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

Closed
Trillazill wants to merge 1 commit from upstream-pr/3668 into main
Trillazill commented 2026-11-30 03:26:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Trillazill on 2026-11-30T03:26:48Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5558428402 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668). Originally posted by [Trillazill](https://github.com/Trillazill) on 2026-11-30T03:26:48Z. --- 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)
davemathews12 commented 2026-11-30 05:26:16 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by davemathews12 on 2026-11-30T05:26:16Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7269667494 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7269667494). Originally posted by [davemathews12](https://github.com/davemathews12) on 2026-11-30T05:26:16Z. --- 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.
dyshay commented 2026-11-30 05:49:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T05:49:50Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7270045372 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7270045372). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-30T05:49:50Z. --- 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.
Trillazill commented 2026-12-01 06:20:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Trillazill on 2026-12-01T06:20:40Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7302764779 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3668#issuecomment-7302764779). Originally posted by [Trillazill](https://github.com/Trillazill) on 2026-12-01T06:20:40Z. --- 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`.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3668
No description provided.