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

Open
github-bot wants to merge 1 commit from github-bot/gh-410 into main AGit
Owner

@⁠AscilCH on GitHub · 2026-11-25 00:25 UTC · original
AscilCH:fix/gpu-watch-wrote-ahead-asked → main · +46 −0 · 1 files · 1 commits · open

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.)

**@⁠AscilCH** on GitHub · 2026-11-25 00:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/410) `AscilCH:fix/gpu-watch-wrote-ahead-asked` → `main` · +46 −0 · 1 files · 1 commits · open ## 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.)*
Under the default `VICTORY_ASK_ONCE=1`, `ask_once` sets `j.ahead_asked = j.asked`.
When `Step::Copy` writes title memory during submission, `watch::wrote`
incremented `j.asked` and stored `now = j.asked` in `j.written[page]`
without updating `j.ahead_asked`. Subsequent `watch::writes()` and
`watch::asked()` calls therefore returned `(j.ahead_asked, [(page, j.asked)])`
with `write > now`, violating `writes()`'s documented monotonicity
contract and causing `Shadow::copy_stale` to store `*at = now < write` —
triggering redundant re-copies and spurious `stale_under_writes` stalls.

Update `j.ahead_asked = now` inside `watch::wrote` so `now >= write`
always holds while keeping earlier dirty pages at their prior timestamp.

Add `watch::wrote_tests::wrote_keeps_ahead_asked_at_or_above_written_timestamps`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:51 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/watch.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/410/head:github-bot/gh-410'
git switch 'github-bot/gh-410'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-410'
git switch 'github-bot/gh-410'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-410'
git switch 'github-bot/gh-410'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-410'
git switch 'main'
git merge --squash 'github-bot/gh-410'
git switch 'main'
git merge --ff-only 'github-bot/gh-410'
git switch 'main'
git merge 'github-bot/gh-410'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.