Skip to content

UCS/RCACHE: Default merging rcache regions to on - #12267

Merged
william-gallagher-nv merged 3 commits into
openucx:masterfrom
william-gallagher-nv:default-rcache-merge-enable
Nov 22, 2026
Merged

william-gallagher-nv merged 3 commits into
openucx:masterfrom
william-gallagher-nv:default-rcache-merge-enable

Conversation

@william-gallagher-nv

@william-gallagher-nv william-gallagher-nv commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What?

Change default to enable merging adjacent rcache regions. Opt out available by setting UCX_RCACHE_MERGE_ADJACENT=n. Testing is added to ensure that merging of adjacent regions does not occur when disabled.

Why?

The ability merge adjacent rcache regions was added in #11958. The UCX_RCACHE_MERGE_ADJACENT environmental variable was added with the original PR. This PR toggles the default to merging adjacent regions. Defaulting to enabling the merging of adjacent regions provides a better user experience for applications that register large numbers of memory regions.

@william-gallagher-nv william-gallagher-nv self-assigned this Nov 5, 2026
@william-gallagher-nv
william-gallagher-nv requested a review from a team as a code owner November 5, 2026 21:58
@william-gallagher-nv william-gallagher-nv added the WIP-DNM Work in progress / Do not review label Nov 5, 2026
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucs/memory/rcache.c Resolved
Comment thread src/ucs/memory/rcache.c Resolved
@svc-ucx

svc-ucx commented Nov 5, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Build build_x86_64 centos7) · commit 31921dfc

TL;DR: The job never built anything — it died in the Azure Pipelines "Initialize containers" step because docker inspect on rdmz-harbor.rdmz.labs.mlnx/ucx/centos7:5 returned "No such object" on agent swx-rdmz-instinct01; this is an agent/Docker infrastructure problem, not a code regression from PR #12267, so simply re-run the pipeline (and clean the agent's Docker image cache).

Full analysis

Summary: Build build_x86_64 centos7 (build 143175) failed during container initialization with Exit code 1 returned from process: file name '/scrap/bin/docker', arguments 'inspect --format=... rdmz-harbor.rdmz.labs.mlnx/ucx/centos7:5'.

Root cause: Infrastructure/Docker-state inconsistency on the build agent. The log shows docker pull rdmz-harbor.rdmz.labs.mlnx/ucx/centos7:5 returning Status: Image is up to date (22:01:16.412) — i.e. the pull was a no-op based on the local manifest — but the immediately following docker inspect of the same tag failed with Error: No such object: rdmz-harbor.rdmz.labs.mlnx/ucx/centos7:5 (22:01:19.110). The image reference was therefore not actually resolvable locally: either the local image store is corrupt/partially GC'd, or a concurrent image prune/docker rmi on the shared agent (swx-rdmz-instinct01, slot -05, multiple concurrent jobs do docker network prune/cleanup) removed the image between the pull and the inspect. No source compilation, no test, and not even the git checkout of the PR merge commit happened before the failure (checkout ran only after the container step already errored, and "Stop Containers"/"Finalize Job" followed within 2 seconds). There is no evidence of any UCX code involvement — the whole job lasted ~7 seconds and the total log is pure agent bootstrap. This is also not a timeout: there are no gaps larger than ~3 seconds anywhere in the log.

Implicated commit: unknown — not a code regression; commit 31921df / PR #12267 code was never compiled or executed in this build.

File: unknown (failure is in the Azure agent container-initialization step, before any repo file is used; pipeline definition: buildlib/azure-pipelines-pr.yml)

Suggested fix: Re-run the failed job — this class of failure is transient. If it recurs on swx-rdmz-instinct01, have CI admins clean up that agent's Docker state (docker image prune -a then re-pull rdmz-harbor.rdmz.labs.mlnx/ucx/centos7:5, or docker rmi the stale tag to force a full re-pull) and check for cron/other jobs running docker system prune concurrently with pipeline jobs on that shared host, since the agent's own prune --filter "label=f35170" plus an unfiltered external prune would explain an image disappearing between pull and inspect. As a hardening step, consider adding a pull retry/docker image inspect pre-check (or setting a non-shared image cache per agent slot) in the container resource setup.

Related: #12094 (CI: Jenkins integration testing) — only loosely related CI infrastructure work; no existing issue tracks this specific Docker No such object flake.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucs/memory/rcache.c Resolved
Comment thread test/gtest/ucp/test_ucp_mmap.cc Resolved
Comment thread test/gtest/ucp/test_ucp_mmap.cc Resolved
Switches UCX_RCACHE_MERGE_ADJACENT default from 'n' to 'y'. Regions of
memory that are adjacent in memory will be merged into a single region
when possible.
@william-gallagher-nv
william-gallagher-nv force-pushed the default-rcache-merge-enable branch from 15ae738 to 46561ab Compare November 12, 2026 13:30
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

