D3D12-BATCH-HEAP-READS: a program that only reads through views of the heap keeps the indirect batch open (LEONIDA_BATCH_HEAP_READS) #2868

Closed
enlight3d wants to merge 5 commits from upstream-pr/2868 into main
enlight3d commented 2026-12-01 11:51:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T11:51:31Z.


Claimed in the coordination issue as: D3D12-BATCH-HEAP-READS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7305543096)

Depends on: none. Conflicts: #2834 in d3d12/docs/switches.md (regenerate the page). #2569 merges without a textual conflict, but its one LEONIDA_UNDECLARED_TRACE call needs stores_declared(p, builder).all and undeclared_why(p, builder, heap_reads) (see below).

What and why

With LEONIDA_INDIRECT_BATCH=4 (what d3d12/scripts/play-nvidia.ps1 sets), an open batch of clamped indirect records stays open past a dispatch or draw whose stores all go through views its bind declares (stores_declared). A stage with the root SRV SLOT_STRIDES ended the batch before stores_bound was asked. The translator gives that root SRV for every buffer access through a descriptor loaded from a ResourceHeap root parameter, reads included (leonida-shader emit/lower.rs, slot_word), so programs that only read through views of the heap ended the batch as if they stored through them. stores_bound (stores_in_bound_views) already says no of a store through a view loaded from the heap, or through a table at an offset the program computes, so it can decide for those stages too.

  • LEONIDA_BATCH_HEAP_READS (on unless 0, crate::toggled!, switched by LEONIDA_AB): a stage that loads views from the heap is declared when stores_bound says all its stores go through views its bind declares. 0 gives the old behaviour. No store through a view loaded from the heap is let through, as before. Batches whose records really are written still end, for "a record declared written since the pass".
  • stores_told reads the switch once per decision: stores_declared answers with the setting it used (Declared), and the diagnostic takes that same setting.
  • LEONIDA_BATCH_WHY (diagnostics only) gets a second line with the total for every reason a batch ended for undeclared stores, not only the first eight programs. It tells "reads only from the heap (stores bound yes / no / not yet)" from "stores through a view picked from the heap", and counts the ends for a full table and for another source apart. The first line reads as before.

Measurements

RTX 3090 24 GB, NVIDIA 621.40, Windows 11, launcher defaults (mode 4), Series S settings, standing in the world.

  • Before, on main 640b0d0df (GPU timing run): about 603 clamp passes a frame, 2.34 ms of the card's time, the costliest entry of the run.
  • A/B in one run, LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS, 900 s, 33 pairs of phases (on this branch before the default changed): frame median -2.2 +- 0.17 ms with the switch on, the card busy 1.9 ms less a frame, the lists' steps on the submitting thread 0.5 ms longer.
  • LEONIDA_BATCH_WHY=1, 300 s with the switch off and 300 s on: 601 batches opened a frame against 122; ends for stores not all declared 507 against 9 (the 498 of "reads only from the heap (stores bound yes)" with it off); ends for a record declared written since the pass 20 against 34.
  • GPU timing run with the switch on: the clamp passes 0.82 ms a frame in 122 commands.
  • Pictures: four captures in each of two 300 s runs (switch 0 and 1): nothing missing or different apart from a character's idle pose.

Limits: at these settings the 3090 is held by the card, so the gain may differ on a card-light or CPU-bound machine; the picture check is four captures per run on two runs, not a frame-by-frame scan; the switch adds about 0.5 ms a frame to the lists' steps on the CPU; the timing run with the switch on had no run with it off in the same session (it is compared with an earlier timing run on another commit).

Tested

