d3d12: eliminate quadratic Refresh scans and allocations in card_steps (D3D12-CARD-STEPS-PLAN-SCRATCH) #3069

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "github-pr/3069:github-pr/3069"
git switch "github-pr/3069"
Open
leonida/mandy
piyonchu wants to merge 2 commits from github-pr/3069 into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'github-pr/3069:github-pr/3069'
git switch 'github-pr/3069'
piyonchu commented 2026-12-02 08:26:34 +00:00

Claimed in the coordination issue as: D3D12-CARD-STEPS-PLAN-SCRATCH (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7338836162)

What and why

Relates to #2940 ("title bytes under flights' writes" / "steps on the card" submitting-thread CPU overhead).

This replaces quadratic per-submission scans and per-frame heap allocations in host::card_steps and its blocked_by / copied_read gate in host.rs with zero-behavior-change algorithmic improvements:

  1. Single-pass blocked_by_into across runs (host.rs, card_steps.rs): Fuses blocked_by and copied_read into one walk over runs across Host::card_steps, late_blocked, and relay_wait (preserving exact WHY_RUN/WHY_READ and diagnostics blame precedence while stopping as soon as needed).
  2. Active-only planning & Does::Refresh filtering (does_of_into, plan_indices): Routes Step::Refresh entries straight to RefreshIndex instead of appending ~20,000 Does::Refresh items to does, so seeding, dependency wave propagation, Placed barrier checks, and CPU-reader conflict checks only inspect active copy/fill/read/placed entries (O(W * |active|) instead of O(W * N)). Replaces Box<dyn Iterator> heap allocations and indirect indexing in level assignment with direct out_rw / copy_writes reverse scan and max_copy_level early break (preserving zero-length Does::Copy overlap checks). Also makes host::join_ranges compact in-place instead of allocating a fresh Vec per merge.
  3. Hybrid lazy interval tree for elsewhere (RefreshIndex): Stays linear for small spans/early queries (queries < 16 || spans.len() < 128) and lazily sorts, deduplicates, and builds an in-place midpoint max_to interval tree when elsewhere is queried heavily under LEONIDA_CARD_STEPS=2 (including when a 174 MiB heap refresh spans sub-allocations).
  4. Thread-local scratch reuse & direct FillTo expansion (CardStepsScratch, ScratchGuard, RecordScratch): Reuses persistent does, active, run_steps, list_ptrs, RefreshIndex, PlanScratch, writers, ops, places, held, room, spans, op_buckets (O(ops) bucketed level recording), and RecordScratch across cut_for and take_steps_with_scratch while clear_retained() drops all Arc/ID3D12Resource handles and borrowed transition barriers immediately on every return or unwind. Resolves FillTo directly by (run_idx, step_idx) in O(1) without linear pointer searches or intermediate Vec<To> allocations.

Tested

All commands run on perf/d3d12-card-steps-plan-scratch (aef892880) in d:\GTAVI\Leonida\d3d12 (with no game files):

  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs — passed (exit 0)
  • cargo check --lib -p leonida-gpu --locked — passed (0 warnings in touched files)
  • cargo check --lib -p leonida-gpu --features diagnostics --locked — passed (0 warnings in touched files)
  • cargo clippy -p leonida-gpu --lib --tests --locked — passed (0 warnings in touched files)
  • cargo test --locked -j 4 -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws --test-threads=1 — 693 passed; 0 failed; 61 ignored; 1 filtered out (includes new equivalence tests refresh_index_matches_linear_elsewhere, plan_scratch_and_active_filter_match_reference, and single_pass_blocked_by_into_matches_legacy_precedence)
  • LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2 cargo test --locked -p leonida-gpu --lib -- a_copy_behind_a_flight_reads_what_the_flight_wrote --ignored --nocapture --test-threads=1 — 1 passed; 0 failed (48 of 48 copies were done on the card, 0 submissions waited)
  • cargo test -p leonida-gpu --features diagnostics --test replay --locked — 1 passed; 0 failed (a_frame_is_recorded_and_replayed)
  • cargo test --release --locked -j 4 -p leonida-gpu --lib -- bench_card_steps --ignored --nocapture --test-threads=1 (2 passed; 0 failed):
    • card_steps elsewhere: 4 queries / 20k refreshes before=27.6 us/iter, after=28.9 us/iter (0.96x); 120 queries / 20k refreshes before=813.2 us/iter, after=594.0 us/iter (1.37x)
    • card_steps plan (20k refreshes + 4k fills + 118 copies): before=289.9 us/iter, after=134.4 us/iter (2.16x)

GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656) / Intel(R) UHD Graphics (driver 32.0.101.6790), Microsoft Windows NT 10.0.26200.0 (unit, replay, and LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2 card-steps tests ran; no retail game data).

AI-assisted: yes (Antigravity + independent read-only reviewer subagent audited the diff against cont/main before committing and verified review fixes).

Checklist

  • Based on current main (a917c54d6) and merges cleanly.
  • One topic (host::card_steps planning/scratch and single-pass blocked_by_into); follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No translator rules added (docs/design.md not applicable).
