GPU zones: the card's time by kind and by program from GPU Trace's ra… #2743

Closed
kibradev wants to merge 1 commit from upstream-pr/2743 into main
kibradev commented 2026-11-30 14:05:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kibradev on 2026-11-30T14:05:21Z.


…nges (LEONIDA_GPU_ZONES)

LEONIDA_GPU_ZONES=1 (diagnostics, off by default) wraps what each host list records in event ranges by kind: the title's draws, mesh and compute dispatches and indirect executions (the command itself), our clamps, and the rest; a list of the title's compute type names its ranges C:. With =2 the title's commands' ranges also name their pipeline. GPU Trace exports one row per range with its counters, which says where the card's time goes.

Findings (RTX 4060 Ti 8 GB, Series S, DLSS Quality, standing): the title's own work is 81 % of the card's time and ours 17 %; the indirect mesh draws are 41 % on c22a0a732 and 33 % on f9f3ec4c6, most of it nine wrapped vertex programs (128/128/128). A synthetic benchmark puts their cost in the group's output storage, not its threads; only a vertex path with an index buffer gets around it (about 4x), and leaving the nine out entirely takes 3.4 ms off the frame on f9f3ec4c6, where the submitting thread then stands at about 27 ms.

AI-assisted (Claude). Tested on an RTX 4060 Ti 8 GB, driver 610.88, Ryzen 7 7800X3D.

Claude-Session: https://claude.ai/code/session_01GXUoUmcFCUKVsuFDT4ozXA

Claimed in the coordination issue as:

Depends on:

Fixes:

What and why

Tested

GPUs tested:

AI-assisted:

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5566837432 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2743). Originally posted by [kibradev](https://github.com/kibradev) on 2026-11-30T14:05:21Z. --- …nges (LEONIDA_GPU_ZONES) LEONIDA_GPU_ZONES=1 (diagnostics, off by default) wraps what each host list records in event ranges by kind: the title's draws, mesh and compute dispatches and indirect executions (the command itself), our clamps, and the rest; a list of the title's compute type names its ranges C:. With =2 the title's commands' ranges also name their pipeline. GPU Trace exports one row per range with its counters, which says where the card's time goes. Findings (RTX 4060 Ti 8 GB, Series S, DLSS Quality, standing): the title's own work is 81 % of the card's time and ours 17 %; the indirect mesh draws are 41 % on c22a0a732 and 33 % on f9f3ec4c6, most of it nine wrapped vertex programs (128/128/128). A synthetic benchmark puts their cost in the group's output storage, not its threads; only a vertex path with an index buffer gets around it (about 4x), and leaving the nine out entirely takes 3.4 ms off the frame on f9f3ec4c6, where the submitting thread then stands at about 27 ms. AI-assisted (Claude). Tested on an RTX 4060 Ti 8 GB, driver 610.88, Ryzen 7 7800X3D. Claude-Session: https://claude.ai/code/session_01GXUoUmcFCUKVsuFDT4ozXA Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (see AGENTS.md; the coordination issue lists the open pull requests); delete the line if it builds on none and conflicts with none --> Fixes: <!-- #N for each issue this closes (GitHub closes it on merge); delete the line if it closes none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> GPUs tested: <!-- vendor, model, driver and OS of each GPU the GPU tests ran on, or n/a --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### 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.
KelboLive commented 2026-11-30 15:43:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T15:43:38Z.


Independent check on Windows (not the author), at 51134319c.

  • cargo test --locked --jobs 8 -p leonida-gpu --lib -- --test-threads=8: 563 passed, 0 failed, 52 ignored in 17.0 s.

The diff adds the GPU-zone instrumentation (draw.rs, host.rs, indirect.rs, list.rs) plus findings docs; this confirms it builds and leaves the existing unit tests green. The new counters themselves need a game run with LEONIDA_GPU_ZONES, which I did not do.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7283476946 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2743#issuecomment-7283476946). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T15:43:38Z. --- Independent check on Windows (not the author), at `51134319c`. - `cargo test --locked --jobs 8 -p leonida-gpu --lib -- --test-threads=8`: **563 passed, 0 failed, 52 ignored** in 17.0 s. The diff adds the GPU-zone instrumentation (`draw.rs`, `host.rs`, `indirect.rs`, `list.rs`) plus findings docs; this confirms it builds and leaves the existing unit tests green. The new counters themselves need a game run with `LEONIDA_GPU_ZONES`, which I did not do. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned. AI-assisted: yes (opencode).
KelboLive commented 2026-12-01 16:12:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T16:12:19Z.

Review: COMMENTED


Reviewed at 51134319c (the merge-base diff: 6 files, +235/−1; gh's stale baseRefOid shows an unrelated 14-file diff). The diagnostics-gated suite is 626/0/52 and the default run 563/0/52, and the range bookkeeping inside a list cannot double-count by construction — every transition ends the previous range, and zone() skips same-zone transitions. close() forcing P_other and reset() clearing are both sane.

But the numbers do not close, and that is the point of the tool:

  1. P_other does not cover whole lists. reset() leaves zone 0 and only close() opens a range, so a list's head before its first zoned command — and internal-only lists (texture init, copy/upload, BLAS) that never call zone() — are in no range. Your own figures show it: at f9f3ec4c6, 29.3 ms of ranges against 35.7 ms card-busy is 82 % coverage, 6.4 ms (≈18 %) unaccounted; at c22a0a732, 37–39 vs 40.4. So the 81 %/17 % split is of the exported ranges, not of card-busy time, and the port's share may be nearer a third than 17 %.
  2. Report ranges-versus-card-busy with a stated tolerance, and open P_other at reset (or at the first command) so the uncovered head is counted somewhere. Without that, the tool systematically understates the port's own work.
  3. =2 does not name direct draws: draw.rs:6055 and :6192 still call zone(TitleDraw), so T_draw cannot be split by program although switches.md says the title's commands' ranges name their pipeline. Either name them or narrow the doc.
  4. The zone state machine has no test: deleting the EndEvent in the was != 0 branch (host.rs:9011-9013) leaves all 626 tests green, and that mutation produces nested, double-counted ranges. A small fake range-emitter test would pin begin/end balance and switching.
  5. C: is a list kind, not a queue — every host list is created D3D12_COMMAND_LIST_TYPE_DIRECT (host.rs:5827) and submitted on the one direct host queue (:1315); C: labels the console list kind (kind == 2). Rename it, or verify the assumption if you believe otherwise.
  6. Needs the rebase it is labelled with: merge-tree conflicts in d3d12/docs/findings.md and d3d12/docs/switches.md only; the four code files merge cleanly.
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6135179011 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2743#pullrequestreview-6135179011). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T16:12:19Z. **Review:** COMMENTED --- Reviewed at `51134319c` (the merge-base diff: 6 files, +235/−1; `gh`'s stale `baseRefOid` shows an unrelated 14-file diff). The diagnostics-gated suite is 626/0/52 and the default run 563/0/52, and the range bookkeeping inside a list cannot double-count by construction — every transition ends the previous range, and `zone()` skips same-zone transitions. `close()` forcing `P_other` and `reset()` clearing are both sane. But the numbers do not close, and that is the point of the tool: 1. **`P_other` does not cover whole lists.** `reset()` leaves zone 0 and only `close()` opens a range, so a list's head before its first zoned command — and internal-only lists (texture init, copy/upload, BLAS) that never call `zone()` — are in **no** range. Your own figures show it: at `f9f3ec4c6`, 29.3 ms of ranges against 35.7 ms card-busy is **82 % coverage, 6.4 ms (≈18 %) unaccounted**; at `c22a0a732`, 37–39 vs 40.4. So the 81 %/17 % split is of the *exported ranges*, not of card-busy time, and the port's share may be nearer a third than 17 %. 2. **Report ranges-versus-card-busy with a stated tolerance**, and open `P_other` at reset (or at the first command) so the uncovered head is counted somewhere. Without that, the tool systematically understates the port's own work. 3. **`=2` does not name direct draws**: `draw.rs:6055` and `:6192` still call `zone(TitleDraw)`, so `T_draw` cannot be split by program although `switches.md` says the title's commands' ranges name their pipeline. Either name them or narrow the doc. 4. **The zone state machine has no test**: deleting the `EndEvent` in the `was != 0` branch (`host.rs:9011-9013`) leaves all 626 tests green, and that mutation produces nested, double-counted ranges. A small fake range-emitter test would pin begin/end balance and switching. 5. **`C:` is a list kind, not a queue** — every host list is created `D3D12_COMMAND_LIST_TYPE_DIRECT` (`host.rs:5827`) and submitted on the one direct host queue (`:1315`); `C:` labels the console list kind (`kind == 2`). Rename it, or verify the assumption if you believe otherwise. 6. **Needs the rebase it is labelled with**: `merge-tree` conflicts in `d3d12/docs/findings.md` and `d3d12/docs/switches.md` only; the four code files merge cleanly.
MoonEyes commented 2026-12-02 11:50:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:50:34Z.


Closing: this pull request no longer applies to current main (merge conflict in d3d12/crates/leonida-gpu/src/draw.rs, d3d12/docs/findings.md, 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:7344481778 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2743#issuecomment-7344481778). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:50:34Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `d3d12/crates/leonida-gpu/src/draw.rs`, `d3d12/docs/findings.md`, `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!2743
No description provided.