GPU: the held-work pump reads each wait's word once, and answers its own blocked question #3245
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3247"
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?
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T14:25:43Z.
The held-work pump read every wait's memory word through
ReadProcessMemoryon every test, and its caller immediately asked the same question again, which read them all a second time.The shape of it
queue::pumprunsHeld::pump, thenif held.blocked(&read).is_empty() { return; }— andblockedwalks the same queue heads and callsw.holds(read)on the same waits, i.e. oneReadProcessMemoryper 4–8 byte word per blocked queue, again. The pump itself runs on every submission, every fence poll, and every 2 ms tick of its timer thread; at a 1.8 s frame that is ~900 pumps.What changes
Held::pumpkeeps each word's answer for the duration of one pump — cleared whenever work actually runs (that is what changes memory; with no run, only another thread can, and a stale answer costs at most one 2 ms timer tick of latency). Two waits on the same word in one head now cost one read.Pumpedgainsblocked: bool, which the pump sets when it leaves a head waiting.queue::pumpasks that instead of callingHeld::blocked, so the second read pass is gone.Held::blockeditself is untouched —account_framestill uses it once per presented frame for the "still held" log line.Cost removed
Arithmetic, not a title measurement: one kernel read (~1.5 µs) per blocked queue per pump, removed; at 4 blocked queues and ~900 pumps a frame that is ~6 µs/pump, ~5–6 ms per frame, plus the duplicate reads of the same word within a pump. The frame line already prints the pump's own time, so a run with this merged shows the difference directly.
Verification
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings— clean; same with--all-features.cargo test -p victory-gpu --lib --locked --no-fail-fast— 231 passed, 2 failed, both the known Intel baseline failures pristinemainalso fails (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views, #1744/#1829).hold::tests::a_pump_reads_each_word_once_and_says_if_anything_is_blockedcounts the reads through the pump and assertsPumped::blocked.rustfmt --edition 2024 --checkhunk counts againstmain:hold.rs11/11,queue.rs10/10.Synthetic tests only; no game data.
Part of the fifteen gaps claimed for this sweep on #1633. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T14:27:41Z.
Review: COMMENTED
Reviewed the diff and ran local verification on Windows 11 x64 (cargo test -p victory-gpu --lib hold:: -- --test-threads=1: 11/11 passed; cargo clippy -p victory-gpu --all-targets -- -D warnings: clean; cargo xtask policy: 191 files ok).
The per-pump read cache (cleared on
un/signal) looks clean, but Pumped::blocked has two behavioral regressions compared to the previous held.blocked(&read).is_empty() check in queue.rs:
Note that pump() already finishes with self.queues.retain(|(_, items)| !items.is_empty());, so setting done.blocked = !self.queues.is_empty() right after
etain (or using the existing held.is_empty() in queue.rs) is exact, O(1), performs zero memory reads, and avoids both edge cases.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T14:33:29Z.
Fixed at
08d821941ba0c0770459aaa29927d00c652798ed— both edge cases, exactly as you suggested.done.blockedis no longer set when a segment's wait is found unmet. It is taken once, afterself.queues.retain(|(_, items)| !items.is_empty()), as!self.queues.is_empty()— which is precisely what the oldheld.blocked(&read).is_empty()asked: any queue with anything left, aFenceWaitincluded, and zero memory reads to know it. A queue drained in an earlier pass of the same pump is already gone fromself.queuesby then, so the flag cannot go stale within one pump.hold::tests::a_pump_reads_each_word_once_and_says_if_anything_is_blockednow also covers both cases: a queue drained within one pump asserts!p.blocked, and a remainingItem::FenceWait(5, 9)against fence value 0 assertsp.blocked.Local re-verification on this side (Windows 11, Intel Arc B580):
cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand--all-featuresclean;cargo test -p victory-gpu --lib --locked --no-fail-fast230 passed, 2 failed — both the known B580 baseline failures pristine main also fails (#1744/#1829);rustfmt --edition 2024 --checkhunk count for hold.rs unchanged at 11/11 against main. Synthetic tests only; no game data.Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T14:42:38Z.
Independent local verification of head
08d8219on Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-gpu --lib -- hold::tests::a_pump_reads_each_word_once_and_says_if_anything_is_blocked --exact— 1 passed, 0 failed.git diff --checkagainst merge base — clean.CPU-only synthetic test; worktree-local
CARGO_TARGET_DIR. AI-assisted (Hy4 flash). GPU/driver N/A. No game data, assets or DRM material used.Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T22:53:21Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, since none of them names a GPU run. Tested exact head
08d8219(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.a_pump_reads_each_word_once_and_says_if_anything_is_blocked.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:00:03Z.
Review: APPROVED
Looks good — clean, exact optimization that eliminates redundant wait-word reads during
Held::pumpand inqueue::pump.Checked
crates/victory-gpu/src/hold.rs:140-232andcrates/victory-gpu/src/queue.rs:234-240:(address, bytes)keeps 4-byte and 8-byte waits at the same address distinct, avoids redundant reads across repeated passes/waits, and invalidating the cache on bothrun(hold.rs:190, 218) andsignal(hold.rs:210) ensures causal writes from either path are observed in the next pass of the same pump.done.blocked = !self.queues.is_empty()right afterself.queues.retain(|(_, items)| !items.is_empty())(hold.rs:227-231) is exact — matching!held.blocked(&read).is_empty()for segments, fence waits, unknown comparisons, and valve-released queues without re-reading every wait word inqueue.rs.Verification (
08d82194):cargo xtask policyandcargo clippy -p victory-gpu(default and--features diagnostics,--tests -- -D warnings): passed.hold::tests::(11/11) on both hardware GPU and WARP, andqueue::tests::(5/5) on hardware GPU: passed.Signalcallback mutating a wait word to unblock another queue within the same pump, a shared blocked word across 3 waits on 2 queues (exactly 1 read),force_older_than+pumpclearingblocked, andp.blocked == !held.blocked(&read).is_empty()equivalence across all states: passed.Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T06:38:45Z.
Thank you for running the full suite on the 5070 Ti — an NVIDIA green run is the data point this PR was missing, since the reports before yours were CPU-only or a single crate.
Notes for anyone reading later: the skips you list are all failures on
63bcca4on that card too, including thevictory-shaderprocess dying atheap_direct_texture_reads_mark_their_heap_index(#2571) which would otherwise hide the rest of the crate's results — so 867 passed / 0 failed / 10 ignored with those skips is the right comparison, anda_pump_reads_each_word_once_and_says_if_anything_is_blockedpassing is the one this PR adds.Nothing further needed from my side; the head is still
08d8219and CI is green on it. Synthetic tests only, no game data.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.