card_steps: the two "late" tests forget what an earlier one learned of their pages (order-dependent failure) #3668

Closed
github-bot wants to merge 1 commit from github-bot/gh-3668 into main AGit
Owner

@⁠Trillazill on GitHub · 2026-11-30 03:26 UTC · original
Trillazill:fix/card-steps-test-order → main · +17 −0 · 1 files · 1 commits · closed without merging

Fixes: the card_steps part of #3659.

What it changes

host::card_steps::tests::places_written_after_sending_are_learned passes alone but fails now and then in a run of the whole crate, even single-threaded (--test-threads=1), so it depends on what an earlier test leaves behind, not on tests running side by side.

Cause. late::PAGES, the pages the title was found writing late, belongs to the process, and nothing ever empties it. With a temporary eprintln! in late::learn printing the test thread's name, only two tests learn any pages:

  • fills_done_on_the_cpu_are_learned_too learns the page at page + 4096 of a vec of its own, then lets the vec go.
  • places_written_after_sending_are_learned runs after it in a one-thread run, and often gets the same addresses back from the allocator. Its changed place is on that same page, so its first assertion, !late::written(changed, ..) ("nothing learned yet"), fails.

Whether it happens depends on what the allocator hands back, which is why it comes and goes.

Fix. A test-only late::forget(from, to) drops what was learned of a range. Both tests call it on their own memory before they start. Production code is unchanged.

How it was tested

  • GPU and profile: none. No game was run; test-only change.
  • cargo test --locked -p victory-gpu --lib -- --test-threads=1 host::: on 41adb551, 2 of 5 runs failed a card_steps "late" test; with this change, 0 of 5.
  • Deterministic check: with the stale page planted on purpose at the test's start (late::landed_cpu with bytes that differ, then asserted learned), the test fails 3 of 3 without forget and passes 3 of 3 with it.
  • cargo test --locked -p victory-gpu --lib -- --test-threads=1: 921 passed, 1 failed (shader_cache::tests::every_switch_of_the_translator_is_in_the_key, a stale key entry that fails on main too; #3385 / #3530).
  • cargo clippy -p victory-gpu --all-targets: nothing new in card_steps.rs. cargo xtask policy --staged: ok.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes, apart from the failure above that main has too.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none for these tests. #3659 describes the other victory-gpu test failures (memory contention between GPU tests), which this doesn't address.

🤖 Generated with Claude Code

**@⁠Trillazill** on GitHub · 2026-11-30 03:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668) `Trillazill:fix/card-steps-test-order` → `main` · +17 −0 · 1 files · 1 commits · closed without merging Fixes: the `card_steps` part of #3659. ## What it changes `host::card_steps::tests::places_written_after_sending_are_learned` passes alone but fails now and then in a run of the whole crate, even single-threaded (`--test-threads=1`), so it depends on what an earlier test leaves behind, not on tests running side by side. **Cause.** `late::PAGES`, the pages the title was found writing late, belongs to the process, and nothing ever empties it. With a temporary `eprintln!` in `late::learn` printing the test thread's name, only two tests learn any pages: - `fills_done_on_the_cpu_are_learned_too` learns the page at `page + 4096` of a `vec` of its own, then lets the `vec` go. - `places_written_after_sending_are_learned` runs after it in a one-thread run, and often gets the same addresses back from the allocator. Its `changed` place is on that same page, so its first assertion, `!late::written(changed, ..)` ("nothing learned yet"), fails. Whether it happens depends on what the allocator hands back, which is why it comes and goes. **Fix.** A test-only `late::forget(from, to)` drops what was learned of a range. Both tests call it on their own memory before they start. Production code is unchanged. ## How it was tested - GPU and profile: none. No game was run; test-only change. - `cargo test --locked -p victory-gpu --lib -- --test-threads=1 host::`: on 41adb551, 2 of 5 runs failed a `card_steps` "late" test; with this change, 0 of 5. - Deterministic check: with the stale page planted on purpose at the test's start (`late::landed_cpu` with bytes that differ, then asserted learned), the test fails 3 of 3 without `forget` and passes 3 of 3 with it. - `cargo test --locked -p victory-gpu --lib -- --test-threads=1`: 921 passed, 1 failed (`shader_cache::tests::every_switch_of_the_translator_is_in_the_key`, a stale key entry that fails on main too; #3385 / #3530). - `cargo clippy -p victory-gpu --all-targets`: nothing new in `card_steps.rs`. `cargo xtask policy --staged`: ok. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes, apart from the failure above that main has too. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none for these tests. #3659 describes the other `victory-gpu` test failures (memory contention between GPU tests), which this doesn't address. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
late::PAGES, the pages the title was found writing late, is the
process's and nothing empties it. fills_done_on_the_cpu_are_learned_too
learns the page at page + 4096 of a vec of its own and lets the vec go;
places_written_after_sending_are_learned, after it in a run of one
thread, often gets the same addresses back, and its `changed` place is on
that page, so its first assertion (nothing learned yet) failed. Whether
it did depended on what the allocator handed back: 2 of 5 runs of
`cargo test -p victory-gpu --lib -- --test-threads=1 host::` on 41adb551.