On this branch at main bf30e2585 (main 1b8371637 since then changes nothing under d3d12/, and the branch merges onto it cleanly), against main at the same commit:

  • cargo test -p leonida-gpu: default 641 passed, 58 ignored (main 627, 58). --features diagnostics: 720 passed, 58 ignored, replay 1 passed (main 706, 58, replay 1). In both diagnostics runs timeline::record::tests::global_stall_routing_retains_spans_waits_wakes_and_sent_fences_without_stacks failed once, on main as here, and it passes run alone on both. The 14 new tests make the difference.
  • cargo test --workspace --exclude xtask --no-fail-fast (the CI step): 1,619 passed, 2 failed. leonida-loader load_probe fails the same way on main in this environment (its probe DLL is not found with a target folder of its own). watch::tests::a_write_opens_the_view_it_goes_through passes run alone and in the leonida-gpu runs above.
  • Seen on main as well: texture::allocation_costs::no_two_changes_cancel_in_the_aes_digest now and then stops the diagnostics test process with a ptr::copy alignment check (1 run in 12 of that module on main, 2 in 12 here). No code it runs is touched here.
  • Written before the code and failing by assertion: the reasons' classification (left: Other, right: Builder), the totals line (1 item instead of 11), the full-table counter (table.full_for(7)), the switch in the stage test and in the reasons (left: HeapReadsBound, right: Other), the switch reaching the decision (Declared { all: false, heap_reads: false } instead of { all: true, heap_reads: true }), the default (batch_heap_reads() false).
  • Guard tests of stores_in_bound_views (pass on main, as they should): reads from the heap with a store through a table entry or through a root view of unordered access are declared; a store through the view loaded from the heap, through a descriptor made in the code, through the table at a computed offset, or through a descriptor chosen by s_cselect between the table's entry and the heap's is not.
  • Mutations on the final commit, each rebuilt and each failing at least one test (15 of 15): the switch ignored in the stage test; the switch read as always off, and as always on, in stages_declared; the SLOT_STRIDES short-cut put back; stores_bound's answer taken as yes; stores_in_bound_views always yes; heap and table roots swapped; the computed-offset test dropped; other descriptor sources taken as declared; one declared leaf of a choice taken as enough; root views refused; a reason misclassified; the full-table counter off by one and blind to the source; the default back to off.
  • cargo clippy -p leonida-gpu --all-targets, default and --features diagnostics: the same warnings as main, none new.
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md passes (the page is the tool's output); python -I scripts/check_no_game_data.py on every file touched and on this text.

GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 621.40, Windows 11 Pro (unit tests and the in-game A/B).

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5585103576 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-01T11:51:31Z. --- Claimed in the coordination issue as: D3D12-BATCH-HEAP-READS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7305543096) Depends on: none. Conflicts: #2834 in `d3d12/docs/switches.md` (regenerate the page). #2569 merges without a textual conflict, but its one `LEONIDA_UNDECLARED_TRACE` call needs `stores_declared(p, builder).all` and `undeclared_why(p, builder, heap_reads)` (see below). ### What and why With `LEONIDA_INDIRECT_BATCH=4` (what `d3d12/scripts/play-nvidia.ps1` sets), an open batch of clamped indirect records stays open past a dispatch or draw whose stores all go through views its bind declares (`stores_declared`). A stage with the root SRV `SLOT_STRIDES` ended the batch before `stores_bound` was asked. The translator gives that root SRV for every buffer access through a descriptor loaded from a `ResourceHeap` root parameter, reads included (`leonida-shader` `emit/lower.rs`, `slot_word`), so programs that only read through views of the heap ended the batch as if they stored through them. `stores_bound` (`stores_in_bound_views`) already says no of a store through a view loaded from the heap, or through a table at an offset the program computes, so it can decide for those stages too. - `LEONIDA_BATCH_HEAP_READS` (on unless `0`, `crate::toggled!`, switched by `LEONIDA_AB`): a stage that loads views from the heap is declared when `stores_bound` says all its stores go through views its bind declares. `0` gives the old behaviour. No store through a view loaded from the heap is let through, as before. Batches whose records really are written still end, for "a record declared written since the pass". - `stores_told` reads the switch once per decision: `stores_declared` answers with the setting it used (`Declared`), and the diagnostic takes that same setting. - `LEONIDA_BATCH_WHY` (diagnostics only) gets a second line with the total for every reason a batch ended for undeclared stores, not only the first eight programs. It tells "reads only from the heap (stores bound yes / no / not yet)" from "stores through a view picked from the heap", and counts the ends for a full table and for another source apart. The first line reads as before. ### Measurements RTX 3090 24 GB, NVIDIA 621.40, Windows 11, launcher defaults (mode 4), Series S settings, standing in the world. - Before, on main 640b0d0df (GPU timing run): about 603 clamp passes a frame, 2.34 ms of the card's time, the costliest entry of the run. - A/B in one run, `LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS`, 900 s, 33 pairs of phases (on this branch before the default changed): frame median -2.2 +- 0.17 ms with the switch on, the card busy 1.9 ms less a frame, the lists' steps on the submitting thread 0.5 ms longer. - `LEONIDA_BATCH_WHY=1`, 300 s with the switch off and 300 s on: 601 batches opened a frame against 122; ends for stores not all declared 507 against 9 (the 498 of "reads only from the heap (stores bound yes)" with it off); ends for a record declared written since the pass 20 against 34. - GPU timing run with the switch on: the clamp passes 0.82 ms a frame in 122 commands. - Pictures: four captures in each of two 300 s runs (switch `0` and `1`): nothing missing or different apart from a character's idle pose. Limits: at these settings the 3090 is held by the card, so the gain may differ on a card-light or CPU-bound machine; the picture check is four captures per run on two runs, not a frame-by-frame scan; the switch adds about 0.5 ms a frame to the lists' steps on the CPU; the timing run with the switch on had no run with it off in the same session (it is compared with an earlier timing run on another commit). ### Tested On this branch at `main` bf30e2585 (`main` 1b8371637 since then changes nothing under `d3d12/`, and the branch merges onto it cleanly), against `main` at the same commit: - `cargo test -p leonida-gpu`: default 641 passed, 58 ignored (main 627, 58). `--features diagnostics`: 720 passed, 58 ignored, replay 1 passed (main 706, 58, replay 1). In both diagnostics runs `timeline::record::tests::global_stall_routing_retains_spans_waits_wakes_and_sent_fences_without_stacks` failed once, on main as here, and it passes run alone on both. The 14 new tests make the difference. - `cargo test --workspace --exclude xtask --no-fail-fast` (the CI step): 1,619 passed, 2 failed. `leonida-loader` `load_probe` fails the same way on main in this environment (its probe DLL is not found with a target folder of its own). `watch::tests::a_write_opens_the_view_it_goes_through` passes run alone and in the `leonida-gpu` runs above. - Seen on main as well: `texture::allocation_costs::no_two_changes_cancel_in_the_aes_digest` now and then stops the diagnostics test process with a `ptr::copy` alignment check (1 run in 12 of that module on main, 2 in 12 here). No code it runs is touched here. - Written before the code and failing by assertion: the reasons' classification (`left: Other, right: Builder`), the totals line (1 item instead of 11), the full-table counter (`table.full_for(7)`), the switch in the stage test and in the reasons (`left: HeapReadsBound, right: Other`), the switch reaching the decision (`Declared { all: false, heap_reads: false }` instead of `{ all: true, heap_reads: true }`), the default (`batch_heap_reads()` false). - Guard tests of `stores_in_bound_views` (pass on main, as they should): reads from the heap with a store through a table entry or through a root view of unordered access are declared; a store through the view loaded from the heap, through a descriptor made in the code, through the table at a computed offset, or through a descriptor chosen by `s_cselect` between the table's entry and the heap's is not. - Mutations on the final commit, each rebuilt and each failing at least one test (15 of 15): the switch ignored in the stage test; the switch read as always off, and as always on, in `stages_declared`; the `SLOT_STRIDES` short-cut put back; `stores_bound`'s answer taken as yes; `stores_in_bound_views` always yes; heap and table roots swapped; the computed-offset test dropped; other descriptor sources taken as declared; one declared leaf of a choice taken as enough; root views refused; a reason misclassified; the full-table counter off by one and blind to the source; the default back to off. - `cargo clippy -p leonida-gpu --all-targets`, default and `--features diagnostics`: the same warnings as main, none new. - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` passes (the page is the tool's output); `python -I scripts/check_no_game_data.py` on every file touched and on this text. GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 621.40, Windows 11 Pro (unit tests and the in-game A/B). AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-01 12:18:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T12:18:19Z.


