GPU/watch: advance ahead_asked in watch::wrote to preserve writes/asked monotonicity #410

Open
AscilCH wants to merge 1 commit from upstream-pr/410 into main
AscilCH commented 2026-11-25 00:25:55 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T00:25:55Z.


Problem

In crates/victory-gpu/src/watch.rs, under the default VICTORY_ASK_ONCE=1, ask_once sets j.ahead_asked = j.asked (e.g., 10) and j.kept = true. When Step::Copy later calls watch::wrote(dst, len) during the submission:

  • watch::wrote increments j.asked to 11 and inserts j.written[page] = 11, without updating j.ahead_asked.
  • Subsequent watch::writes() and watch::asked() calls return (now = 10, [(page, write = 11)]), violating writes()'s contract (now >= write).
  • Shadow::copy_stale refreshes the page and records *at = now = 10 < 11, so every subsequent refresh still sees write > *at — causing redundant re-copies and spurious WHY_STALE stalls in Shadow::stale_under_writes.

Fix

  • Set j.ahead_asked = now; in watch::wrote alongside j.asked += 1;.
  • Add unit test watch::wrote_tests::wrote_keeps_ahead_asked_at_or_above_written_timestamps.

Verification

  • cargo test -p victory-gpu --locked watch -- --test-threads=1: 8 passed, 0 failed
  • cargo xtask policy: 169 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean

(AI-assisted; synthetic unit tests only, no game data.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594264154 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/410). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T00:25:55Z. --- ## Problem In `crates/victory-gpu/src/watch.rs`, under the default `VICTORY_ASK_ONCE=1`, `ask_once` sets `j.ahead_asked = j.asked` (e.g., `10`) and `j.kept = true`. When `Step::Copy` later calls `watch::wrote(dst, len)` during the submission: - `watch::wrote` increments `j.asked` to `11` and inserts `j.written[page] = 11`, **without updating `j.ahead_asked`**. - Subsequent `watch::writes()` and `watch::asked()` calls return `(now = 10, [(page, write = 11)])`, violating `writes()`'s contract (`now >= write`). - `Shadow::copy_stale` refreshes the page and records `*at = now = 10 < 11`, so every subsequent refresh still sees `write > *at` — causing redundant re-copies and spurious `WHY_STALE` stalls in `Shadow::stale_under_writes`. ## Fix - Set `j.ahead_asked = now;` in `watch::wrote` alongside `j.asked += 1;`. - Add unit test `watch::wrote_tests::wrote_keeps_ahead_asked_at_or_above_written_timestamps`. ## Verification - `cargo test -p victory-gpu --locked watch -- --test-threads=1`: 8 passed, 0 failed - `cargo xtask policy`: 169 files ok - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings`: clean *(AI-assisted; synthetic unit tests only, no game data.)*
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/410:upstream-pr/410'
git switch 'upstream-pr/410'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/410'
git switch 'upstream-pr/410'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/410'
git switch 'upstream-pr/410'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/410'
git switch 'main'
git merge --squash 'upstream-pr/410'
git switch 'main'
git merge --ff-only 'upstream-pr/410'
git switch 'main'
git merge 'upstream-pr/410'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!410
No description provided.