diff --git a/tests/test_mmap_warn.py b/tests/test_mmap_warn.py new file mode 100644 index 000000000..f3d51b70b --- /dev/null +++ b/tests/test_mmap_warn.py @@ -0,0 +1,17 @@ +import os + + +def test_mem_mmap_hook_warn(caplog): + """ + Test warning for UCX_MEM_MMAP_HOOK_MODE + """ + import logging + + os.environ["UCX_MEM_MMAP_HOOK_MODE"] = "none" + + # ucp.init will only print INFO LINES + with caplog.at_level(logging.INFO): + import ucp + + ucp.init() + assert any(["UCX memory hooks" in rec.message for rec in caplog.records]) diff --git a/ucp/__init__.py b/ucp/__init__.py index bb9865d0f..4477cd0a1 100644 --- a/ucp/__init__.py +++ b/ucp/__init__.py @@ -39,6 +39,13 @@ if not os.environ.get("UCX_TCP_RX_SEG_SIZE", False): os.environ["UCX_TCP_RX_SEG_SIZE"] = "8M" +if os.environ.get("UCX_MEM_MMAP_HOOK_MODE", False) == "none": + msg = ( + "WARNING: Disabling UCX memory hooks also disables IB registration " + "cache and zero-copy flows in UCX. This can cause serious performance " + "degradation." + ) + logger.warning(msg) # After handling of environment variable logging, add formatting to the logger logger = get_ucxpy_logger()