Independent check of 685a2e5c2 on c60ce461a. Twelve targeted tests passed in the Windows MSVC test binary under Wine. They cover heap reads paired with bound stores, rejection of unclassified stores, the batch-closing reason, and the per-job table check. I ran the same selection in the AMD Raphael and RTX 4070 SUPER host configurations.

Restoring the old conservative decision in stage_declared for the control build made both with_heap_reads tests fail. The PR build passes both. These are synthetic analysis and batch-policy tests. GPU timing and in-game batching were outside the run.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310941780 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7310941780). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T12:18:19Z. --- Independent check of `685a2e5c2` on `c60ce461a`. Twelve targeted tests passed in the Windows MSVC test binary under Wine. They cover heap reads paired with bound stores, rejection of unclassified stores, the batch-closing reason, and the per-job table check. I ran the same selection in the AMD Raphael and RTX 4070 SUPER host configurations. Restoring the old conservative decision in `stage_declared` for the control build made both `with_heap_reads` tests fail. The PR build passes both. These are synthetic analysis and batch-policy tests. GPU timing and in-game batching were outside the run. AI-assisted with OpenAI Codex.
enlight3d commented 2026-12-01 12:30:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T12:30:13Z.


Checked again on this pull request's final exe (685a2e5c2, the switch on by default), RTX 3090 24 GB, NVIDIA 621.40, launcher defaults, Series S settings, the same save, standing still; warm-up and a throwaway run first, nothing else running; no device loss, private memory at most 29.5 GB.

