Repository navigation
UCS/RCACHE: Adds capability for merging adjacent rcache regions - #11958
Conversation
When enabled, rcache regions of adjacent memory will be merged. Merges only occur when new region is the same size or larger than the existing region. This prevents continually reregistering the same memory region when adding many small regions in a row.
|
🤖 Starting review — findings will be posted here when done. |
|
Residual coverage gap: no test for the gap-fill path (both neighbors present) and no negative test that regions are not merged when the flag is off; both are cheap to add once the tests use their own fixture. The knob Growth is unbounded by design (each merge at least doubles the region), so |
|
🤖 CI Triage Agent — TL;DR: The gtest Full analysisSummary: Root cause: Commit ucs_rcache_params_t params = {sizeof(ucs_rcache_region_t), UCM_EVENT_VM_UNMAPPED, 1000, ops, context,
/* Temp for testing merge code. */
UCS_RCACHE_FLAG_MERGE_ADJACENT, ULONG_MAX, SIZE_MAX};( Because
Note also that Implicated commit: File: Suggested fix:
Related: PR #11958 (this PR, WIP), PR #11803 "UCS/RCACHE: Merge adjacent regions" (earlier attempt at the same feature)
|
|
🤖 Starting review — findings will be posted here when done. |
|
Residual coverage note: No test covers the |
|
Open Questions:
|
Fixes random_merge test case assumption that regions always combine to a single region.
|
🤖 Starting review — findings will be posted here when done. |
|
Note: Adjacent merging never pins memory the user did not already register or request (merged span is always Note: Added lines are right at the ~500 line ceiling from |
|
🤖 CI Triage Agent — TL;DR: The gtest run failed on a single test, Full analysisSummary: Root cause: The Azure log tail only preserves the summary block ( Implicated commit: db208ee "UCP/FT: probe-gated lane recovery via aux uct_ep_check (#11563)", Evgeny Leksikov — the commit that added this test (PR commit [REDACTED:Hex High Entropy String]/[REDACTED:Hex High Entropy String] by William Gallagher on rcache is not implicated) File: test/gtest/ucp/test_ucp_fault_tolerance.cc:922-943 (assertion at :941) Suggested fix: Re-run the failed job to confirm flakiness, and harden the test: install a Related: PR #11958 (this PR, rcache merge adjacent), PR #11803 (earlier rcache merge attempt), PR #11563 (introduced probe-gated recovery + this test); prior precedent for disabling a flaky FT test: 13ae935 "TEST/GTEST: Disable failing fault-tolerance test (#11397)"
|
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The build failed to compile Full analysisSummary: "Build ucx artifact" step of the WireCompat build on Root cause: In Exact log evidence: Implicated commit: File: Suggested fix: Initialize the pointers and use them as the guard so the compiler can see the correlation, dropping the redundant static void
ucs_rcache_check_adj_regions(ucs_rcache_t *rcache, void *arg,
ucs_pgt_addr_t start, ucs_pgt_addr_t end,
ucs_list_link_t *list)
{
ucs_pgt_region_t *pgt_left, *pgt_right;
ucs_rcache_region_t *region_left = NULL;
ucs_rcache_region_t *region_right = NULL;
if (rcache->params.ops->can_merge == NULL) {
return;
}
pgt_left = ucs_pgtable_lookup(&rcache->pgtable, start - 1);
pgt_right = ucs_pgtable_lookup(&rcache->pgtable, end);
if (pgt_left != NULL) {
region_left = ucs_derived_of(pgt_left, ucs_rcache_region_t);
if (!rcache->params.ops->can_merge(arg, region_left)) {
region_left = NULL;
}
}
if (pgt_right != NULL) {
region_right = ucs_derived_of(pgt_right, ucs_rcache_region_t);
if (!rcache->params.ops->can_merge(arg, region_right)) {
region_right = NULL;
}
}
/* Fill in a gap between two existing registrations */
if ((region_left != NULL) && (region_right != NULL)) {
ucs_list_add_tail(list, ®ion_left->tmp_list);
ucs_list_add_tail(list, ®ion_right->tmp_list);
return;
}
if ((region_left != NULL) &&
ucs_rcache_check_adj_size(start, end, region_left)) {
ucs_list_add_tail(list, ®ion_left->tmp_list);
}
if ((region_right != NULL) &&
ucs_rcache_check_adj_size(start, end, region_right)) {
ucs_list_add_tail(list, ®ion_right->tmp_list);
}
}This keeps behavior identical and removes the warning on all GCC versions. (Do not silence it with a Related: PR #11958 (branch
|
Add addition checks to adjacent regions before merging two rcache regions. The checks ensure that the two regions have the same memory type and memory flags and are part of the same allocation.
2ee19de to
f964120
Compare
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The Full analysisSummary: Root cause: In This is not just a warning-pedantry issue — the Implicated commit: File: Suggested fix: Initialize the pointers at declaration, and drop the now-redundant static void
ucs_rcache_check_adj_regions(ucs_rcache_t *rcache, void *arg,
ucs_pgt_addr_t start, ucs_pgt_addr_t end,
ucs_list_link_t *list)
{
ucs_pgt_region_t *pgt_left, *pgt_right;
ucs_rcache_region_t *region_left = NULL; /* <-- add */
ucs_rcache_region_t *region_right = NULL; /* <-- add */
int can_merge_left = 0;
int can_merge_right = 0;
...Note the codebase is built with Related: PR #11958 (
|
|
🤖 Starting review — findings will be posted here when done. |
|
🤖 CI Triage Agent — TL;DR: The Full analysisSummary: Azure job Root cause: The compile itself succeeded; the failure is purely the static-analysis gate. Log excerpt: This PR ( 796: ucp_mem_rcache_reg_ctx_t reg_ctx = {
797: .mem_type = mem_type,
798: .mem_flags = mem_info->mem_flags,
799: .alloc_base = mem_info->base_address,
800: .alloc_len = mem_info->alloc_length,The 2045: status = ucp_memh_rcache_get(rcache, unpacked->address,
2046: unpacked->length, UCS_RCACHE_MIN_ALIGNMENT,
2047: unpacked->mem_type, 0, 0, 0, "", &memh);So this is a real NULL dereference reachable whenever Implicated commit: File: Suggested fix: In ucs_memory_info_t mem_info;
...
mem_info.type = unpacked->mem_type;
mem_info.sys_dev = UCS_SYS_DEVICE_ID_UNKNOWN;
mem_info.base_address = unpacked->address;
mem_info.alloc_length = unpacked->length;
mem_info.mem_flags = UCS_MEM_FLAG_REGISTRABLE;
status = ucp_memh_rcache_get(rcache, unpacked->address, unpacked->length,
UCS_RCACHE_MIN_ALIGNMENT, unpacked->mem_type,
&mem_info, 0, 0, "", &memh);Setting Related: #11958
|
|
🤖 Starting review — findings will be posted here when done. |
|
Residual note: Residual note: the |
|
@william-gallagher-nv The last push brought ~20 master commits (#12060, #12154, #12069, #12110, ...) into the branch as new commits, so the PR now shows 74 files and +3221 lines. Merged into current master, the real change is 6 files (rcache.c/h, ucp_mm.c, rocm_copy_md.c, test_rcache.cc, test_ucp_mmap.cc). Can you git merge upstream/master (or rebase onto it) and push, so the diff shows only the rcache change? It also pulled in CODEOWNERS reviewers for files this PR doesn't change. |
|
🤖 CI Triage Agent — TL;DR: The build never got past the "Get sources" step — Full analysisSummary: Root cause: Authentication to GitHub was unavailable to the checkout task. In the log, Implicated commit: unknown — failure is pre-checkout; no repository content was fetched, so no commit is implicated. File: unknown — no repository file was involved (failure in the Azure Pipelines Suggested fix: Have the CI admins rotate/refresh the GitHub service connection (PAT or GitHub App installation token) used by the Related: none — searches for this error signature returned only unrelated PRs (no existing issue tracking the checkout auth failure).
|
e03cd3f to
ab90c1b
Compare
|
🤖 Starting review — findings will be posted here when done. |
@yafshar I accidently squashed a merge commit with master before pushing the last two commits. Fixed now. Sorry for the spam on unrelated changes. |
| ucp_unpacked_exported_memh_t *unpacked) | ||
| { | ||
| ucs_memory_info_t mem_info = { | ||
| .type = UCS_MEMORY_TYPE_HOST, |
There was a problem hiding this comment.
minor: mem_info.type is set to UCS_MEMORY_TYPE_HOST while the same call passes unpacked->mem_type as the memory type. Harmless today (only sys_dev/base_address/alloc_length/mem_flags are read out of mem_info), but the two values contradict each other in one statement.
| .type = UCS_MEMORY_TYPE_HOST, | |
| .type = unpacked->mem_type, |
|
Residual coverage gaps (previously reported, noted again for completeness): |
|
🤖 CI Triage Agent — TL;DR: The GPU worker-3 gtest run failed on a single unrelated test, Full analysisSummary: Root cause: The only failing test is a UCT TCP connection-manager (tcp_sockcm) test that is completely unrelated to the PR under test. PR #11958 (
Implicated commit: unknown — not attributable to the PR commit File: Suggested fix:
Related: PR #11958 (the PR under test, rcache merge-adjacent); related earlier attempt PR #11803. No existing issue found for
|
What?
When enabled, rcache regions of adjacent memory will be merged. Merges only occur when new region is the same size or larger than the existing region. This prevents continually reregistering the same memory region when adding many small regions in a row.
Why?
Reduce the number of memory keys in use for sequences of adjacent memory regions. When using too many memory keys, NIC can run out of resources and fail to register memory.
Fixes #6264
How?
The rcache already has handling for memory regions that overlap with existing registrations. This is extend to handle regions that sit adjacent in memory when enabled. This is a little more difficult. Overlapping regions can be can safely be assumed to be of the same memory type and from the same allocation. This isn't true for adjacent memory regions. This is handled by checking to make sure that the regions have the same memory type, memory flags, and are part of the same allocation.