Claimed in the coordination issue as: D3D12-CARD-STEPS-PLAN-SCRATCH (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7338836162) ### What and why Relates to #2940 (`"title bytes under flights' writes"` / `"steps on the card"` submitting-thread CPU overhead). This replaces quadratic per-submission scans and per-frame heap allocations in `host::card_steps` and its `blocked_by` / `copied_read` gate in `host.rs` with zero-behavior-change algorithmic improvements: 1. **Single-pass `blocked_by_into` across `runs` (`host.rs`, `card_steps.rs`):** Fuses `blocked_by` and `copied_read` into one walk over `runs` across `Host::card_steps`, `late_blocked`, and `relay_wait` (preserving exact `WHY_RUN`/`WHY_READ` and `diagnostics` `blame` precedence while stopping as soon as needed). 2. **Active-only planning & `Does::Refresh` filtering (`does_of_into`, `plan_indices`):** Routes `Step::Refresh` entries straight to `RefreshIndex` instead of appending ~20,000 `Does::Refresh` items to `does`, so seeding, dependency wave propagation, `Placed` barrier checks, and CPU-reader conflict checks only inspect active copy/fill/read/placed entries (`O(W * |active|)` instead of `O(W * N)`). Replaces `Box<dyn Iterator>` heap allocations and indirect indexing in level assignment with direct `out_rw` / `copy_writes` reverse scan and `max_copy_level` early break (preserving zero-length `Does::Copy` overlap checks). Also makes `host::join_ranges` compact in-place instead of allocating a fresh `Vec` per merge. 3. **Hybrid lazy interval tree for `elsewhere` (`RefreshIndex`):** Stays linear for small spans/early queries (`queries < 16 || spans.len() < 128`) and lazily sorts, deduplicates, and builds an in-place midpoint `max_to` interval tree when `elsewhere` is queried heavily under `LEONIDA_CARD_STEPS=2` (including when a 174 MiB heap refresh spans sub-allocations). 4. **Thread-local scratch reuse & direct `FillTo` expansion (`CardStepsScratch`, `ScratchGuard`, `RecordScratch`):** Reuses persistent `does`, `active`, `run_steps`, `list_ptrs`, `RefreshIndex`, `PlanScratch`, `writers`, `ops`, `places`, `held`, `room`, `spans`, `op_buckets` (`O(ops)` bucketed level recording), and `RecordScratch` across `cut_for` and `take_steps_with_scratch` while `clear_retained()` drops all `Arc`/`ID3D12Resource` handles and borrowed transition barriers immediately on every return or unwind. Resolves `FillTo` directly by `(run_idx, step_idx)` in `O(1)` without linear pointer searches or intermediate `Vec<To>` allocations. ### Tested All commands run on `perf/d3d12-card-steps-plan-scratch` (`aef892880`) in `d:\GTAVI\Leonida\d3d12` (with no game files): - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs` — passed (exit 0) - `cargo check --lib -p leonida-gpu --locked` — passed (0 warnings in touched files) - `cargo check --lib -p leonida-gpu --features diagnostics --locked` — passed (0 warnings in touched files) - `cargo clippy -p leonida-gpu --lib --tests --locked` — passed (0 warnings in touched files) - `cargo test --locked -j 4 -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws --test-threads=1` — `693 passed; 0 failed; 61 ignored; 1 filtered out` (includes new equivalence tests `refresh_index_matches_linear_elsewhere`, `plan_scratch_and_active_filter_match_reference`, and `single_pass_blocked_by_into_matches_legacy_precedence`) - `LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2 cargo test --locked -p leonida-gpu --lib -- a_copy_behind_a_flight_reads_what_the_flight_wrote --ignored --nocapture --test-threads=1` — `1 passed; 0 failed` (`48 of 48 copies were done on the card, 0 submissions waited`) - `cargo test -p leonida-gpu --features diagnostics --test replay --locked` — `1 passed; 0 failed` (`a_frame_is_recorded_and_replayed`) - `cargo test --release --locked -j 4 -p leonida-gpu --lib -- bench_card_steps --ignored --nocapture --test-threads=1` (`2 passed; 0 failed`): - `card_steps elsewhere`: 4 queries / 20k refreshes `before=27.6 us/iter, after=28.9 us/iter (0.96x)`; 120 queries / 20k refreshes `before=813.2 us/iter, after=594.0 us/iter (1.37x)` - `card_steps plan` (20k refreshes + 4k fills + 118 copies): `before=289.9 us/iter, after=134.4 us/iter (2.16x)` GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU (driver `32.0.16.1656`) / Intel(R) UHD Graphics (driver `32.0.101.6790`), Microsoft Windows NT `10.0.26200.0` (unit, `replay`, and `LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2` card-steps tests ran; no retail game data). AI-assisted: yes (Antigravity + independent read-only reviewer subagent audited the diff against `cont/main` before committing and verified review fixes). ### Checklist - [x] Based on current `main` (`a917c54d6`) and merges cleanly. - [x] One topic (`host::card_steps` planning/scratch and single-pass `blocked_by_into`); follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] No translator rules added (`docs/design.md` not applicable).
Kal0s-design commented 2026-12-02 08:33:03 +00:00

Windows 11, MSVC toolchain 1.98.1, head aef892880 (on main a917c54d6). These are the configurations the description didn't run: the lib in parallel, with diagnostics, on WARP and with the debug layer.

cargo test -p leonida-gpu --lib, in parallel: 694 passed, 0 failed, 61 ignored.

cargo test -p leonida-gpu --features diagnostics --lib, in parallel:

device result
hardware 775 passed
WARP (LEONIDA_D3D12_WARP=1) 775 passed
hardware + LEONIDA_D3D12_DEBUG=1 775 passed
WARP + debug layer 775 passed, twice. A third run had 1 failure, descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync. I've seen that test fail once before on WARP on another branch that doesn't touch card_steps, so I take it for a flake outside this change.