In-run A/B, LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS (the off phases are =0), 600 s:

  • The A/B tool: frame median -1.85 +-0.12 ms with the switch (23 pairs).
  • Per phase, off against on: frame median 28.3 / 26.3 ms, p90 33.3 / 30.5 ms, card busy 29.0 / 26.9 ms.
  • Paired off minus on, the first 4 s of each phase and the first 60 s in the world left out (23 pairs): frame median +1.91 +-0.05 ms, mean +1.95 +-0.05, p90 +2.54 +-0.14, card busy +1.98 +-0.05; off before on +1.96, off after on +1.90.
  • The submitting thread works 0.86 +-0.10 ms a frame more with the switch on (0.2 ms in the first A/B). The card holds this machine, so it does not show in the frame here; on a machine held by the submitting thread it would eat into the gain.

LEONIDA_BATCH_WHY=1, 300 s at the defaults: 123 batches opened a frame (p90 124); ends for stores not all declared 9 (all "scalar stores or code not known"; no "?"); ends for a record declared written since the pass 34; full table 7, another source 25.9, copy 1; 4,470 executions read from an open batch a frame. Whole run 27.5 ms a frame (36.4 fps).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311224050 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7311224050). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-01T12:30:13Z. --- Checked again on this pull request's final exe (685a2e5c2, the switch on by default), RTX 3090 24 GB, NVIDIA 621.40, launcher defaults, Series S settings, the same save, standing still; warm-up and a throwaway run first, nothing else running; no device loss, private memory at most 29.5 GB. **In-run A/B, `LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS` (the off phases are `=0`), 600 s:** - The A/B tool: frame median -1.85 +-0.12 ms with the switch (23 pairs). - Per phase, off against on: frame median 28.3 / 26.3 ms, p90 33.3 / 30.5 ms, card busy 29.0 / 26.9 ms. - Paired off minus on, the first 4 s of each phase and the first 60 s in the world left out (23 pairs): frame median +1.91 +-0.05 ms, mean +1.95 +-0.05, p90 +2.54 +-0.14, card busy +1.98 +-0.05; off before on +1.96, off after on +1.90. - The submitting thread works 0.86 +-0.10 ms a frame more with the switch on (0.2 ms in the first A/B). The card holds this machine, so it does not show in the frame here; on a machine held by the submitting thread it would eat into the gain. **`LEONIDA_BATCH_WHY=1`, 300 s at the defaults:** 123 batches opened a frame (p90 124); ends for stores not all declared 9 (all "scalar stores or code not known"; no "?"); ends for a record declared written since the pass 34; full table 7, another source 25.9, copy 1; 4,470 executions read from an open batch a frame. Whole run 27.5 ms a frame (36.4 fps).
KelboLive commented 2026-12-01 12:45:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T12:45:49Z.

Review: COMMENTED


The rule reads well and fails closed on every write shape the new tests cover. stage_declared (draw.rs:923) requires !s.stores || (!s.past_views && (heap_reads || !s.heap) && bound()), and bound() is the per-store analysis (pipeline.rs:577-633) that only accepts a table descriptor loaded at a fixed offset with a UAV entry, or a non-spilled root UAV. A store through a heap-loaded descriptor becomes Source::Loaded with a ResourceHeap root param and is rejected (pipeline.rs:607); dynamic offsets, code-made descriptors, cselects and unknown tracking all fail closed, and the new heap_reader(16) case pins it. stores_told (draw.rs:6463-6490) really is the only thing kept — the open batch, not a descriptor table or slot — marking batch.wrote = true so later executions check the writer's ranges. The switch is read once and threaded as Declared.heap_reads, so an A/B phase change can't leave the diagnostic lying.

Mutation confirms the guard is load-bearing: relaxing it to "every non-past-view heap stage declared" fails draw::batch_tests::with_heap_reads_a_stage_reading_from_the_heap_is_declared_when_its_stores_are_bound (draw.rs:7231) and draw::undeclared_tests::…ends_no_batch (:7414). 641 lib tests pass, and merge-tree against origin/main is clean.

