GPU: waits on memory that cannot be read are counted apart (#2604) #2605
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!2605
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2605"
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?
@BastienRodz on GitHub · 2026-11-25 16:41 UTC · original
BastienRodz:gpu/unreadable-wait-holds-queue-pr→main· +50 −6 · 2 files · 1 commits · openWhat's wrong
ValueWait::holds(9cc37c5) returnsNoneboth for a comparison we do not know and for memory that cannot be read. Its doc comment says the first is "taken as holding" and the second "taken as not holding".Held::pumpcan't tell the two apart: it counts everyNoneas an unknown comparison and lets the work run. So a wait on memory that isn't readable yet runs at once and is reported as an unknown comparison. Nobody can see whether titles make such waits, or whether that memory becomes readable later.What the fix does
This keeps
main's behaviour, as the triage suggested: such work still runs at once. The change makes the case visible:Held::pumpcounts waits on unreadable memory apart, asPumped::unreadable. AnALWAYSwait never reads its memory and is not counted.queue.rs'sAccountsums them per frame. The frame's warning reportsunreadablenext toforced,unknownandmappings, and a frame with only such waits is no longer skipped.holdsnow says what the code does.Holding the work back until the memory reads, the earlier version of this PR, can follow once a title run shows such waits happen and their memory becomes readable.
Tests
New
hold::tests::unreadable_waits_are_counted_apart_and_do_not_hold_work:unreadable1 andunknown0;ALWAYSwait on the same memory runs and is not counted.hold::tests(11),queue::tests(5) andfence::tests(2) pass under Wine 10 (they need no device), andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.Not tested
No title run. The counter is what such a run would report.
Fixes #2604
AI-assisted (Claude Code). No game data used.
🤖 Generated with Claude Code
@DrDarkDK on GitHub · 2026-11-25 16:44 UTC · original
One edge case in
ValueWait::holds: if the address is unreadable, this patch returnsSome(false)before reaching theALWAYScomparison. The base returnsNoneand the pump releases the segment. With the patch, anALWAYSwait can hold the queue until the address becomes readable or the 10-second safety valve fires.Should
ALWAYSreturnSome(true)before the memory read? If that matches the intended behavior, addingw(ALWAYS, 5).holds(&|_, _| None) == Some(true)alongside the unreadableEQUALcase would cover both paths.Static review only.
AI-assisted with Codex.
@BastienRodz on GitHub · 2026-11-25 16:47 UTC · original
Good catch @DrDarkDK, thanks.
ALWAYSdoesn't read the memory, so it now holds whether or not the address is readable:holdsreturnsSome(self.comparison == ALWAYS)when the read fails, and the unit test checksw(ALWAYS, 5)with unreadable memory next to theEQUALcase.hold::tests11/11.@welisonzika14-jpg on GitHub · 2026-11-25 17:49 UTC · original
First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head
5de820amerged ontomain13f91ca,cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast -- --skip heap_direct_texture_reads_mark_their_heap_index. That one test is skipped because it kills the process on hardware on the currentmain(#2571, fixed by #2596/#2587).The PR's new test(s) pass on this card:
hold::tests::an_unreadable_wait_holds_its_queue_until_readable. The rest is the same asmainon this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests invictory-gpu, 3 invictory-shader), nothing new.One run, unit tests only, title not run.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
@kotekompotek on GitHub · 2026-11-25 17:50 UTC · original
Reviewed: returning
Some(comparison == ALWAYS)on unreadable memory is the right split — a queue wait must not pass on unverifiable data, whileALWAYSnever reads. The companion test (held until readable, then proceeds) pins the behavior. Note this overlaps the sameholds()as #2608/#2611 — all three are complementary pieces of the same wait-semantics fix; they merge cleanly on different hunks.@fuzeofficlal on GitHub · 2026-11-25 18:01 UTC · original
Tested
5de820a8merged cleanly ontomain(13f91ca) on Windows 11 with NVIDIA GeForce RTX 5090 (32.0.16.1656) and D3D12 WARP (--features diagnostics):cargo test -p victory-gpu --lib hold::tests: 11 passed, 0 failed (default and RTX 5090--features diagnostics)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics -- --test-threads=1: 199 passed, 0 failed, 1 ignoredcargo clippy -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): clean (0 warnings)Checked
ValueWait::holdswith unreadable memory (ALWAYSreturnsSome(true), all other predicates returnSome(false)soHeld::blockedkeeps the queue held for the 2 ms timer / safety valve) — looks clean and ready.@Kajanos on GitHub · 2026-11-25 19:05 UTC · original
One risk nobody has raised yet:
read_value(queue.rs) reads the address directly as a CPU pointer. A wait on an address that never becomes readable (GPU-only memory, or an address we do not emulate) used to run at once and was counted as unknown. With this change, each such wait holds its queue for the fullVALVE(10 s) until the safety valve forces it, logging "held work runs without its waits". If the title does this in the world, it turns slightly misordered work into multi-second stalls.Before merging, it would help to check whether real runs show a non-zero "unknown" count in the frame summary. If they do, count unreadable addresses separately first (keep releasing, report them apart from unknown comparisons) to see whether they become readable later or never do.
AI-assisted (Claude Code). Reasoning only; tests not run (no Windows host).
@BastienRodz on GitHub · 2026-11-25 19:06 UTC · original
That's a fair risk to raise, and you're right that the PR has no in-game data. Its "Not tested" section says how often this happens isn't measured.
Two points that narrow it.
read_valuegoes throughhost::read_into, which isReadProcessMemoryon our own process. It fails only when the page isn't mapped readable at that moment. As far as I can see, every address a title passes as a wait's GPU address is title memory in this process: the console's memory is unified, and resources here live at title addresses. So "GPU-only memory" has no separate address space in this code path. An address that never becomes readable is one the title never commits. On the console, such a wait could not be satisfied either, and the title's own fence would hang.VALVE, 10 s) and then runs with the "held work runs without its waits" warning. On main it runs at once and is counted asunknown, a count that also includes unknown comparisons. So the two outcomes are a stall that is logged, or ordering that may be wrong and is lumped in with unknown comparisons. Which one is better depends on whether real runs hit this at all, and nobody has measured that yet.I agree that counting unreadable waits on their own would settle it. It would be a separate counter in
queue.rs'sAccount, next tounknown. I'd rather keep this PR to thehold.rsfix that matches the function's doc comment. If the maintainer wants that number before merging, I'll add it here or as a follow-up. Anyone running the title with this PR: a non-zeroforcedcount in the frame summary, together with the "held work runs without its waits" warning, would be the signal.@Marvisak on GitHub · 2026-11-25 23:19 UTC · original · edited 2026-11-26 03:21 UTC
Automated triage for the maintainers.
Thanks for splitting it.
74ccd68now does what the last triage asked for: behaviour stays as onmain, and the case becomes visible.Held::pump(crates/victory-gpu/src/hold.rs) still runs waits whose memory cannot be read. It now counts them asPumped::unreadableinstead ofunknown.ALWAYSwaits are left uncounted. That arm can be reached, becauseholdsreads memory before it checks the comparison.queue.rsAccountadds the count to the frame warning.holdsnow matches what the code does.Holding such work until the memory can be read is left for a follow-up, once a title run shows non-zero
unreadablecounts.Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.
Generated by Claude Code
@BastienRodz on GitHub · 2026-11-25 23:24 UTC · original
Rebased on
main(842b0cb) and added the separate count the triage asks for, asc5d0230:hold::Pumpedgetsunreadable: tests of waits whose memory could not be read. It is counted only when a wait holds, so the common path reads nothing more.queue.rs'sAccountsums it per frame. The frame line's warning reportsunreadablenext toforced,unknownandmappings, and a frame with only unreadable waits is no longer skipped.an_unreadable_wait_holds_its_queue_until_readablechecks one count while the memory is unreadable and none once it reads.How to read a title run:
unreadable > 0withforcedat 0 means the memory became readable and the wait held only until then.forcedgrowing with it means waits that never become readable, the stall @Kajanos raised. I have no title to run; numbers from anyone who does would settle it.hold::tests(11),queue::tests(5) andfence::tests(2) pass under Wine, andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.@BastienRodz on GitHub · 2026-11-26 00:30 UTC · original
Split as suggested, as
74ccd68(one commit on63bcca4): the PR now keepsmain's behaviour and only makes the case visible.main.unreadableinPumpedand in the frame'sAccount, and reported in the frame warning next toforced.holdsnow matches the code.Holding such work until the memory reads can come as a follow-up once a run shows the count is non-zero and the memory becomes readable. The title and description are updated.
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.