a_copy_behind_a_flight_reads_what_the_flight_wrote (ignored), with LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2: "48 of 48 copies were done on the card, 0 submissions waited". It passed on hardware, on WARP, and on hardware with the debug layer.

--features diagnostics --test replay: 1 passed.

cargo clippy -p leonida-gpu --features diagnostics --lib --tests: no warning in the changed lines. The one hit in host.rs (mem_replace_with_default at the BLAMED take) is on a line this PR doesn't change.

Not run: the release bench, and the game.

GPUs tested: one NVIDIA desktop card + WARP.

AI-assisted: yes (Claude Code).

Windows 11, MSVC toolchain 1.98.1, head `aef892880` (on `main` `a917c54d6`). These are the configurations the description didn't run: the lib in parallel, with `diagnostics`, on WARP and with the debug layer. `cargo test -p leonida-gpu --lib`, in parallel: 694 passed, 0 failed, 61 ignored. `cargo test -p leonida-gpu --features diagnostics --lib`, in parallel: | device | result | |---|---| | hardware | 775 passed | | WARP (`LEONIDA_D3D12_WARP=1`) | 775 passed | | hardware + `LEONIDA_D3D12_DEBUG=1` | 775 passed | | WARP + debug layer | 775 passed, twice. A third run had 1 failure, `descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync`. I've seen that test fail once before on WARP on another branch that doesn't touch `card_steps`, so I take it for a flake outside this change. | `a_copy_behind_a_flight_reads_what_the_flight_wrote` (ignored), with `LEONIDA_RELAY=2 LEONIDA_CARD_STEPS=2`: "48 of 48 copies were done on the card, 0 submissions waited". It passed on hardware, on WARP, and on hardware with the debug layer. `--features diagnostics --test replay`: 1 passed. `cargo clippy -p leonida-gpu --features diagnostics --lib --tests`: no warning in the changed lines. The one hit in `host.rs` (`mem_replace_with_default` at the `BLAMED` take) is on a line this PR doesn't change. Not run: the release bench, and the game. GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
ecox982745 commented 2026-12-02 08:40:57 +00:00

CPU-only source review at aef892880. One diagnostics change in the relay path is worth separating from the preserved wait decisions. On main, the relay_wait predicate calls copied_read whenever blocked_by(..., false) finds no remaining shader-write blocker. copied_read still records its matching range via blame. If the initial shader-write blocker lands first and a card-copy destination still has a reader, blamed at the end of the wait reports that copy reader and its range.

The new predicate passes count=false to blocked_by_into in host.rs:8194. That drops the copy hit's metadata and can leave the initial shader-write attribution in the frame line even when the copy reader kept the wait going. The boolean settle decision is the same. It would help the #2940 measurements to preserve the copy-only attribution on relay polls, or describe the change explicitly. The new boolean equivalence test does not check BLAMED.

AI-assisted static review. No game files or GPU use.

CPU-only source review at `aef892880`. One diagnostics change in the relay path is worth separating from the preserved wait decisions. On main, the `relay_wait` predicate calls `copied_read` whenever `blocked_by(..., false)` finds no remaining shader-write blocker. `copied_read` still records its matching range via `blame`. If the initial shader-write blocker lands first and a card-copy destination still has a reader, `blamed` at the end of the wait reports that copy reader and its range. The new predicate passes `count=false` to `blocked_by_into` in `host.rs:8194`. That drops the copy hit's metadata and can leave the initial shader-write attribution in the frame line even when the copy reader kept the wait going. The boolean settle decision is the same. It would help the #2940 measurements to preserve the copy-only attribution on relay polls, or describe the change explicitly. The new boolean equivalence test does not check `BLAMED`. AI-assisted static review. No game files or GPU use.
lixonik commented 2026-12-02 10:02:27 +00:00

