From 2595da2b2b61bce877b5e3138294bd871d36be07 Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Wed, 30 Sep 2020 10:13:31 -0700 Subject: [PATCH 1/2] add warning for when UCX_MEM_MMAP_HOOK_MODE is set --- tests/test_mmap_warn.py | 17 +++++++++++++++++ ucp/__init__.py | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/test_mmap_warn.py diff --git a/tests/test_mmap_warn.py b/tests/test_mmap_warn.py new file mode 100644 index 000000000..178ed924a --- /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_MEM_MMAP_HOOK_MODE" in rec.message for rec in caplog.records]) diff --git a/ucp/__init__.py b/ucp/__init__.py index bb9865d0f..3cc98d669 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): + msg = ( + "Setting `UCX_MEM_MMAP_HOOK_MODE` disable IB registration cache " + "which disable GPURDMAincluding GPU direct. \nPlease unset " + "UCX_MEM_MMAP_HOOK_MODE" + ) + logger.warning(msg) # After handling of environment variable logging, add formatting to the logger logger = get_ucxpy_logger() From 37c207cd506fd1da98f2adf38efca0041c21821a Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Wed, 30 Sep 2020 11:22:09 -0700 Subject: [PATCH 2/2] use peters suggestion --- tests/test_mmap_warn.py | 2 +- ucp/__init__.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_mmap_warn.py b/tests/test_mmap_warn.py index 178ed924a..f3d51b70b 100644 --- a/tests/test_mmap_warn.py +++ b/tests/test_mmap_warn.py @@ -14,4 +14,4 @@ def test_mem_mmap_hook_warn(caplog): import ucp ucp.init() - assert any(["UCX_MEM_MMAP_HOOK_MODE" in rec.message for rec in caplog.records]) + assert any(["UCX memory hooks" in rec.message for rec in caplog.records]) diff --git a/ucp/__init__.py b/ucp/__init__.py index 3cc98d669..4477cd0a1 100644 --- a/ucp/__init__.py +++ b/ucp/__init__.py @@ -39,11 +39,11 @@ 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): +if os.environ.get("UCX_MEM_MMAP_HOOK_MODE", False) == "none": msg = ( - "Setting `UCX_MEM_MMAP_HOOK_MODE` disable IB registration cache " - "which disable GPURDMAincluding GPU direct. \nPlease unset " - "UCX_MEM_MMAP_HOOK_MODE" + "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)