A test-only late::forget(from, to) drops what was learned of a range;
both tests call it on their memory first. With the stale page planted on
purpose (landed_cpu with bytes that differ), the test fails 3 of 3
without it and passes 3 of 3 with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 03:31:37 +00:00
Author
Owner

@⁠davemathews12 on GitHub · 2026-11-30 05:26 UTC · original · edited 2026-11-30 05:41 UTC

I checked this by reading it, and it looks right to me:

  • The cause is exactly as described. late::PAGES is never emptied, and both tests allocate the same vec![0u8; 4 * 4096]. So when fills_done_on_the_cpu_are_learned_too runs first, the allocator very likely hands its block straight back to places_written_after_sending_are_learned, and that block's second page is already marked. The first assert!(!late::written(changed, …)) then fails. In the other order nothing fails.
  • forget removes keys from / PAGE .. to.div_ceil(PAGE). That is the same page-index form written and learn use, so it really clears what was learned.
  • Clearing a test's own range can't disturb the other test: each test's marked pages lie fully inside its own live buffer.

This is also what keeps #3530 (the CI fix) red, where places_written_after_sending_are_learned failed. Merging this first should let #3530 go green. It merges cleanly with main.

Edit: As wrq2007 notes on #3530, this PR comes from a fork, so its test workflow hasn't run yet (only the label check is green). Could a maintainer approve the workflow run here? Once it's green and merged, #3530 can be re-run, and main should finally be green.

**@⁠davemathews12** on GitHub · 2026-11-30 05:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7269667494) · edited 2026-11-30 05:41 UTC I checked this by reading it, and it looks right to me: - The cause is exactly as described. `late::PAGES` is never emptied, and both tests allocate the same `vec![0u8; 4 * 4096]`. So when `fills_done_on_the_cpu_are_learned_too` runs first, the allocator very likely hands its block straight back to `places_written_after_sending_are_learned`, and that block's second page is already marked. The first `assert!(!late::written(changed, …))` then fails. In the other order nothing fails. - `forget` removes keys `from / PAGE .. to.div_ceil(PAGE)`. That is the same page-index form `written` and `learn` use, so it really clears what was learned. - Clearing a test's own range can't disturb the other test: each test's marked pages lie fully inside its own live buffer. This is also what keeps #3530 (the CI fix) red, where `places_written_after_sending_are_learned` failed. Merging this first should let #3530 go green. It merges cleanly with `main`. Edit: As wrq2007 notes on #3530, this PR comes from a fork, so its test workflow hasn't run yet (only the label check is green). Could a maintainer approve the workflow run here? Once it's green and merged, #3530 can be re-run, and main should finally be green.
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 05:49 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 05:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7270045372) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠Trillazill on GitHub · 2026-12-01 06:20 UTC · original

Closing: #2486 (merged) adds the same late::forget isolation to places_written_after_sending_are_learned and fills_done_on_the_cpu_are_learned_too.

**@⁠Trillazill** on GitHub · 2026-12-01 06:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7302764779) Closing: #2486 (merged) adds the same `late::forget` isolation to `places_written_after_sending_are_learned` and `fills_done_on_the_cpu_are_learned_too`.
github-bot closed this pull request 2026-12-01 06:26:09 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!3668
No description provided.