Live in-game 4-leg ABBA verification on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (driver 621.40, 16C/32T desktop CPU), PR head aef892880 merged onto main a917c54d6 (diag build, diagnostics,dlss,mimalloc, Series S, -NoFrameGen -NoPrecompile, same save snapshot restored before every leg, 85 s in-world per leg):

  • Unit tests & clean-room:
    • cargo test -p leonida-gpu --locked --lib card_steps -- 15 passed, 0 failed, 3 ignored.
    • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs -- exit 0.
  • Stability: 0 ERROR lines across all 4 legs; card_steps active throughout (513-562 card-step log lines per leg).
  • 4-leg ABBA results (A = main a917c54d6, B = #3069 aef892880):
Leg Build All-world median (n=19) Steady 4,200-5,000 draws median (n=6-8) Steady prep / copies (ms) Steady draws Errors
1 A (main) 23.40 fps (42.80 ms) 25.35 fps (39.50 ms) 30.95 / 12.30 4,622 0
2 B (#3069) 23.20 fps (43.10 ms) 26.10 fps (38.30 ms) 30.10 / 12.40 4,604 0
3 B (#3069) 22.40 fps (44.70 ms) 23.90 fps (41.90 ms) 32.80 / 13.80 4,663 0
4 A (main) 20.60 fps (48.50 ms) 22.30 fps (44.95 ms) 32.45 / 14.60 4,616 0
ABBA avg B vs A 22.80 vs 22.00 fps (-1.75 ms) 25.00 vs 23.82 fps (-2.13 ms) 31.45 vs 31.70 / 13.10 vs 13.45 4,634 vs 4,619 0

Both ABBA half-pairs (Leg 2 vs Leg 1 and Leg 3 vs Leg 4) favor #3069 in the steady-world slice (+0.75 fps / -1.20 ms and +1.60 fps / -3.05 ms, compensating for run-order drift across legs 1->4).

Result: PASS on live gameplay stability and performance (no regression; small positive steady-world margin). @ecox982745's diagnostics BLAMED attribution note on host.rs remains a separate diagnostics-only point.

AI-assisted: yes (Antigravity).

Live in-game 4-leg ABBA verification on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (driver `621.40`, 16C/32T desktop CPU), PR head `aef892880` merged onto `main` `a917c54d6` (`diag` build, `diagnostics,dlss,mimalloc`, Series S, `-NoFrameGen -NoPrecompile`, same save snapshot restored before every leg, 85 s in-world per leg): - **Unit tests & clean-room:** - `cargo test -p leonida-gpu --locked --lib card_steps` -- **15 passed, 0 failed, 3 ignored**. - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs` -- exit `0`. - **Stability:** **0 `ERROR` lines** across all 4 legs; `card_steps` active throughout (`513-562` card-step log lines per leg). - **4-leg ABBA results (`A = main a917c54d6`, `B = #3069 aef892880`):** | Leg | Build | All-world median (n=19) | Steady 4,200-5,000 draws median (n=6-8) | Steady prep / copies (ms) | Steady draws | Errors | |---|---|---|---|---|---|---| | 1 | A (`main`) | 23.40 fps (42.80 ms) | 25.35 fps (39.50 ms) | 30.95 / 12.30 | 4,622 | 0 | | 2 | B (`#3069`) | 23.20 fps (43.10 ms) | 26.10 fps (38.30 ms) | 30.10 / 12.40 | 4,604 | 0 | | 3 | B (`#3069`) | 22.40 fps (44.70 ms) | 23.90 fps (41.90 ms) | 32.80 / 13.80 | 4,663 | 0 | | 4 | A (`main`) | 20.60 fps (48.50 ms) | 22.30 fps (44.95 ms) | 32.45 / 14.60 | 4,616 | 0 | | **ABBA avg** | **B vs A** | **22.80 vs 22.00 fps (-1.75 ms)** | **25.00 vs 23.82 fps (-2.13 ms)** | **31.45 vs 31.70 / 13.10 vs 13.45** | **4,634 vs 4,619** | **0** | Both ABBA half-pairs (`Leg 2 vs Leg 1` and `Leg 3 vs Leg 4`) favor `#3069` in the steady-world slice (`+0.75 fps` / `-1.20 ms` and `+1.60 fps` / `-3.05 ms`, compensating for run-order drift across legs 1->4). Result: **PASS** on live gameplay stability and performance (no regression; small positive steady-world margin). `@ecox982745`'s diagnostics `BLAMED` attribution note on `host.rs` remains a separate diagnostics-only point. AI-assisted: yes (Antigravity).
piyonchu commented 2026-12-02 11:44:46 +00:00

Thanks @ecox982745 for catching the diagnostics attribution difference, and @Kal0s-design / @lixonik for the WARP, debug-layer, and live 4-leg ABBA testing.

Updated in 311d33a40:

  • Added blame_copied: bool to blocked_by_into (host.rs) so both relay_wait (count=false, blame_copied=true) and late_blocked (count=true, blame_copied=true) preserve legacy copied_read BLAMED attribution under --features diagnostics whenever no shader-write blocker takes precedence, while keeping release builds zero-cost (cfg!(feature = "diagnostics")).
  • Extended single_pass_blocked_by_into_matches_legacy_precedence (card_steps.rs) to assert exact BLAMED parity against legacy blocked_by + copied_read under --features diagnostics.
  • Re-verified after the final edit:
    • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs — exit 0
    • cargo check --lib -p leonida-gpu --locked & cargo clippy -p leonida-gpu --features diagnostics --lib --tests --locked — passed (0 warnings in touched files)
    • cargo test --locked -j 4 -p leonida-gpu --features diagnostics --lib -- card_steps --test-threads=1 — 15 passed; 0 failed; 3 ignored
    • cargo test --locked -j 4 -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws --test-threads=1 — 693 passed; 0 failed; 61 ignored; 1 filtered out
    • cargo test -p leonida-gpu --features diagnostics --test replay --locked — 1 passed; 0 failed
    • Independent read-only reviewer re-audit verified the final diff cleanly.
Thanks @ecox982745 for catching the diagnostics attribution difference, and @Kal0s-design / @lixonik for the WARP, debug-layer, and live 4-leg ABBA testing. Updated in `311d33a40`: - Added `blame_copied: bool` to `blocked_by_into` (`host.rs`) so both `relay_wait` (`count=false, blame_copied=true`) and `late_blocked` (`count=true, blame_copied=true`) preserve legacy `copied_read` `BLAMED` attribution under `--features diagnostics` whenever no shader-write blocker takes precedence, while keeping release builds zero-cost (`cfg!(feature = "diagnostics")`). - Extended `single_pass_blocked_by_into_matches_legacy_precedence` (`card_steps.rs`) to assert exact `BLAMED` parity against legacy `blocked_by` + `copied_read` under `--features diagnostics`. - Re-verified after the final edit: - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/card_steps.rs` — exit `0` - `cargo check --lib -p leonida-gpu --locked` & `cargo clippy -p leonida-gpu --features diagnostics --lib --tests --locked` — passed (`0` warnings in touched files) - `cargo test --locked -j 4 -p leonida-gpu --features diagnostics --lib -- card_steps --test-threads=1` — `15 passed; 0 failed; 3 ignored` - `cargo test --locked -j 4 -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws --test-threads=1` — `693 passed; 0 failed; 61 ignored; 1 filtered out` - `cargo test -p leonida-gpu --features diagnostics --test replay --locked` — `1 passed; 0 failed` - Independent read-only reviewer re-audit verified the final diff cleanly.
MoonEyes commented 2026-12-02 18:02:22 +00:00

Code review of the new commit only, not built (Windows-only leonida-gpu). Ready, with one note on the in-game evidence.

  • Head: 311d33a40, merge base a917c54d6, 184 behind current main 45dc41f95. A trial merge is clean. CI on the head: all 6 checks pass.
  • The earlier runs covered aef892880:
    • Kal0s-design: WARP and debug layer.
    • lixonik: 4-leg ABBA in game on an RTX 5070, 0 errors, B (this PR) slightly faster than A (main).
  • 311d33a40 came after both. The author reports card_steps 15/15 under --features diagnostics, the whole lib 693 passed, and the replay test.

Review of aef892880..311d33a40 (host.rs, host/card_steps.rs):

  • The new blame_copied flag restores the copied_read BLAMED attribution that ecox982745 found missing for relay_wait and late_blocked.
  • record_copied_blame = cfg!(feature = "diagnostics") && blame_copied keeps the early return !need_copied_if_blocked && !count && !record_copied_blame identical to before in release builds. Release behaviour of this commit is therefore unchanged, and the in-game ABBA on aef892880 still describes what ships.
  • emit_copied_blame runs only when blocked.is_none(), which matches the legacy precedence where a shader-write blocker wins.
  • The extended single_pass_blocked_by_into_matches_legacy_precedence compares (blk, copied, BLAMED) against the legacy pair under diagnostics. That is the right oracle.
  • Minor: the test resets and reads the global BLAMED mutex. Under a parallel cargo test --features diagnostics --lib, any other test that calls blame can interleave and flake it. The author ran with --test-threads=1. It would be worth one parallel run, or reading the attribution through a returned value instead of the global.

Verdict: ready. The render-path in-game gate was met on aef892880, and the follow-up is diagnostics-only.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

**Code review of the new commit only, not built (Windows-only `leonida-gpu`). Ready, with one note on the in-game evidence.** - Head: `311d33a40`, merge base `a917c54d6`, 184 behind current `main` `45dc41f95`. A trial merge is clean. CI on the head: all 6 checks pass. - The earlier runs covered `aef892880`: - Kal0s-design: WARP and debug layer. - lixonik: 4-leg ABBA in game on an RTX 5070, 0 errors, B (this PR) slightly faster than A (`main`). - `311d33a40` came after both. The author reports `card_steps` 15/15 under `--features diagnostics`, the whole lib 693 passed, and the replay test. **Review of `aef892880..311d33a40` (`host.rs`, `host/card_steps.rs`):** - The new `blame_copied` flag restores the `copied_read` BLAMED attribution that ecox982745 found missing for `relay_wait` and `late_blocked`. - `record_copied_blame = cfg!(feature = "diagnostics") && blame_copied` keeps the early return `!need_copied_if_blocked && !count && !record_copied_blame` identical to before in release builds. Release behaviour of this commit is therefore unchanged, and the in-game ABBA on `aef892880` still describes what ships. - `emit_copied_blame` runs only when `blocked.is_none()`, which matches the legacy precedence where a shader-write blocker wins. - The extended `single_pass_blocked_by_into_matches_legacy_precedence` compares `(blk, copied, BLAMED)` against the legacy pair under diagnostics. That is the right oracle. - Minor: the test resets and reads the global `BLAMED` mutex. Under a parallel `cargo test --features diagnostics --lib`, any other test that calls `blame` can interleave and flake it. The author ran with `--test-threads=1`. It would be worth one parallel run, or reading the attribution through a returned value instead of the global. Verdict: **ready**. The render-path in-game gate was met on `aef892880`, and the follow-up is diagnostics-only. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
icdmkg2 commented 2026-12-02 20:22:14 +00:00

Third-party Windows verification of #3069 (D3D12-CARD-STEPS-PLAN-SCRATCH) on head 311d33a40

Follow-up Windows build/test verification for the post-review commit 311d33a40 (blame_copied / BLAMED attribution parity under --features diagnostics).

  • Head / base: 311d33a4038a95af56c34925e32bace4f9d5849d merged cleanly (git merge --no-ff) onto origin/main b41763227.
  • Machine: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver 621.24 (32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 10.0.26300.9974, rustc 1.98.1.
  • Scope: synthetic / D3D12 hardware + WARP + debug-layer + diagnostics + replay + microbenchmarks (no retail title run).

Results (MEASURED)

Check Result
python -I scripts/check_no_game_data.py (host.rs, host/card_steps.rs) exit 0
python -I scripts/red_green.py 3069 --mutate (LEONIDA_ADAPTER=5060) green: 767 passed, 0 failed in leonida-gpu; red: red does not build (cannot find function copied_read in module card_steps, expected for refactored internal helpers)
LEONIDA_ADAPTER=5060 cargo test -p leonida-gpu --features diagnostics --locked --lib -- card_steps --test-threads=1 15 passed, 0 failed, 3 ignored (includes single_pass_blocked_by_into_matches_legacy_precedence with BLAMED parity)
LEONIDA_D3D12_WARP=1 + LEONIDA_D3D12_DEBUG=1 (same card_steps command, --features diagnostics) 15 passed, 0 failed, 3 ignored
LEONIDA_ADAPTER=5060 cargo test -p leonida-gpu --features diagnostics --test replay --locked 1 passed, 0 failed
bench_card_steps (--ignored, unoptimized debug build, Ryzen 7 H 260) plan: 3963.5 -> 1092.7 us/iter (3.63x); elsewhere (4 queries): 357.4 -> 291.9 us/iter (1.22x); elsewhere (120 queries): 10849.4 -> 10926.8 us/iter (0.99x in debug)

AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).

**Third-party Windows verification of #3069 (`D3D12-CARD-STEPS-PLAN-SCRATCH`) on head `311d33a40`** Follow-up Windows build/test verification for the post-review commit `311d33a40` (`blame_copied` / `BLAMED` attribution parity under `--features diagnostics`). - **Head / base:** `311d33a4038a95af56c34925e32bace4f9d5849d` merged cleanly (`git merge --no-ff`) onto `origin/main` `b41763227`. - **Machine:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver `621.24` (`32.0.16.2124`), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 `10.0.26300.9974`, `rustc 1.98.1`. - **Scope:** synthetic / D3D12 hardware + WARP + debug-layer + diagnostics + replay + microbenchmarks (no retail title run). ### Results (MEASURED) | Check | Result | |---|---| | `python -I scripts/check_no_game_data.py` (`host.rs`, `host/card_steps.rs`) | exit `0` | | `python -I scripts/red_green.py 3069 --mutate` (`LEONIDA_ADAPTER=5060`) | green: `767` passed, `0` failed in `leonida-gpu`; red: `red does not build` (`cannot find function copied_read in module card_steps`, expected for refactored internal helpers) | | `LEONIDA_ADAPTER=5060` `cargo test -p leonida-gpu --features diagnostics --locked --lib -- card_steps --test-threads=1` | `15 passed, 0 failed, 3 ignored` (includes `single_pass_blocked_by_into_matches_legacy_precedence` with `BLAMED` parity) | | `LEONIDA_D3D12_WARP=1` + `LEONIDA_D3D12_DEBUG=1` (same `card_steps` command, `--features diagnostics`) | `15 passed, 0 failed, 3 ignored` | | `LEONIDA_ADAPTER=5060` `cargo test -p leonida-gpu --features diagnostics --test replay --locked` | `1 passed, 0 failed` | | `bench_card_steps` (`--ignored`, unoptimized debug build, Ryzen 7 H 260) | `plan`: `3963.5 -> 1092.7 us/iter` (`3.63x`); `elsewhere` (4 queries): `357.4 -> 291.9 us/iter` (`1.22x`); `elsewhere` (120 queries): `10849.4 -> 10926.8 us/iter` (`0.99x` in debug) | AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
EdenBendheim commented 2026-12-02 21:02:29 +00:00

RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head 311d33a4038a95af56c34925e32bace4f9d5849d.

  • Base & build: Merged cleanly via git merge --no-ff onto main b41763227 (diagnostics,dlss,mimalloc, exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit 0; standalone Windows red/green unit tests also passed 694 default / 775 diagnostics in leonida-gpu --lib, with compile-time red on RefreshSpan).
  • Batch heads (14 PRs): #3200 d1a91afd1, #3198 80a627bb1, #3191 93b47ac9d, #3189 c182fc392, #3176 ae0075d9a, #3168 337388052, #3164 1065952da, #3146 ebc0253ff, #3124 64600ef0c, #3069 311d33a40, #3031 8df1bfce7, #3029 e49404808, #3054 ff53fd8b9, #3010 d645712a3.
  • Hardware & setup: Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Series X profile, 2560x1440, -NoFrameGen, LEONIDA_RELAY=2, LEONIDA_CARD_STEPS=2 (card-step planning active), scripts/game-gate.ps1 (301.3 s in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (GATE CONTROL moved=2.51 m, max_from_ctrl=5,053.9 m).
Metric 14-PR Batch (c47eeb717f761d9d) main b41763227 baseline (cf499737bf684f6a)
Gate verdict / exit PASS (clean, 0 reasons, 0 warnings) PASS (clean, 0 reasons, 0 warnings)
World time 301.3 s (4,504 frames) 305.6 s
Device lost / crashes / missed pipeline waits 0 / 0 / 0 0 / 0 / 0
Rendered FPS (median) / p95 frame time 20.10 FPS / 69.76 ms 19.13 FPS / 74.01 ms
Median draws/frame / longest present gap 8,048 / 5.222 s 7,983 / 2.358 s

Verdict: PASS for the 300 s in-game stability gate on 311d33a40 (with LEONIDA_RELAY=2 & LEONIDA_CARD_STEPS=2 active). (Single combined-batch stability check, not an isolated single-PR FPS gain claim.)

(AI-assisted verification: gemini-4-neon + gpt-6.2-astra.)

**RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch)** — **PASS** covering exact head `311d33a4038a95af56c34925e32bace4f9d5849d`. - **Base & build:** Merged cleanly via `git merge --no-ff` onto `main` `b41763227` (`diagnostics,dlss,mimalloc`, `exe_sha16 = c47eeb717f761d9d`; changed-file clean-room scan exit `0`; standalone Windows red/green unit tests also passed `694` default / `775` diagnostics in `leonida-gpu --lib`, with compile-time red on `RefreshSpan`). - **Batch heads (`14` PRs):** `#3200` `d1a91afd1`, `#3198` `80a627bb1`, `#3191` `93b47ac9d`, `#3189` `c182fc392`, `#3176` `ae0075d9a`, `#3168` `337388052`, `#3164` `1065952da`, `#3146` `ebc0253ff`, `#3124` `64600ef0c`, `#3069` `311d33a40`, `#3031` `8df1bfce7`, `#3029` `e49404808`, `#3054` `ff53fd8b9`, `#3010` `d645712a3`. - **Hardware & setup:** Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver `610.88`, Series X profile, `2560x1440`, `-NoFrameGen`, `LEONIDA_RELAY=2`, `LEONIDA_CARD_STEPS=2` (card-step planning active), `scripts/game-gate.ps1` (`301.3 s` in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (`GATE CONTROL moved=2.51 m`, `max_from_ctrl=5,053.9 m`). | Metric | 14-PR Batch (`c47eeb717f761d9d`) | `main` `b41763227` baseline (`cf499737bf684f6a`) | |---|---:|---:| | Gate verdict / exit | **PASS** (`clean`, `0` reasons, `0` warnings) | **PASS** (`clean`, `0` reasons, `0` warnings) | | World time | `301.3 s` (`4,504` frames) | `305.6 s` | | Device lost / crashes / missed pipeline waits | `0` / `0` / `0` | `0` / `0` / `0` | | Rendered FPS (median) / p95 frame time | `20.10 FPS` / `69.76 ms` | `19.13 FPS` / `74.01 ms` | | Median draws/frame / longest present gap | `8,048` / `5.222 s` | `7,983` / `2.358 s` | **Verdict:** **PASS** for the 300 s in-game stability gate on `311d33a40` (with `LEONIDA_RELAY=2` & `LEONIDA_CARD_STEPS=2` active). *(Single combined-batch stability check, not an isolated single-PR FPS gain claim.)* *(AI-assisted verification: `gemini-4-neon` + `gpt-6.2-astra`.)*
fiestorra commented 2026-12-02 22:39:38 +00:00

VERIFY-3069 — Windows nativo: 15 pruebas del planificador de pasos pasan y el control muerde la compartición

Head (this PR)
Merge base a917c54d6 (behind main b41763227)
Merged onto main — merge-tree clean, git merge --no-ff clean (auto-merged host.rs)

Ran

cargo test -p leonida-gpu --lib card_steps     15 passed; 0 failed; 3 ignored
  host::card_steps::tests::a_fill_shown_by_several_slots_points_every_one_at_its_bytes ... ok
  host::card_steps::tests::a_single_slot_expands_in_order_only_when_its_fill_is_shared ... ok
  host::card_steps::tests::a_refresh_of_another_host_copy_is_seen ... ok

Negative control (synthetic): a fill with several slots should point every one at its bytes; I made it take only the first (take(1)), rebuilt and ran:

FAILED: a_fill_shown_by_several_slots_points_every_one_at_its_bytes
FAILED: a_single_slot_expands_in_order_only_when_its_fill_is_shared
assertion failed: matches!(tos.as_slice(), [To::Slot(3, 14), To::Slot(3, 20), To::Slot(7, 2)])

Two bite.

What the change is: the step planner's Refresh becomes linear — a fill that several slots show is remembered and every one of them is pointed at its bytes once, instead of each slot re-scanning; a single slot expands in order only when its fill is shared. The comment keeps the measurement that motivates it (3,100–11,600 fills a frame, nearly all out of one host copy of the title's 174 MB heap, each a CopyBufferRegion the card runs serially).

Three ignored tests, named so nobody wonders: two benchmarks (bench_card_steps_elsewhere_before_vs_after, bench_card_steps_plan_before_vs_after) and one that wants LEONIDA_RELAXED… set.

What I could not test

  • The timings the PR is about: the benchmarks are ignored and need a run; the "no longer quadratic" claim is from the body, not from me.
  • The title's own fill pattern: the tests synthesise FillTo::Slots; the 3,100–11,600 a frame are quoted.
  • The 1,467-line diff of card_steps.rs: read around the tests and the changed function, not line by line.

Written with an AI assistant.

## VERIFY-3069 — Windows nativo: 15 pruebas del planificador de pasos pasan y el control muerde la compartición | | | |---|---| | Head | `(this PR)` | | Merge base | `a917c54d6` (behind `main` `b41763227`) | | Merged onto | `main` — `merge-tree` clean, `git merge --no-ff` clean (auto-merged `host.rs`) | **Ran** ``` cargo test -p leonida-gpu --lib card_steps 15 passed; 0 failed; 3 ignored host::card_steps::tests::a_fill_shown_by_several_slots_points_every_one_at_its_bytes ... ok host::card_steps::tests::a_single_slot_expands_in_order_only_when_its_fill_is_shared ... ok host::card_steps::tests::a_refresh_of_another_host_copy_is_seen ... ok ``` **Negative control (synthetic)**: a fill with several slots should point every one at its bytes; I made it take only the first (`take(1)`), rebuilt and ran: ``` FAILED: a_fill_shown_by_several_slots_points_every_one_at_its_bytes FAILED: a_single_slot_expands_in_order_only_when_its_fill_is_shared assertion failed: matches!(tos.as_slice(), [To::Slot(3, 14), To::Slot(3, 20), To::Slot(7, 2)]) ``` **Two bite.** **What the change is**: the step planner's `Refresh` becomes linear — a fill that several slots show is remembered and **every one of them is pointed at its bytes** once, instead of each slot re-scanning; a single slot expands in order **only when its fill is shared**. The comment keeps the measurement that motivates it (3,100–11,600 fills a frame, nearly all out of one host copy of the title's 174 MB heap, each a `CopyBufferRegion` the card runs serially). **Three ignored tests, named so nobody wonders**: two benchmarks (`bench_card_steps_elsewhere_before_vs_after`, `bench_card_steps_plan_before_vs_after`) and one that wants `LEONIDA_RELAXED…` set. ## What I could not test - **The timings the PR is about**: the benchmarks are ignored and need a run; the "no longer quadratic" claim is from the body, not from me. - **The title's own fill pattern**: the tests synthesise `FillTo::Slots`; the 3,100–11,600 a frame are quoted. - **The 1,467-line diff of `card_steps.rs`**: read around the tests and the changed function, not line by line. Written with an AI assistant.
x2Tweek commented 2026-12-03 12:01:31 +00:00

RUN (in game, RTX 5090 32 GB, hardware RT on): PASS, 0 device losses. No frame-rate or submitting-thread change I can measure in this scenario.

  • Head: 311d33a40, merged --no-ff onto main ba9e65cec. Base: main ba9e65cec alone, built the same way.
  • GPU / driver / OS: NVIDIA GeForce RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Diag build (build-nvidia.ps1).
  • Recipe: -HardwareRT -SmoothMotion -PrecompileAll -Dlss quality, Series X profile, 4K output, the same save each run. A key driver presses Enter only while the log shows the menu. In the world the character walks and the camera turns all the time (look keys, 20 s each way). 330 s in the world per run. Order: PR, main, PR, main. LEONIDA_D3D12_DRED=1.
  • Prediction: less time in "the lists' steps" on the submitting thread, about the same fps.
run fps median ms/frame median preparing ms median lists' steps, mean of 5 s lines frames > 250 ms device lost
PR, run 1 13.4 74.9 31.8 15.4 ms 4 0
main, run 1 13.9 72.3 29.9 14.8 ms 3 0
PR, run 2 13.5 74.3 30.9 15.1 ms 1 0
main, run 2 13.2 75.6 32.3 15.3 ms 1 0
  • Verdict (MEASURED, n=2 per arm): the prediction was not met. The lists' steps stay at 15.1-15.4 ms with the PR against 14.8-15.3 ms on main, within the run-to-run spread. fps and preparing time are within noise too.
  • Hitches: the first PR run had two long frames (1.8 s and 2.1 s), the first run after a fresh build; the second PR run had one at 355 ms. With two runs I cannot tell this apart from a cold cache.
  • Stable: 0 device losses, no DRED report, memory at the end in the same range (47-49 GB private, 22-24 GB VRAM).
  • Limit: on this machine the steps are ~6,100 refresh candidates a frame. Your quadratic cases may need more entries per submission than this scenario makes, so this says nothing against the PR's complexity argument, only that it does not show up here.

AI-assisted: runs, key driver and log reading done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.

**RUN (in game, RTX 5090 32 GB, hardware RT on): PASS, 0 device losses. No frame-rate or submitting-thread change I can measure in this scenario.** - **Head:** `311d33a40`, merged `--no-ff` onto main `ba9e65cec`. **Base:** main `ba9e65cec` alone, built the same way. - **GPU / driver / OS:** NVIDIA GeForce RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Diag build (`build-nvidia.ps1`). - **Recipe:** `-HardwareRT -SmoothMotion -PrecompileAll -Dlss quality`, Series X profile, 4K output, the same save each run. A key driver presses Enter only while the log shows the menu. In the world the character walks and the camera turns all the time (look keys, 20 s each way). 330 s in the world per run. Order: PR, main, PR, main. `LEONIDA_D3D12_DRED=1`. - **Prediction:** less time in "the lists' steps" on the submitting thread, about the same fps. | run | fps median | ms/frame median | preparing ms median | lists' steps, mean of 5 s lines | frames > 250 ms | device lost | |---|---|---|---|---|---|---| | PR, run 1 | 13.4 | 74.9 | 31.8 | 15.4 ms | 4 | 0 | | main, run 1 | 13.9 | 72.3 | 29.9 | 14.8 ms | 3 | 0 | | PR, run 2 | 13.5 | 74.3 | 30.9 | 15.1 ms | 1 | 0 | | main, run 2 | 13.2 | 75.6 | 32.3 | 15.3 ms | 1 | 0 | - **Verdict (MEASURED, n=2 per arm):** the prediction was not met. The lists' steps stay at 15.1-15.4 ms with the PR against 14.8-15.3 ms on main, within the run-to-run spread. fps and preparing time are within noise too. - **Hitches:** the first PR run had two long frames (1.8 s and 2.1 s), the first run after a fresh build; the second PR run had one at 355 ms. With two runs I cannot tell this apart from a cold cache. - **Stable:** 0 device losses, no DRED report, memory at the end in the same range (47-49 GB private, 22-24 GB VRAM). - **Limit:** on this machine the steps are ~6,100 refresh candidates a frame. Your quadratic cases may need more entries per submission than this scenario makes, so this says nothing against the PR's complexity argument, only that it does not show up here. AI-assisted: runs, key driver and log reading done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines.
Sign in to join this conversation.
No description provided.