Scope UMA migration locks by pool and protect closing pool IDs #392
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!392
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-392"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lucalocastro on GitHub · 2026-12-03 23:54 UTC · original
lucalocastro:codex/uma-fault-latency→main· +439 −42 · 3 files · 3 commits · openA CPU fault can wait for a worker staging a migration in an unrelated physical pool. There is also a window during teardown when an allocator can reuse a numeric pool ID before the previous owner has finished clearing its metadata.
Evidence
In a synthetic Windows test with a forced 2 ms writer hold, median access time for an unrelated pool fell from 2.0125 to 0.0075 ms (P99 from 2.1716 to 0.0143 ms). Two views of the same backing page still waited about 2.01 ms and saw the writer's value. With no writer the median was 0.0013 ms in both arms. Five paired runs, 240 samples per case per run, originally measured on an integration checkout based on
eb51227. In-game frame-time impact is open.The close/reuse fixture passed in 100 isolated Windows processes on the original combined branch. It covers both an unmapped address and a new section at the same virtual address, pool ID and offset. A competing allocation runs during teardown. The test uses real Windows views and simulates the driver free callback. After splitting the branch, the UMA unit tests and all three isolated lock, rebind and reuse tests passed. Earlier full-suite runs on this Windows machine stopped at
descriptor::tests::views_die_with_their_resource.One A/B comparison requested
Compare A, the common base
1152b9c, with B, this PR tip2403d00. Both use the same fixed read-ahead. The separate opt-in experiment is #397.Please repeat the same save and scripted inputs in A/B/B/A order. Cover a city traversal, a steady interior and repeated save reloads or streaming transitions with background loading active. Include RT off/on, CPU-limited and GPU-limited settings, the normal title budget and a verified 512 MiB cap where supported. Reports from different Radeon generations and VRAM capacities are welcome. A paging-disabled comparison is a useful control. Keep driver, cache state, frame cap and frame generation settings matched. Report cold loads separately; for steady play, warm up one minute and record the next three.
Please attach CPU, GPU/VRAM, OS, driver, Wine/Proton, resolution, commit, actual title budget and per-run P50/P95/P99 frame times, FPS and frames over 50/100 ms. Raw frame-time samples and CPU submit time help establish whether the lock affects slow frames. For repeated load/unload, report completed cycles, the first failure, logs and any visual corruption, dropped draws, hangs or device loss. Neutral results are useful too.
Scope UMA migration locks by pool and test adaptive CPU read-aheadto Scope UMA migration locks by pool and protect closing pool IDs268f2df04fto2403d00164@Kal0s-design on GitHub · 2026-12-04 02:23 UTC · original
Tested
2403d00natively on Windows 11 (MSVC) with one NVIDIA desktop card, against the merge base1152b9c.Worth saying up front that
um::loadonly picks an AMD Vulkan device, so none of the real fault, residency or teardown paths run here. Nothing on this machine runs tick, place or the kick either, so the residency.rs side is review only. What I could check is the lock and ID logic through the synthetic tests.materialize_rechecks_pool_after_rebind,materialize_during_pool_close_and_reuseandclosing_pool_reserves_id_until_cleanup_finisheseach passed 20 out of 20, one process per run.materialize_while_batch_holds_movinggives about the same numbers as the description. The unrelated pool with a 2 ms hold has a median around 0.007 ms, the alias still waits about 2.01 ms and sees the writer's value.cargo test -p victory-gpu --lib(skippingviews_die_with_their_resourceas before) is 340 passed, 5 failed, 26 ignored on the PR and 339 / 5 / 23 on the base. Same 5 failures on both, the difference is just the new tests.--all-targets.I also ran a throwaway stress test (not pushed) with a thread doing 1 ms write holds on pool A while two threads hammer faults on A and on an unrelated pool B for 3 s. On the base B's worst fault matched A's at 1.2 to 1.7 ms. On the PR it was 0.1 to 0.37 ms and B's mean went from about 3.8 to 1.45 µs. A second writer taking A and B together never deadlocked. Three threads looping insert_pool and close_pool (millions of cycles, 5 runs) never got an ID that was still inside its free callback. That only goes through the same seam as your unit test, not the real pool() and pool_gone.
From reading I didn't find an ordering problem. tick is the only writer, takes the pool locks in index order and only does driver calls and page flags under them. materialize holds at most one read lock and drops the old one before waiting on a rebound pool.
One small thing. close_pool removes the ID from
closingonly afterfreereturns, so an unwind there would leave it reserved for good. Nothing in that path looks likely to panic, but a drop guard would cover it.Not from this PR, but pool_to_card drops the state mutex and later calls pool_closing and pool_opened on the same ID without the reservation, so a pool_gone racing with a promotion could still leave stale lazy or residency metadata for a reused ID.
AI-assisted: yes
@fsrajner on GitHub · 2026-12-04 08:14 UTC · original
Tested on top of main together with the other PRs listed below, with no measurable change in this scene. That is expected for a lock-scope change in a GPU-bound scene. It ran 4 × 2-minute sessions on this build with no hangs or errors.
Setup: RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, RADV from this repo's
setup.sh. Series X, 3840x2160 output, FSR 4 Quality (4.1.2), RT at defaults, headless gamescope. Same save (the intro); the game stops 120 s after the first press. The figures come from the 5 sstats: framewindows after loading. 2 runs per variant; main =0fd7614. The PR build is main + #382 + #392 + #393 + #408 + #445 + #369 together. #398 was left out because it conflicts with #369 in the residency planning. The #369 merge conflicted only with local counters.VICTORY_TEXTURE_BARRIERS=1VICTORY_CARD_KEPT_MB=9216The first run of main and of the PR build each began by re-preparing shaders after a translator change. That is likely where the 48 ms run and the 82.9 ms worst window come from. Otherwise the spread between runs is about ±1 ms/frame, so all of these are within noise. In this scene the card is the limit (about 21-24 ms of GPU wait per frame).
@Luxuride on GitHub · 2026-12-04 11:28 UTC · original
The shape is right and I could not break it: a fault path takes at most one read guard and only after releasing the page lock (
um/lazy.rs:700after:697), so it cannot invert against the writer's ascending order;moving_pools[id]cannot go out of bounds because onlyid < MOST_POOLSpools are registered (um/residency.rs:178,:510); andmaterializere-checks the pool id after re-taking the page lock and drops the stale guard (:688-690), which is the case that would otherwise use a closed pool's lock.Two asks:
crates/victory-gpu/src/um/residency.rs:791-796. They are the only place that records why the lock is dropped before the kernel kick (every thread that first-touched any page waited for the whole move), and that ordering is now the entire point of the patch.pool.dead && pool.views == 0teardown inunalias(um.rs:1399-1405) still frees under the state mutex and never touchesclosing— safe, but exactly the shapeclose_poolexists to stop, and the new rule's comment does not mention it.Merging note: this and #398 both edit the
lazy::moving()line and add a row at the same spot indocs/SETTINGS.md; whoever lands second rebases.@lucalocastro on GitHub · 2026-12-04 12:04 UTC · original · edited 2026-12-04 12:09 UTC
@Kal0s-design @Luxuride I’ve prepared a local commit that releases the
closingreservation through a drop guard and adds a regression test for unwinding fromfree. I restored the six lines explaining why the guards are dropped beforekick. I also documented the last-view path inforget: the caller holds the state mutex throughoutfree_pool, so the allocator cannot reuse the ID during that cleanup. Thepool_to_cardfollow-up is separate.@fsrajner Thanks for testing on AMD. The combined build showed no measurable frame-time gain in the intro. The contention improvement reported on the synthetic test is specific to faults on an unrelated pool.
The changes are now on this PR in
8105929cf1. I checked the patch against the PR head; I haven’t run the Rust tests on this revision.github-bot referenced this pull request2026-12-05 11:35:00 +00:00
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.