One wording issue, and it matters because these names end up in the diagnostics a tester reads: HeapReadsBound's "reads only from the heap" actually means "stores nothing through a heap view" — the stage still stores through its bound table/root views. "Heap views read only" would say that, and the batch_heap_reads doc should not read as if the stage were read-only. Also worth one sentence where heap is computed: SLOT_STRIDES is emitted for a heap-loaded constant buffer too (root type, not view kind), so some batches deliberately stay open a moment longer — conservative, not a hole.

Table::full_for is diagnostics-only and gated, and the regenerated switches.md counts (663/623) match the added row.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131502467 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#pullrequestreview-6131502467). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T12:45:49Z. **Review:** COMMENTED --- The rule reads well and fails closed on every write shape the new tests cover. `stage_declared` (`draw.rs:923`) requires `!s.stores || (!s.past_views && (heap_reads || !s.heap) && bound())`, and `bound()` is the per-store analysis (`pipeline.rs:577-633`) that only accepts a table descriptor loaded at a fixed offset with a UAV entry, or a non-spilled root UAV. A store through a heap-loaded descriptor becomes `Source::Loaded` with a `ResourceHeap` root param and is rejected (`pipeline.rs:607`); dynamic offsets, code-made descriptors, cselects and unknown tracking all fail closed, and the new `heap_reader(16)` case pins it. `stores_told` (`draw.rs:6463-6490`) really is the only thing kept — the open **batch**, not a descriptor table or slot — marking `batch.wrote = true` so later executions check the writer's ranges. The switch is read once and threaded as `Declared.heap_reads`, so an A/B phase change can't leave the diagnostic lying. Mutation confirms the guard is load-bearing: relaxing it to "every non-past-view heap stage declared" fails `draw::batch_tests::with_heap_reads_a_stage_reading_from_the_heap_is_declared_when_its_stores_are_bound` (`draw.rs:7231`) and `draw::undeclared_tests::…ends_no_batch` (`:7414`). 641 lib tests pass, and `merge-tree` against `origin/main` is clean. One wording issue, and it matters because these names end up in the diagnostics a tester reads: `HeapReadsBound`'s "reads only from the heap" actually means "stores nothing **through** a heap view" — the stage still stores through its bound table/root views. "Heap views read only" would say that, and the `batch_heap_reads` doc should not read as if the stage were read-only. Also worth one sentence where `heap` is computed: `SLOT_STRIDES` is emitted for a heap-loaded *constant buffer* too (root type, not view kind), so some batches deliberately stay open a moment longer — conservative, not a hole. `Table::full_for` is diagnostics-only and gated, and the regenerated `switches.md` counts (663/623) match the added row.
OreoFR commented 2026-12-01 13:21:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T13:21:25Z.


A/B on an RTX 4070 Laptop 8 GB (not the author), as asked. AI-assisted (Claude Code agent oreofr-agent, for OreoFR). NVIDIA 621.40, Core Ultra 7 155H, Windows 11 Pro.

Head 685a2e5c2 merged into main 2d4f316b0 (local merge 6b93284ad), diagnostics build, no DLSS.

  • cargo test --locked -p leonida-gpu: 641 passed, 0 failed.
  • One binary, LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS, -SeriesS -NoDlss -NoFrameGen, standing, 600 s in the world (fresh gate data, pipelines from an earlier run): 0 device loss, 0 ERROR lines, clean close.
  • d3d12_ab_compare.py phases: 27 pairs (6 left out for a draw jump), median frame time on − off: −0.381 ± 0.127 ms, the tool's verdict "no clear difference"; card_steps_ms −0.090 ± 0.010, card_copies_ms −0.055 ± 0.021. Mean of the phase medians ~39-40 ms on both sides.

So on this card the change goes the same way as on the 3090 but is much smaller (about −1 % of the frame, not −7 %). No regression seen. I did not repeat the mutation red here (the description lists 15 killed mutants).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312490087 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7312490087). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T13:21:25Z. --- **A/B on an RTX 4070 Laptop 8 GB** (not the author), as asked. AI-assisted (Claude Code agent `oreofr-agent`, for OreoFR). NVIDIA 621.40, Core Ultra 7 155H, Windows 11 Pro. Head `685a2e5c2` merged into `main` `2d4f316b0` (local merge `6b93284ad`), `diagnostics` build, no DLSS. - `cargo test --locked -p leonida-gpu`: **641 passed, 0 failed**. - **One binary, `LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS`**, `-SeriesS -NoDlss -NoFrameGen`, standing, 600 s in the world (fresh gate data, pipelines from an earlier run): **0 device loss, 0 ERROR lines**, clean close. - `d3d12_ab_compare.py phases`: 27 pairs (6 left out for a draw jump), **median frame time on − off: −0.381 ± 0.127 ms**, the tool's verdict "no clear difference"; `card_steps_ms` −0.090 ± 0.010, `card_copies_ms` −0.055 ± 0.021. Mean of the phase medians ~39-40 ms on both sides. So on this card the change goes the same way as on the 3090 but is much smaller (about −1 % of the frame, not −7 %). No regression seen. I did not repeat the mutation red here (the description lists 15 killed mutants).
lixonik commented 2026-12-01 13:38:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T13:38:02Z.


RUN

Verdict: same on whole-frame median (-1.600 +- 1.728 ms, no clear difference, 5 valid pairs / 4 dropped for draw jumps) under LEONIDA_INDIRECT_BATCH=4 + LEONIDA_AB=20,LEONIDA_BATCH_HEAP_READS on this CPU-bound PC (gpu_wait 0.0 ms), with 0 errors and 0 device-lost events.

Setup:

  • PR #2868 head 685a2e5c2 (LEONIDA_INDIRECT_BATCH=4, LEONIDA_AB=20,LEONIDA_BATCH_HEAP_READS, Series S, -NoFrameGen)
  • GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 621.40, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T)

Unit tests:

  • cargo test --locked -p leonida-gpu --lib bound_tests: 6 passed, 0 failed.
  • cargo test --locked -p leonida-gpu --lib batch: 28 passed, 0 failed, 2 ignored.

In-run A/B (tools/d3d12_ab_compare.py phases):

  • Overall run: 743.8 s precompile, 76 frame lines (53 world samples >= 1000 draws, median 23.2 fps / 43.1 ms, gpu_wait 0.0 ms, 4,390 median / 5,519 max draws, 0 errors, 0 device lost).
  • Paired deltas (5 pairs):
    • median: -1.600 +- 1.728 ms (no clear difference)
    • steps_ms: -1.999 +- 1.741 ms
    • copies_fills_ms: -0.199 +- 0.072 ms
    • ranges_by_bits: -11.640 +- 2.548

Merge note: d3d12/docs/switches.md currently conflicts with origin/main.

AI-assisted: Antigravity

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7312930719 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7312930719). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T13:38:02Z. --- RUN Verdict: `same` on whole-frame median (`-1.600 +- 1.728 ms`, `no clear difference`, 5 valid pairs / 4 dropped for draw jumps) under `LEONIDA_INDIRECT_BATCH=4` + `LEONIDA_AB=20,LEONIDA_BATCH_HEAP_READS` on this CPU-bound PC (`gpu_wait 0.0 ms`), with `0` errors and `0` device-lost events. Setup: - PR `#2868` head `685a2e5c2` (`LEONIDA_INDIRECT_BATCH=4`, `LEONIDA_AB=20,LEONIDA_BATCH_HEAP_READS`, `Series S`, `-NoFrameGen`) - GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver `621.40`, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T) Unit tests: - `cargo test --locked -p leonida-gpu --lib bound_tests`: `6 passed, 0 failed`. - `cargo test --locked -p leonida-gpu --lib batch`: `28 passed, 0 failed, 2 ignored`. In-run A/B (`tools/d3d12_ab_compare.py phases`): - Overall run: `743.8 s` precompile, `76` frame lines (`53` world samples `>= 1000` draws, median `23.2 fps` / `43.1 ms`, `gpu_wait 0.0 ms`, `4,390` median / `5,519` max draws, `0` errors, `0` device lost). - Paired deltas (`5` pairs): - `median`: `-1.600 +- 1.728 ms` (`no clear difference`) - `steps_ms`: `-1.999 +- 1.741 ms` - `copies_fills_ms`: `-0.199 +- 0.072 ms` - `ranges_by_bits`: `-11.640 +- 2.548` Merge note: `d3d12/docs/switches.md` currently conflicts with `origin/main`. AI-assisted: Antigravity
OreoFR commented 2026-12-01 13:43:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T13:43:43Z.


Addendum to my RUN above (same run, same log, RTX 4070 Laptop 8 GB, NVIDIA 621.40, -SeriesS without DLSS, LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS, standing, 600 s): the card's idle and busy time per arm, read from the A/B phase lines (fence-measured by ab.rs, no LEONIDA_GPU_TIMING). tools/d3d12_ab_compare.py phases does not print these fields, so I paired them myself: consecutive on/off phases in the world, 60 pairs.

per frame, median off on on − off (paired median)
frame 38.2 ms 37.7 ms −0.40 ms
card busy 36.9 ms 34.8 ms −2.20 ms
card idle 1.8 ms 3.5 ms +1.80 ms
submitting thread worked 32.2 ms 32.2 ms −0.10 ms

Reading: the card saves about the same time as on the 3090 (−1.9 to −2.0 ms there). On this card the submitting thread does not pay for the switch, but almost all of the saved card time turns into card idle, so the frame barely moves. Something other than the card's work and the submitting thread holds the frame at ~38 ms here; that part is a hypothesis.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313079453 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7313079453). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T13:43:43Z. --- Addendum to my RUN above (same run, same log, RTX 4070 Laptop 8 GB, NVIDIA 621.40, `-SeriesS` without DLSS, `LEONIDA_AB=10,LEONIDA_BATCH_HEAP_READS`, standing, 600 s): the card's idle and busy time per arm, read from the `A/B phase` lines (fence-measured by `ab.rs`, no `LEONIDA_GPU_TIMING`). `tools/d3d12_ab_compare.py phases` does not print these fields, so I paired them myself: consecutive on/off phases in the world, 60 pairs. | per frame, median | off | on | on − off (paired median) | |---|---|---|---| | frame | 38.2 ms | 37.7 ms | −0.40 ms | | card busy | 36.9 ms | 34.8 ms | **−2.20 ms** | | card idle | 1.8 ms | 3.5 ms | +1.80 ms | | submitting thread worked | 32.2 ms | 32.2 ms | −0.10 ms | Reading: the card saves about the same time as on the 3090 (−1.9 to −2.0 ms there). On this card the submitting thread does not pay for the switch, but almost all of the saved card time turns into card idle, so the frame barely moves. Something other than the card's work and the submitting thread holds the frame at ~38 ms here; that part is a hypothesis.
enlight3d commented 2026-12-01 13:46:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T13:46:14Z.


Follow-up on the 0.86 ms of extra work on the submitting thread that the final A/B showed: it does not come from code this switch runs.

  • In that run (no LEONIDA_BATCH_WHY), the batch path's own cost is measured at about +0.19 ms a frame in a release micro-benchmark of the written-ranges bookkeeping (8,000 declared ranges, 4,500 lookups), and that lands on the translating threads, not on the submitting thread.
  • On the submitting thread, CPU time inside submissions rises by 0.42 ms (user 8.76 to 9.04 ms, kernel 6.71 to 6.85 ms); the rest of the 0.82 ms of wall time is waiting. The added time is spread over steps the submission already does (waiting at the end for the heaps' records +0.22, copies in the card's memory +0.15, lists' steps +0.10, ...), none of them batching.
  • What doubles is data: title bytes merged under in-flight writes go from about 10,900 to 20,300 ranges a frame (0.60 to 1.10 MB), ranges sent to copies on the card from 10,700 to 19,700. Within the off phases alone the thread's worked time already follows those merged ranges (r = 0.59; on phases r = 0.62), at about 1.3-1.5 ms per 10,000 ranges. With the card no longer the wall, the thread waits less for flights (waits 0.21 to 0.04 ms) and prepares more often with flights still running, so it merges more instead of waiting: existing behaviour of the late wait, not this change.
  • On OreoFR's RTX 4070 Laptop the A/B line shows the same card gain (busy -2.2 ms) and the submitting thread's worked time unchanged (32.2 / 32.2 ms); there the frame gains -0.4 ms because the card then waits (+1.8 ms idle) for something else.

So the sentence in my previous comment that this extra work "would eat into the gain" on a machine held by the submitting thread overstated it: it is work the late wait does in place of waiting, and it did not show on the 4070.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313147979 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7313147979). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-01T13:46:14Z. --- Follow-up on the 0.86 ms of extra work on the submitting thread that the final A/B showed: it does not come from code this switch runs. - In that run (no `LEONIDA_BATCH_WHY`), the batch path's own cost is measured at about +0.19 ms a frame in a release micro-benchmark of the written-ranges bookkeeping (8,000 declared ranges, 4,500 lookups), and that lands on the translating threads, not on the submitting thread. - On the submitting thread, CPU time inside submissions rises by 0.42 ms (user 8.76 to 9.04 ms, kernel 6.71 to 6.85 ms); the rest of the 0.82 ms of wall time is waiting. The added time is spread over steps the submission already does (waiting at the end for the heaps' records +0.22, copies in the card's memory +0.15, lists' steps +0.10, ...), none of them batching. - What doubles is data: title bytes merged under in-flight writes go from about 10,900 to 20,300 ranges a frame (0.60 to 1.10 MB), ranges sent to copies on the card from 10,700 to 19,700. Within the off phases alone the thread's worked time already follows those merged ranges (r = 0.59; on phases r = 0.62), at about 1.3-1.5 ms per 10,000 ranges. With the card no longer the wall, the thread waits less for flights (waits 0.21 to 0.04 ms) and prepares more often with flights still running, so it merges more instead of waiting: existing behaviour of the late wait, not this change. - On OreoFR's RTX 4070 Laptop the A/B line shows the same card gain (busy -2.2 ms) and the submitting thread's worked time unchanged (32.2 / 32.2 ms); there the frame gains -0.4 ms because the card then waits (+1.8 ms idle) for something else. So the sentence in my previous comment that this extra work "would eat into the gain" on a machine held by the submitting thread overstated it: it is work the late wait does in place of waiting, and it did not show on the 4070.
enlight3d commented 2026-12-01 15:18:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T15:18:47Z.


Hold, please do not merge yet: a build of current main (cd0c52fcf) with this pull request and #2826 merged locally showed, on the RTX 3090, a character's head not drawn in the first scene (the hair drawn, the head under it missing) and, a few minutes later, a device removal (0x887A0005, "relay: the fence reports the device removed"). The earlier picture checks of this change (on main bf30e2585) showed the head. I am running the same scene with LEONIDA_BATCH_HEAP_READS=0 and =1 on that build to see whether this change is the cause or something else on newer main, and will report here. Marked as draft until then.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7315699885 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7315699885). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-01T15:18:47Z. --- Hold, please do not merge yet: a build of current `main` (cd0c52fcf) with this pull request and #2826 merged locally showed, on the RTX 3090, a character's head not drawn in the first scene (the hair drawn, the head under it missing) and, a few minutes later, a device removal (0x887A0005, "relay: the fence reports the device removed"). The earlier picture checks of this change (on `main` bf30e2585) showed the head. I am running the same scene with `LEONIDA_BATCH_HEAP_READS=0` and `=1` on that build to see whether this change is the cause or something else on newer `main`, and will report here. Marked as draft until then.
enlight3d commented 2026-12-01 15:25:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T15:25:37Z.


For the record: LEONIDA_BATCH_HEAP_READS on main (19d3484d7, 14:06 UTC, and 955e7d9cf, 14:49 UTC, which turns it on by default) is the change claimed as D3D12-BATCH-HEAP-READS in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7305543096, 08:36 UTC) and opened here as #2868 (11:51 UTC): the same rule, the same switch name, measured on an RTX 3090 (frame median -2.2 ms, clamp passes 601 to 122 a frame). Glad it is in. Could the next commit or d3d12/docs/findings.md credit #2868, as the repository does for other sources? I will close this pull request once the missing-head check above is settled.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7315888960 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7315888960). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-01T15:25:37Z. --- For the record: `LEONIDA_BATCH_HEAP_READS` on `main` (19d3484d7, 14:06 UTC, and 955e7d9cf, 14:49 UTC, which turns it on by default) is the change claimed as D3D12-BATCH-HEAP-READS in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7305543096, 08:36 UTC) and opened here as #2868 (11:51 UTC): the same rule, the same switch name, measured on an RTX 3090 (frame median -2.2 ms, clamp passes 601 to 122 a frame). Glad it is in. Could the next commit or `d3d12/docs/findings.md` credit #2868, as the repository does for other sources? I will close this pull request once the missing-head check above is settled.
MoonEyes commented 2026-12-02 12:18:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:18:49Z.


Closing: this pull request no longer applies to current main (merge conflict in d3d12/crates/leonida-gpu/src/draw.rs, d3d12/docs/switches.md), and open pull requests that have fallen out of step with main are being closed so the list stays workable. If you still want this change, rebase it on current main and reopen it (or open a new pull request); it will be looked at again.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345153393 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2868#issuecomment-7345153393). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:18:49Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `d3d12/crates/leonida-gpu/src/draw.rs`, `d3d12/docs/switches.md`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. If you still want this change, rebase it on current `main` and reopen it (or open a new pull request); it will be looked at again. AI-assisted (Claude Code).

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
ProjectLeonida/mandy!2868
No description provided.