GPU: the held-work pump reads each wait's word once, and answers its own blocked question #3247
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3247
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@borosf on GitHub · 2026-11-26 14:25 UTC · original
borosf:vibe/pump-reads-once-842ca5→main· +97 −7 · 2 files · 2 commits · openThe 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.
@Dukestar69 on GitHub · 2026-11-26 14:27 UTC · original · reviewed
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).
@borosf on GitHub · 2026-11-26 14:33 UTC · original
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.@cloph-dsp on GitHub · 2026-11-26 14:42 UTC · original
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.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.