size_t size,
ucs_memory_type_t mem_type)
{
mapped_buffer target = mapped_buffer(size, receiver(), 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: direct initialization is enough here, no need for the temporary copy.

Suggested change
mapped_buffer target = mapped_buffer(size, receiver(), 0,
mapped_buffer target(size, receiver(), 0, UCS_MEMORY_TYPE_HOST);

ucp_context_h context = sender().ucph();
ucs_rcache_t *rcache = context->rcache;
ucp_mem_map_params_t params;
const size_t size = ucs_get_page_size();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: this block duplicates the allocate + register-first-half setup of test_adjacent_registration; maybe extract a small helper for it?

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage note: test_ucp_rcache_merge is instantiated only via UCP_INSTANTIATE_TEST_CASE_TLS(..., rcx, "rc_x,cuda_copy"), so the UCP-level merge/no-merge assertions run only on that transport pair; the new default elsewhere is validated only indirectly by the rest of the suite running with merging enabled. Generic merge logic is covered by test_rcache_merge_adjacent in test/gtest/ucs/test_rcache.cc, so this is acceptable, but it is worth keeping in mind if CI shows transport-specific fallout from the default change.

@william-gallagher-nv william-gallagher-nv removed the WIP-DNM Work in progress / Do not review label Nov 12, 2026
@gleon99
gleon99 requested a review from nbellalou November 12, 2026 16:00
@gleon99

gleon99 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@nbellalou please review

@william-gallagher-nv

Copy link
Copy Markdown
Contributor Author

@nbellalou Can you take a look when you get a chance?

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucs/memory/rcache.c
ucs_offsetof(ucs_rcache_config_t, purge_on_fork), UCS_CONFIG_TYPE_BOOL},

{"RCACHE_MERGE_ADJACENT", "n", "Merge adjacent registration cache regions",
{"RCACHE_MERGE_ADJACENT", "y", "Merge adjacent registration cache regions",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucp_mem_rcache_can_merge_cb() short-circuits to 1 for host memory, without the same-allocation check used for GPU memory (alloc_base/alloc_len). With the default flipped, two unrelated host allocations that happen to be adjacent will be de-registered and re-registered as one region, and later freeing one of them invalidates the registration of the other.

Was this measured on host registration-heavy workloads? Should host merging also be limited to the same allocation, like GPU memory?

@svc-ucx

svc-ucx commented Nov 19, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (AddressSanitizer BlueField on worker 1) · commit 388886e5

TL;DR: The ASAN/BlueField gtest job failed on a LeakSanitizer report (68024 byte(s) leaked in 17 allocation(s)) — every leaked block was allocated in test_ucp_proto_mock_rcx_speed_change.rma_put's init(), i.e. the mocked rc_mlx5 interface and the wireup UCT endpoint of the initial EP configuration are never destroyed after the simulated IBV_EVENT_DEVICE_SPEED_CHANGE reconfiguration. This is a master-side regression in the EP-reconfiguration/lane-discard path (newly landed #12362/#12334), not something PR #12267 (rcache merge default) can cause.

Full analysis

Summary: ./contrib/test_jenkins.sh → make test in build-test/test/gtest exited non-zero because LeakSanitizer detected leaks attributed to test_ucp_proto_mock_rcx_speed_change_rma_put (make: *** [Makefile:5017: test] Error 1, Bash exited with code '2').

Root cause: All 17 leaked allocations have allocation stacks that bottom out in the test's setup path (test_ucp_proto_mock.cc:5108 → :5026 → :501/:503 → ucp_worker_create / ucp_ep_create):

  • one UCT endpoint of the initial configuration: QP buffer 64 KB (uct_ib_mlx5_devx_create_qp, ib_mlx5_dv.c:290), qp struct 56 B (ib_mlx5_dv.c:163), devx obj 48 B, uct_rc_mlx5_ep_t_new 320 B (rc_mlx5_ep.c:2601), plus its dbrec;
  • the owning wireup proxy EP: 832 B from uct_stub_iface_open (uct_iface.c:1232 via ucp_wireup_ep_create);
  • interface-level resources: TX/RX CQ buffers and dbrecs (ib_iface.c:2038/2044, ib_mlx5_dv.c:695/704) and the SRQ dbrec (rc_mlx5_devx.c:233);
  • an indirect leak of the MD's devx UAR (ib_mlx5.c:601 via uct_ib_mlx5_devx_check_uar) and dbrec-mpool page (ib_mlx5dv_md.c:1717 via ucs_mpool_grow) — the classic signature of dbrec objects never returned to the MD pool, which makes ucs_mpool_cleanup leak-check refuse to release the chunk.

In other words a UCT ep/iface pair from the pre-speed-change configuration is dropped without being discarded (ucp_worker_discard_uct_ep) when set_port_speed() → ib_event(IBV_EVENT_DEVICE_SPEED_CHANGE) forces a new EP/rkey config; the orphaned QP then keeps the MD dbrec pool and UAR alive to process exit. No UCP worker/context allocations are in the report, so the entity itself was destroyed — this is a real resource leak inside UCX, not a test-teardown-skipped artifact.

Implicated commit: Most likely 4748c2a0 "UCP/RMA: Balance PUT fragments by measured path bandwidth (#12362)" (dmitrygx, 2026-11-18, ~10 h before this run — touches this exact test, ucp_worker.c and ucp_ep.c, and only the rma_put variant is affected); secondary suspects 48795b8b (#12334, per-endpoint path bandwidth, adds worker->ep_path_bw) and f68fa5fc (#12360, force-close EPs on worker destroy). PR #12267 ("UCS/RCACHE: Default merging rcache regions to on") touches only the registration cache and cannot allocate CQ/QP/UAR objects, so it is almost certainly an innocent bystander.

File: test/gtest/ucp/test_ucp_proto_mock.cc:5108 (failing test) — leak origin in src/ucp/wireup/wireup.c:2937 (ucp_wireup_check_config_intersect, lane reuse/discard on reconfiguration) and src/ucp/core/ucp_worker.c:4220 (ucp_worker_discard_uct_ep)

Suggested fix:

  1. Reproduce on plain master (no PR changes) with ASAN_OPTIONS=detect_leaks=1 ./gtest --gtest_filter='*rcx_speed_change*rma_put*' plus UCX_LOG_LEVEL=debug; the head of the log (truncated in Azure) should contain the ucs_mpool_cleanup "object not returned" / uct_rc_iface ep-leak warnings that pinpoint the orphaned QP.
  2. Fix the reconfiguration path so lanes present in the old EP config but absent (or re-indexed) in the new config are routed through ucp_worker_discard_uct_ep() (which also destroys the wireup proxy EP) instead of being overwritten — the leaked set is exactly one lane's uct_ep + its ucp_wireup_ep.
  3. Meanwhile, rebase PR UCS/RCACHE: Default merging rcache regions to on #12267 onto a master revision that passes this job (or re-run) so the PR is not blocked by the regression; do not suppress the leak in test/gtest/common/asan_suppressions — it is a genuine QP/CQ leak.

Related: PR #12267 (the PR under test), PR #12362 / #12334 / #12360 (recent commits touching the failing test and EP reconfiguration), PR #11901 "TEST/UCP: Make test_port_speed more robust" (previous instability of this same test). No existing issue found for this leak — worth filing one.

@nbellalou nbellalou left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@william-gallagher-nv why changing the default behavior now ? Did you run perf tests demonstrating that auto merging is a good trade-off in the general case ?

@william-gallagher-nv

Copy link
Copy Markdown
Contributor Author

@william-gallagher-nv why changing the default behavior now ? Did you run perf tests demonstrating that auto merging is a good trade-off in the general case ?

@nbellalou, after discussion with @gleon99 we decided to change the default behavior to be "opt out". This provides a better user experience by allowing applications with large numbers of memory registrations to work without extra configuration. The cost of merging is one time cost and is amortized over the life of the registration.

I did some testing with OSU alltoall test. This is the test case that originally exposed the memory region exhaustion issue that these PRs address. The alltoall test does a buffer transfer from every rank to every other rank. This can generate a very large number of memory registrations if no merging occurs. Latency is measured for a single iteration of the test. This is the best way to to measure the effect of merging adjacent regions. All registrations happen on the first iteration of the test.

Nodes Ranks per Node Total Ranks Registrations per Host (unmerged) ENABLE_MERGE=n Latency (us) ENABLE_MERGE=y Latency (us) GVA Latency (us)
5 192 960 ~184,320 56,764,483 50,411,364 132,068,550
60 192 11520 ~2,211,840 Mkey Exhaustion 598,866,361 245,886,984

Merging adjacent regions is slightly faster than not merging for the smaller scale OSU alltoall test. GVA is used here as another point of comparison because disabling merging fails. GVA is faster than merging adjacent regions for large scale tests.

@william-gallagher-nv
william-gallagher-nv enabled auto-merge (squash) November 21, 2026 04:01
@william-gallagher-nv

Copy link
Copy Markdown
Contributor Author

@gleon99 Can you take a look and give maintainer approval?

@william-gallagher-nv
william-gallagher-nv merged commit c8677c2 into openucx:master Nov 22, 2026
190 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants