GPU: a list waiting on memory that cannot be read yet runs at once and is counted as an unknown comparison #2604

Open
opened 2026-11-26 05:10:08 +00:00 by github-bot · 3 comments
Owner

@⁠BastienRodz on GitHub · 2026-11-25 16:41 UTC · original

What happens

ValueWait::holds (crates/victory-gpu/src/hold.rs, from 9cc37c5) documents two distinct cases:

None for a comparison we do not know (counted by the caller, taken as holding) and for memory that cannot be read (taken as not holding).

It returns None for both, though (read(self.address, self.bytes)?). The caller can't tell them apart: Held::pump takes every None as an unknown comparison (done.unknown += 1, the segment counted as holding). So a list that waits (Wait32BitValueX / Wait64BitValueX) on memory that can't be read yet, for example a page not mapped yet, runs at once, before the work that would write the value. It is also counted as an unknown comparison in the frame's summary. Held::blocked (holds(..) == Some(false)) leaves such a wait out of the unmet ones.

The unit test comparisons_test_the_masked_value asserts None for unreadable memory, so the code matches the test rather than the doc comment.

Expected

The doc comment says memory that cannot be read is "taken as not holding": the queue should hold the segment until the memory reads and the comparison holds, or until the safety valve releases old heads. If releasing at once is the intent, the doc comment, and the summary's "unknown comparison" count, should say so instead.

Where

crates/victory-gpu/src/hold.rs: ValueWait::holds, Held::pump, Held::blocked.

AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.

**@⁠BastienRodz** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/2604) ### What happens `ValueWait::holds` (`crates/victory-gpu/src/hold.rs`, from 9cc37c5) documents two distinct cases: > `None` for a comparison we do not know (counted by the caller, taken as holding) and for memory that cannot be read (taken as not holding). It returns `None` for both, though (`read(self.address, self.bytes)?`). The caller can't tell them apart: `Held::pump` takes every `None` as an unknown comparison (`done.unknown += 1`, the segment counted as holding). So a list that waits (`Wait32BitValueX` / `Wait64BitValueX`) on memory that can't be read yet, for example a page not mapped yet, runs at once, before the work that would write the value. It is also counted as an unknown comparison in the frame's summary. `Held::blocked` (`holds(..) == Some(false)`) leaves such a wait out of the unmet ones. The unit test `comparisons_test_the_masked_value` asserts `None` for unreadable memory, so the code matches the test rather than the doc comment. ### Expected The doc comment says memory that cannot be read is "taken as not holding": the queue should hold the segment until the memory reads and the comparison holds, or until the safety valve releases old heads. If releasing at once is the intent, the doc comment, and the summary's "unknown comparison" count, should say so instead. ### Where `crates/victory-gpu/src/hold.rs`: `ValueWait::holds`, `Held::pump`, `Held::blocked`. AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:08 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:47 UTC · original · edited 2026-11-26 06:45 UTC

Automated triage for the maintainers.

Confirmed in main (63bcca4), in crates/victory-gpu/src/hold.rs. ValueWait::holds returns None through read(self.address, self.bytes)? when the memory cannot be read. Held::pump counts every None as an unknown comparison and runs the segment, and Held::blocked only lists Some(false). This contradicts the doc comment, which says memory that cannot be read is taken as not holding.

PR #2693 was closed without being merged. Open PR #2605 (head 74ccd68, verified in a comment here on an RTX 4070) addresses the counting half only: an unreadable wait is now counted as unreadable and named in the frame warning, and its doc comment matches the code, but the wait still runs at once. The PR body says Fixes #2604; if it is merged as is, the "runs at once" half should stay open here or move to a follow-up issue. The last comment lays out the options for holding the work (hold with the 10 s valve, a shorter separate limit, or keep running until a title run reports unreadable waits).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/2604#issuecomment-7171411205) · edited 2026-11-26 06:45 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-26T04:33:33Z at=2026-11-26T07:10:30Z --> Automated triage for the maintainers. Confirmed in `main` (`63bcca4`), in `crates/victory-gpu/src/hold.rs`. `ValueWait::holds` returns `None` through `read(self.address, self.bytes)?` when the memory cannot be read. `Held::pump` counts every `None` as an unknown comparison and runs the segment, and `Held::blocked` only lists `Some(false)`. This contradicts the doc comment, which says memory that cannot be read is taken as not holding. PR #2693 was closed without being merged. Open PR #2605 (head `74ccd68`, verified in a comment here on an RTX 4070) addresses the counting half only: an unreadable wait is now counted as `unreadable` and named in the frame warning, and its doc comment matches the code, but the wait still runs at once. The PR body says `Fixes #2604`; if it is merged as is, the "runs at once" half should stay open here or move to a follow-up issue. The last comment lays out the options for holding the work (hold with the 10 s valve, a shorter separate limit, or keep running until a title run reports `unreadable` waits). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠pawrenity on GitHub · 2026-11-26 04:06 UTC · original

Comparative verification of the open PRs for this issue, against main at 63bcca4.

Hardware: NVIDIA GeForce RTX 4070, Windows 11 (rustc 1.98.1 MSVC, debug, --locked). Unit tests only. No title run, no game data.

PR Head Own test Fails without the fix Cross-tests Clippy -D warnings (victory-gpu, default + diagnostics) Merges onto main Defects found
#2605 74ccd68 hold::tests::unreadable_waits_are_counted_apart_and_do_not_hold_work passes. hold::/queue::/fence:: 18/18 Test-only hunk on main: does not compile (needs the new Pumped::unreadable field). With the PR's files and only the two new pump arms removed: fails, left: (2, 2, 0) right: (2, 0, 1) (both waits counted as unknown) n/a (no other PR fixes this) clean yes (already based on 63bcca4) none
#2507 37f5700 — — — — — Not related: DirectStorage staging buffer sizes (victory-hle), doesn't touch hold.rs/queue.rs. Closed on 2026-11-26.

Full cargo test -p victory-gpu --lib at 74ccd68: 229 passed, 3 failed, 1 ignored. main gives 229/2/1 (one fewer test).

  • descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views also fail on main when run alone. They are the NVIDIA heap cap failures (#1744).
  • frame::tests::waits_end_on_ticks_and_count_frames failed only in the parallel run. It passed alone 3 times out of 3 with --test-threads=1, so it's a timing flake under load and not caused by this PR.

Scope note: the head moved from c5d0230 (which held the queue until the memory read) to 74ccd68. The current head deliberately keeps main's behaviour. A wait on unreadable memory still runs at once (hold.rs:50 still returns None), but it is now counted as unreadable instead of unknown (hold.rs:151-154), summed in Account, and named in the frame warning (queue.rs:225-231, 344-349). An ALWAYS wait is not counted. Its doc comment now matches the code. So this head fixes the "counted as an unknown comparison" half of the issue title. The "runs at once" half is left for a follow-up, pending title-run numbers, yet the PR body still says Fixes #2604. I found no correctness defect in the diff.

Recommendation: #2605 (74ccd68) is the only applicable PR. It is clean, tested, and merges as is. If it is merged, keep #2604 open, or open a follow-up for holding work until the memory reads, since Fixes #2604 would close the issue with that part unaddressed.

AI-assisted (Claude Code).

**@⁠pawrenity** on GitHub · 2026-11-26 04:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/2604#issuecomment-7182302819) Comparative verification of the open PRs for this issue, against `main` at `63bcca4`. Hardware: NVIDIA GeForce RTX 4070, Windows 11 (rustc 1.98.1 MSVC, debug, `--locked`). Unit tests only. No title run, no game data. | PR | Head | Own test | Fails without the fix | Cross-tests | Clippy `-D warnings` (victory-gpu, default + `diagnostics`) | Merges onto `main` | Defects found | |---|---|---|---|---|---|---|---| | #2605 | `74ccd68` | `hold::tests::unreadable_waits_are_counted_apart_and_do_not_hold_work` passes. `hold::`/`queue::`/`fence::` 18/18 | Test-only hunk on `main`: does not compile (needs the new `Pumped::unreadable` field). With the PR's files and only the two new `pump` arms removed: fails, `left: (2, 2, 0)` `right: (2, 0, 1)` (both waits counted as unknown) | n/a (no other PR fixes this) | clean | yes (already based on `63bcca4`) | none | | #2507 | `37f5700` | — | — | — | — | — | Not related: DirectStorage staging buffer sizes (`victory-hle`), doesn't touch `hold.rs`/`queue.rs`. Closed on 2026-11-26. | Full `cargo test -p victory-gpu --lib` at `74ccd68`: 229 passed, 3 failed, 1 ignored. `main` gives 229/2/1 (one fewer test). - `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views` also fail on `main` when run alone. They are the NVIDIA heap cap failures (#1744). - `frame::tests::waits_end_on_ticks_and_count_frames` failed only in the parallel run. It passed alone 3 times out of 3 with `--test-threads=1`, so it's a timing flake under load and not caused by this PR. Scope note: the head moved from `c5d0230` (which held the queue until the memory read) to `74ccd68`. The current head deliberately keeps `main`'s behaviour. A wait on unreadable memory still runs at once (`hold.rs:50` still returns `None`), but it is now counted as `unreadable` instead of `unknown` (`hold.rs:151-154`), summed in `Account`, and named in the frame warning (`queue.rs:225-231`, `344-349`). An `ALWAYS` wait is not counted. Its doc comment now matches the code. So this head fixes the "counted as an unknown comparison" half of the issue title. The "runs at once" half is left for a follow-up, pending title-run numbers, yet the PR body still says `Fixes #2604`. I found no correctness defect in the diff. Recommendation: #2605 (`74ccd68`) is the only applicable PR. It is clean, tested, and merges as is. If it is merged, keep #2604 open, or open a follow-up for holding work until the memory reads, since `Fixes #2604` would close the issue with that part unaddressed. AI-assisted (Claude Code).
Author
Owner

@⁠pawrenity on GitHub · 2026-11-26 04:33 UTC · original

Follow-up on the "runs at once" half of this issue: what holding the work would take, and why it isn't a code-only fix yet. Read against main at 63bcca4, with #2605 at 74ccd68. Static analysis only. No title run, no game data.

Where it happens

  • crates/victory-gpu/src/hold.rs:50: read(self.address, self.bytes)? returns None when the memory cannot be read.
  • hold.rs:146-150: Held::pump treats that None like an unknown comparison, so the segment runs (#2605 counts it as unreadable and still runs it).
  • hold.rs:210: Held::blocked lists only Some(false). A wait on unreadable memory therefore never starts the 2 ms timer either (queue.rs:237-246).

Why the hold was dropped (from the history of #2605 and #2693)

  • #2693 and #2605 up to c5d0230 both made an unreadable wait return Some(false) (Some(comparison == ALWAYS) after the ALWAYS review). The queue was then held until the memory could be read.
  • No deadlock was found. The only exit for a wait whose memory never becomes readable is the safety valve: VALVE = 10 s (queue.rs:186-191), forced in queue.rs:200-203. So each such wait would stall its queue, and every fence behind it, for 10 s per occurrence. Today it runs at once.
  • How often this happens in a title is unmeasured. The PR author's argument (host::read_into is ReadProcessMemory on our own process, title memory is unified, so a never-readable address is one the title never commits) is plausible but unverified. I found no VirtualProtect/PAGE_NOACCESS on title memory in victory-gpu that would make such reads fail only for a while.
  • The triage on #2605 (head 74ccd68) chose to keep main's behaviour and to hold the work "once a title run shows non-zero unreadable counts".

Options

  1. Hold until readable, with the 10 s valve (the old c5d0230). Small change (hold.rs:50 plus the ALWAYS case), and it matches the original doc comment. Risk: 10 s stalls if the memory never becomes readable.
  2. Hold, but with a separate, shorter limit for unreadable waits (for example a few ms, or until the next frame boundary, then run and count it). This bounds the stall. But the limit is a number nobody can choose without run data, and it needs Held to track why the head is held (the per-item state is only (Item, Instant, fresh) today, hold.rs:95).
  3. Keep running at once and decide from #2605's unreadable and forced counts in a title run. unreadable > 0 alone would show the case exists. Whether the memory later becomes readable would need one more signal: for example, a debug log of the address on the first unreadable test, compared against read_value in the frame summary (queue.rs:327 already prints is {:?} for blocked waits).

Assessment

Holding the work is a two-line change and needs nothing from #2605 to work. What it still lacks is a decision on the stall, not code. Option 1 brings back the risk the triage deferred. Option 2 needs a limit that only run data can set. Until a run reports unreadable, option 3 (the current plan) looks like the right order. If a run shows the memory becomes readable soon after the wait is tested, option 1 or option 2 with that measured limit can stack on #2605: return Some(false) from holds for unreadable memory (except ALWAYS), move the unreadable count to the test that holds, and adapt #2605's test to "held while unreadable, runs once readable" (as an_unreadable_wait_holds_its_queue_until_readable did in c5d0230).

I found no other open PR on this half. #2693 is closed in favour of #2605. #2611 is closed. #2608 deals with segment splitting after read-backs, not unreadable waits.

AI-assisted (Claude Code).

**@⁠pawrenity** on GitHub · 2026-11-26 04:33 UTC · [original](https://github.com/Marvisak/VIctory/issues/2604#issuecomment-7182699833) Follow-up on the "runs at once" half of this issue: what holding the work would take, and why it isn't a code-only fix yet. Read against `main` at `63bcca4`, with #2605 at `74ccd68`. Static analysis only. No title run, no game data. **Where it happens** - `crates/victory-gpu/src/hold.rs:50`: `read(self.address, self.bytes)?` returns `None` when the memory cannot be read. - `hold.rs:146-150`: `Held::pump` treats that `None` like an unknown comparison, so the segment runs (#2605 counts it as `unreadable` and still runs it). - `hold.rs:210`: `Held::blocked` lists only `Some(false)`. A wait on unreadable memory therefore never starts the 2 ms timer either (`queue.rs:237-246`). **Why the hold was dropped (from the history of #2605 and #2693)** - #2693 and #2605 up to `c5d0230` both made an unreadable wait return `Some(false)` (`Some(comparison == ALWAYS)` after the `ALWAYS` review). The queue was then held until the memory could be read. - No deadlock was found. The only exit for a wait whose memory never becomes readable is the safety valve: `VALVE` = 10 s (`queue.rs:186-191`), forced in `queue.rs:200-203`. So each such wait would stall its queue, and every fence behind it, for 10 s per occurrence. Today it runs at once. - How often this happens in a title is unmeasured. The PR author's argument (`host::read_into` is `ReadProcessMemory` on our own process, title memory is unified, so a never-readable address is one the title never commits) is plausible but unverified. I found no `VirtualProtect`/`PAGE_NOACCESS` on title memory in `victory-gpu` that would make such reads fail only for a while. - The triage on #2605 (head `74ccd68`) chose to keep `main`'s behaviour and to hold the work "once a title run shows non-zero `unreadable` counts". **Options** 1. **Hold until readable, with the 10 s valve** (the old `c5d0230`). Small change (`hold.rs:50` plus the `ALWAYS` case), and it matches the original doc comment. Risk: 10 s stalls if the memory never becomes readable. 2. **Hold, but with a separate, shorter limit for unreadable waits** (for example a few ms, or until the next frame boundary, then run and count it). This bounds the stall. But the limit is a number nobody can choose without run data, and it needs `Held` to track why the head is held (the per-item state is only `(Item, Instant, fresh)` today, `hold.rs:95`). 3. **Keep running at once** and decide from #2605's `unreadable` and `forced` counts in a title run. `unreadable > 0` alone would show the case exists. Whether the memory later becomes readable would need one more signal: for example, a debug log of the address on the first unreadable test, compared against `read_value` in the frame summary (`queue.rs:327` already prints `is {:?}` for blocked waits). **Assessment** Holding the work is a two-line change and needs nothing from #2605 to work. What it still lacks is a decision on the stall, not code. Option 1 brings back the risk the triage deferred. Option 2 needs a limit that only run data can set. Until a run reports `unreadable`, option 3 (the current plan) looks like the right order. If a run shows the memory becomes readable soon after the wait is tested, option 1 or option 2 with that measured limit can stack on #2605: return `Some(false)` from `holds` for unreadable memory (except `ALWAYS`), move the `unreadable` count to the test that holds, and adapt #2605's test to "held while unreadable, runs once readable" (as `an_unreadable_wait_holds_its_queue_until_readable` did in `c5d0230`). I found no other open PR on this half. #2693 is closed in favour of #2605. #2611 is closed. #2608 deals with segment splitting after read-backs, not unreadable waits. AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#2604
No description provided.