d3d12/timeline: attribute slow command-list ops, caller sites, and bound pipelines in stall and timed traces (D3D12-TIMELINE-STALL-LIST-OP) #3136

Open
zmasi wants to merge 5 commits from upstream-pr/3136 into main
zmasi commented 2026-12-02 13:33:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-02T13:33:53Z.


Claimed in the coordination issue as: D3D12-TIMELINE-STALL-LIST-OP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7345129758)

Addresses #3105 (does not close it: surfaces the command-list operation, caller return site, and bound title pipeline on slow list calls in stall and timed timeline captures; separate changes address underlying stall sources).

What and why

Extends command-list slow-call timeline attribution (>= 50 us) so both one-shot rolling stall captures (LEONIDA_TIMELINE_STALL_MS) and timed captures (LEONIDA_TIMELINE) attribute the specific command-list operation, a stack-local caller return site, and the list's currently bound title pipeline pointer instead of collapsing into an unattributed "a long list call" span:

  1. Root cause of "a long list call" blindness in #3105:
    • timeline::record::called emitted generic "a long list call" with Event.a = 0 and Event.b = 0, while gating stack() behind timed_on() so stall mode (STACK unallocated, Event.stack == 0) retained zero operation, callsite, or pipeline context.
    • list.rs only timed with_state closures anonymously and left non-with_state host-list recording methods (ResourceBarrier, BarrierGroups, Sync, CopyBufferRegion, CopyResource, CopyTextureRegion, ResolveSubresource, ClearRenderTargetView, ClearDepthStencilView, CopyMemoryToMemoryX, and WaitValue / WaitValue64 list cuts) untimed.
    • timeline::report had no long-list-call section in summary_stall_with_freq and ignored Event.a / Event.b on long-list-call spans in Chrome JSON args.
  2. Zero-fast-path-overhead operation, caller-site, and pipeline recording (copystat.rs, list.rs, timeline.rs, timeline/record.rs):
    • Adds copystat::recorded_op(started, op, pipeline) gating timeline::called_from_list(took, op, pipeline) behind timeline::on(), adding zero call overhead when timeline recording is off.
    • Tracks bound_pipeline: AtomicUsize at the end of List (preserving offset_of!(List, put) == 0x18 and offset_of!(List, pipeline_shadow) + 32 == 0x560) across creation, Reset, SetPipelineState, Close, detach, and detach_parts.
    • Tags all with_state callers with static "a long list call: <Op>" and wraps non-with_state host-list recording operations (ResourceBarrier, BarrierGroups, Sync, copies, resolves, clears, and WaitValue / WaitValue64 cuts) once via measure_call + with_state_untimed without double-counting, using black_box(&started) and aligned external / upscale -> run_external / upscale_now frame depth so RtlCaptureStackBackTrace(3, 1, ...) resolves the list op's caller (thin::translate / thin::run_plain or title callsite) identically in dev and optimized (diag) builds without touching STACK (Event.stack == 0 in stall mode and size_of::<Event>() == 64 preserved).
  3. Stall & timed summary and Chrome JSON reporting (timeline/report.rs):
    • Trace::doing / chain_stall attributes stall chains directly to "a long list call: <Op>".
    • summary_stall_with_freq adds "list calls of 50 us or more in trigger interval: who, op, caller site, bound title pipeline", formatting Event.b in hex ({:#x}, matching the hex value of pipeline in "first bind" log lines).
    • chrome_inner emits "op", "at", "site", and "pipeline" in args for long-list-call spans (preferring Event.stack in timed mode and falling back to Event.a).

Tested

  • Red -> Green baseline check (985661b34 onto origin/main d0bf821fa):
    • python -I scripts/red_green.py HEAD --no-fetch --no-python (with --features diagnostics timeline:: runner): verdict: red then green (2/2 new tests red -> green, 17/17 existing timeline:: tests pass on both).
  • Rust & hygiene suites (x86_64-pc-windows-msvc):
    • cargo test -p leonida-gpu --features diagnostics --lib --target x86_64-pc-windows-msvc timeline:: (dev and --release opt-level=3): 19 passed, 0 failed (verifies exact caller identity via PE .pdata RtlLookupFunctionEntry in both unoptimized and opt-level=3 builds, Event.stack == 0 in stall mode, and stall/timed .txt + Chrome JSON formatting).
    • cargo test -p leonida-gpu --features diagnostics --lib --target x86_64-pc-windows-msvc copystat::: 4 passed, 0 failed.
    • cargo test -p leonida-gpu [--features diagnostics] --lib --target x86_64-pc-windows-msvc list::: 12 passed, 0 failed in both diagnostics and default builds.
    • cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc: 0 warnings in touched files.
    • python -I scripts/check_no_game_data.py and python -I tests/test_text_write_line_endings.py: exit 0.

GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro 10.0.26200 (host D3D12 command-list and timeline unit tests; no retail title run).

AI-assisted: yes — authored with Gemini 4 Carbon (High) and independently audited across two read-only review cycles by Gemini 4 Neon (XHigh) (which caught and verified the opt-level=3 sibcall frame-depth alignment and zero-overhead !timeline::on() gate).

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:5607483913 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-02T13:33:53Z. --- Claimed in the coordination issue as: `D3D12-TIMELINE-STALL-LIST-OP` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7345129758) Addresses #3105 (does not close it: surfaces the command-list operation, caller return site, and bound title pipeline on slow list calls in stall and timed timeline captures; separate changes address underlying stall sources). ### What and why Extends command-list slow-call timeline attribution (`>= 50 us`) so both one-shot rolling stall captures (`LEONIDA_TIMELINE_STALL_MS`) and timed captures (`LEONIDA_TIMELINE`) attribute the specific command-list operation, a stack-local caller return site, and the list's currently bound title pipeline pointer instead of collapsing into an unattributed `"a long list call"` span: 1. **Root cause of `"a long list call"` blindness in `#3105`:** - `timeline::record::called` emitted generic `"a long list call"` with `Event.a = 0` and `Event.b = 0`, while gating `stack()` behind `timed_on()` so stall mode (`STACK` unallocated, `Event.stack == 0`) retained zero operation, callsite, or pipeline context. - `list.rs` only timed `with_state` closures anonymously and left non-`with_state` host-list recording methods (`ResourceBarrier`, `BarrierGroups`, `Sync`, `CopyBufferRegion`, `CopyResource`, `CopyTextureRegion`, `ResolveSubresource`, `ClearRenderTargetView`, `ClearDepthStencilView`, `CopyMemoryToMemoryX`, and `WaitValue` / `WaitValue64` list cuts) untimed. - `timeline::report` had no long-list-call section in `summary_stall_with_freq` and ignored `Event.a` / `Event.b` on long-list-call spans in Chrome JSON `args`. 2. **Zero-fast-path-overhead operation, caller-site, and pipeline recording (`copystat.rs`, `list.rs`, `timeline.rs`, `timeline/record.rs`):** - Adds `copystat::recorded_op(started, op, pipeline)` gating `timeline::called_from_list(took, op, pipeline)` behind `timeline::on()`, adding zero call overhead when timeline recording is off. - Tracks `bound_pipeline: AtomicUsize` at the end of `List` (preserving `offset_of!(List, put) == 0x18` and `offset_of!(List, pipeline_shadow) + 32 == 0x560`) across creation, `Reset`, `SetPipelineState`, `Close`, `detach`, and `detach_parts`. - Tags all `with_state` callers with static `"a long list call: <Op>"` and wraps non-`with_state` host-list recording operations (`ResourceBarrier`, `BarrierGroups`, `Sync`, copies, resolves, clears, and `WaitValue` / `WaitValue64` cuts) once via `measure_call` + `with_state_untimed` without double-counting, using `black_box(&started)` and aligned `external` / `upscale` -> `run_external` / `upscale_now` frame depth so `RtlCaptureStackBackTrace(3, 1, ...)` resolves the list op's caller (`thin::translate` / `thin::run_plain` or title callsite) identically in `dev` and optimized (`diag`) builds without touching `STACK` (`Event.stack == 0` in stall mode and `size_of::<Event>() == 64` preserved). 3. **Stall & timed summary and Chrome JSON reporting (`timeline/report.rs`):** - `Trace::doing` / `chain_stall` attributes stall chains directly to `"a long list call: <Op>"`. - `summary_stall_with_freq` adds `"list calls of 50 us or more in trigger interval: who, op, caller site, bound title pipeline"`, formatting `Event.b` in hex (`{:#x}`, matching the hex value of `pipeline` in `"first bind"` log lines). - `chrome_inner` emits `"op"`, `"at"`, `"site"`, and `"pipeline"` in `args` for long-list-call spans (preferring `Event.stack` in timed mode and falling back to `Event.a`). ### Tested - **Red -> Green baseline check (`985661b34` onto `origin/main` `d0bf821fa`):** - `python -I scripts/red_green.py HEAD --no-fetch --no-python` (with `--features diagnostics` `timeline::` runner): `verdict: red then green` (`2/2` new tests `red -> green`, `17/17` existing `timeline::` tests pass on both). - **Rust & hygiene suites (`x86_64-pc-windows-msvc`):** - `cargo test -p leonida-gpu --features diagnostics --lib --target x86_64-pc-windows-msvc timeline::` (`dev` and `--release` `opt-level=3`): `19 passed, 0 failed` (verifies exact caller identity via PE `.pdata` `RtlLookupFunctionEntry` in both unoptimized and `opt-level=3` builds, `Event.stack == 0` in stall mode, and stall/timed `.txt` + Chrome JSON formatting). - `cargo test -p leonida-gpu --features diagnostics --lib --target x86_64-pc-windows-msvc copystat::`: `4 passed, 0 failed`. - `cargo test -p leonida-gpu [--features diagnostics] --lib --target x86_64-pc-windows-msvc list::`: `12 passed, 0 failed` in both `diagnostics` and default builds. - `cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc`: `0` warnings in touched files. - `python -I scripts/check_no_game_data.py` and `python -I tests/test_text_write_line_endings.py`: exit `0`. GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro `10.0.26200` (host D3D12 command-list and timeline unit tests; no retail title run). AI-assisted: yes — authored with Gemini 4 Carbon (High) and independently audited across two read-only review cycles by Gemini 4 Neon (XHigh) (which caught and verified the `opt-level=3` sibcall frame-depth alignment and zero-overhead `!timeline::on()` gate). ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
Kal0s-design commented 2026-12-02 17:01:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T17:01:51Z.


Ran natively on Windows 11, head 0518fc48e merged into main (43fc605ed, merges cleanly; still merges cleanly into today's 5b1fff821), on an NVIDIA card and on WARP. Besides the suites, I checked what the body does not cover: the play profile (thin LTO, one codegen unit), several threads recording at once, the bounds, the cost, and the reports.

Suites on the merge. MEASURED.

Run Result
leonida-gpu --lib --features diagnostics, card 779 passed, 0 failed, 59 ignored
same, WARP 779 passed, 0 failed
leonida-gpu --lib (no diagnostics) 696 passed, 0 failed
long_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modes, --profile play 3/3 pass
timeline:: + copystat::, --profile play 22 of 23 pass. real_waits_are_recorded_with_who_ended_them fails, and fails the same way on main under play: a symbol-name check, unrelated to this PR
clippy -p leonida-gpu --all-targets, with and without diagnostics no warning on a line this PR adds

Caller site and pipeline, several threads at once. Throwaway test, stall mode. 8 threads, each with its own title list (its own pipeline pointer at creation) and its own #[inline(never)] caller, each doing 200 external calls of about 100 us. Every retained event was checked: Event.a resolved through .pdata to that thread's caller, and Event.b was that list's pipeline. MEASURED.

Profile Retained Wrong site Wrong pipeline Unresolved Dropped by ring contention
dev 1,412 / 1,600 0 0 0 188
play 1,540 / 1,600 0 0 0 60

So attribution holds under concurrency and with thin LTO. What is lost is lost whole: the stall ring's try_lock drops the event (and counts it in dropped_contention). That behaviour is older than this PR, but with 8 recording threads it was 4 to 12 % of the slow calls here. Since the new stall summary ranks ops by total time, that loss is worth keeping in mind when reading it.

READ IN CODE: every timed call site I found either calls with_state / measure_call directly from the op function, or goes through an #[inline(always)] helper (wait_for, copy_resource_inner, copy_texture_region_inner, reset_inner, external, upscale), or through a deliberate #[inline(never)] frame (run_external, upscale_now). None of the timed paths nests a timed with_state inside a measure_call closure. Thin lists replay on the back list in record order, so the pipeline a replayed op carries is the one bound at that point.

Bounds. Throwaway test. MEASURED.

Mode Input Result
stall, ring of 1,024 5,000 slow calls 1,024 kept, 3,976 counted as overwritten
timed EVENTS + 5,000 slow calls 1,048,576 kept, 5,000 counted as lost; stack table capped at STACKS (65,536); stall mode leaves Event.stack at 0 throughout

No new buffer: LIST_RUN is one Cell per thread.

Cost. Throwaway test, --profile play --features diagnostics, card: best of 7 x 5,000 calls, 5 runs each, on a machine that was busy with other builds. MEASURED.

ns per call, median (range) main PR, timeline off PR, stall mode on
Sync 406 (352-426) 414 (349-445) 431 (385-434)
UAV ResourceBarrier 404 (383-437) 476 (357-547) 492 (443-517)
ClearRenderTargetView 828 (654-836) 1050 (956-1173) 1056 (1007-1100)

Turning the timeline on (stall mode, calls under 50 us) costs nothing I can see over it being off. Against main, Sync is the same. The barrier and the clear came out about 70 and 200 ns slower at the median. Those two are now timed (two Instant reads and recorded_op) where they were not before. But the main and PR runs were not interleaved, and one earlier PR run had the clear at 740-760 ns, so I would not quote these as the cost. A clear in the title's frame is far from a hot path anyway.

The "list calls" line of a diagnostics run changes. copystat::peek(RecordCalls) before and after one call. MEASURED.

Call main PR
pipeline Sync +2 +1
UAV ResourceBarrier +1 +1
ClearRenderTargetView +0 +1

Copies, resolves, clears, barrier groups and value waits are now timed, and nested with_state calls no longer count twice. That is intended, but the "recording per frame: N list calls, X ms" figures of a diagnostics build are not comparable across this PR, in either direction, depending on the mix. A line in the body would help anyone comparing logs.

Timed report: one site spread over many pipelines. Throwaway test of summary(). One caller site with 40 slow calls of 1 ms, each under a different pipeline (40 ms in all), and one other site with a single 5 ms call. MEASURED.

  • The "list calls of 50 us or more, per frame" table now keys on op | site | pipeline, so the 40 ms site becomes 40 rows of 1 ms.
  • The 5 ms site is first, and the table's cap of 25 rows shows only 24 of the 40.
  • On main the key is the site alone (READ IN CODE), so the same calls would be one 40 ms row on top.

In a real timed capture, where thin::translate or one title function binds many pipelines, the heaviest site can drop out of the top 25. Keeping that table keyed by op and site, and leaving per-pipeline detail to the stall summary and the JSON, would keep the old ranking.

Chrome JSON. A site name with a quote and a backslash is escaped and the file parses (the test's parse_json). A span with a == 0 gives "at":"", "site":"0x0", "pipeline":"", which is valid. MEASURED.

Smaller things (READ IN CODE).

  • copystat::recorded and timeline::called have no callers left and are kept with #[allow(dead_code)]. A test still calls called with its own frame depth (skip 1), while recorded would go through called_from_list with skip 3, one frame too far for a direct caller. Removing recorded avoids that trap.
  • git merge-tree against #2834's head conflicts in leonida-gpu/src/list.rs. #2834 adds two-argument with_state calls (targets_written in clear, clear-depth and resolve, and its wait). Whichever lands second needs a rebase and op names for those calls.

Not checked: a capture from a running title (no game run), and the attribution under the diag profile itself (dev, play and the body's opt-level 3 runs bracket it).

GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352798069 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7352798069). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T17:01:51Z. --- Ran natively on Windows 11, head `0518fc48e` merged into `main` (`43fc605ed`, merges cleanly; still merges cleanly into today's `5b1fff821`), on an NVIDIA card and on WARP. Besides the suites, I checked what the body does not cover: the `play` profile (thin LTO, one codegen unit), several threads recording at once, the bounds, the cost, and the reports. **Suites on the merge.** MEASURED. | Run | Result | |---|---| | `leonida-gpu --lib --features diagnostics`, card | 779 passed, 0 failed, 59 ignored | | same, WARP | 779 passed, 0 failed | | `leonida-gpu --lib` (no diagnostics) | 696 passed, 0 failed | | `long_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modes`, `--profile play` | 3/3 pass | | `timeline::` + `copystat::`, `--profile play` | 22 of 23 pass. `real_waits_are_recorded_with_who_ended_them` fails, and fails the same way on `main` under `play`: a symbol-name check, unrelated to this PR | | `clippy -p leonida-gpu --all-targets`, with and without diagnostics | no warning on a line this PR adds | **Caller site and pipeline, several threads at once.** Throwaway test, stall mode. 8 threads, each with its own title list (its own pipeline pointer at creation) and its own `#[inline(never)]` caller, each doing 200 `external` calls of about 100 us. Every retained event was checked: `Event.a` resolved through `.pdata` to that thread's caller, and `Event.b` was that list's pipeline. MEASURED. | Profile | Retained | Wrong site | Wrong pipeline | Unresolved | Dropped by ring contention | |---|---|---|---|---|---| | dev | 1,412 / 1,600 | 0 | 0 | 0 | 188 | | play | 1,540 / 1,600 | 0 | 0 | 0 | 60 | So attribution holds under concurrency and with thin LTO. What is lost is lost whole: the stall ring's `try_lock` drops the event (and counts it in `dropped_contention`). That behaviour is older than this PR, but with 8 recording threads it was 4 to 12 % of the slow calls here. Since the new stall summary ranks ops by total time, that loss is worth keeping in mind when reading it. READ IN CODE: every timed call site I found either calls `with_state` / `measure_call` directly from the op function, or goes through an `#[inline(always)]` helper (`wait_for`, `copy_resource_inner`, `copy_texture_region_inner`, `reset_inner`, `external`, `upscale`), or through a deliberate `#[inline(never)]` frame (`run_external`, `upscale_now`). None of the timed paths nests a timed `with_state` inside a `measure_call` closure. Thin lists replay on the back list in record order, so the pipeline a replayed op carries is the one bound at that point. **Bounds.** Throwaway test. MEASURED. | Mode | Input | Result | |---|---|---| | stall, ring of 1,024 | 5,000 slow calls | 1,024 kept, 3,976 counted as overwritten | | timed | `EVENTS` + 5,000 slow calls | 1,048,576 kept, 5,000 counted as lost; stack table capped at `STACKS` (65,536); stall mode leaves `Event.stack` at 0 throughout | No new buffer: `LIST_RUN` is one `Cell` per thread. **Cost.** Throwaway test, `--profile play --features diagnostics`, card: best of 7 x 5,000 calls, 5 runs each, on a machine that was busy with other builds. MEASURED. | ns per call, median (range) | `main` | PR, timeline off | PR, stall mode on | |---|---|---|---| | `Sync` | 406 (352-426) | 414 (349-445) | 431 (385-434) | | UAV `ResourceBarrier` | 404 (383-437) | 476 (357-547) | 492 (443-517) | | `ClearRenderTargetView` | 828 (654-836) | 1050 (956-1173) | 1056 (1007-1100) | Turning the timeline on (stall mode, calls under 50 us) costs nothing I can see over it being off. Against `main`, `Sync` is the same. The barrier and the clear came out about 70 and 200 ns slower at the median. Those two are now timed (two `Instant` reads and `recorded_op`) where they were not before. But the `main` and PR runs were not interleaved, and one earlier PR run had the clear at 740-760 ns, so I would not quote these as the cost. A clear in the title's frame is far from a hot path anyway. **The "list calls" line of a diagnostics run changes.** `copystat::peek(RecordCalls)` before and after one call. MEASURED. | Call | `main` | PR | |---|---|---| | pipeline `Sync` | +2 | +1 | | UAV `ResourceBarrier` | +1 | +1 | | `ClearRenderTargetView` | +0 | +1 | Copies, resolves, clears, barrier groups and value waits are now timed, and nested `with_state` calls no longer count twice. That is intended, but the "recording per frame: N list calls, X ms" figures of a diagnostics build are not comparable across this PR, in either direction, depending on the mix. A line in the body would help anyone comparing logs. **Timed report: one site spread over many pipelines.** Throwaway test of `summary()`. One caller site with 40 slow calls of 1 ms, each under a different pipeline (40 ms in all), and one other site with a single 5 ms call. MEASURED. - The "list calls of 50 us or more, per frame" table now keys on op | site | pipeline, so the 40 ms site becomes 40 rows of 1 ms. - The 5 ms site is first, and the table's cap of 25 rows shows only 24 of the 40. - On `main` the key is the site alone (READ IN CODE), so the same calls would be one 40 ms row on top. In a real timed capture, where `thin::translate` or one title function binds many pipelines, the heaviest site can drop out of the top 25. Keeping that table keyed by op and site, and leaving per-pipeline detail to the stall summary and the JSON, would keep the old ranking. **Chrome JSON.** A site name with a quote and a backslash is escaped and the file parses (the test's `parse_json`). A span with `a == 0` gives `"at":""`, `"site":"0x0"`, `"pipeline":""`, which is valid. MEASURED. **Smaller things (READ IN CODE).** - `copystat::recorded` and `timeline::called` have no callers left and are kept with `#[allow(dead_code)]`. A test still calls `called` with its own frame depth (skip 1), while `recorded` would go through `called_from_list` with skip 3, one frame too far for a direct caller. Removing `recorded` avoids that trap. - `git merge-tree` against #2834's head conflicts in `leonida-gpu/src/list.rs`. #2834 adds two-argument `with_state` calls (`targets_written` in clear, clear-depth and resolve, and its `wait`). Whichever lands second needs a rebase and op names for those calls. Not checked: a capture from a running title (no game run), and the attribution under the `diag` profile itself (dev, `play` and the body's opt-level 3 runs bracket it). GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 18:18:23 +00:00 (Migrated from github.com)

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


Verification of #3136 (third party, code review on Linux; not built: Windows-only leonida-gpu)

  • Head verified: 0518fc48eb705382fd1d60cf5975c0ac476c4a5c (5 files: list.rs, copystat.rs, timeline.rs,
    timeline/record.rs, timeline/report.rs; +1054/-297).
  • Merge base 128648cfe. git merge-tree --write-tree origin/main pr/3136 against main 45dc41f95 is clean
    (70 commits behind). CI on the head: 6/6 success.
  • python -I scripts/check_no_game_data.py on the 5 files: exit 0.

Review

  • Purpose (#3105): slow command-list calls (>= 50 µs) in stall and timed timelines now name the list op, the
    caller's return site and the bound title pipeline. Each list.rs entry point goes through
    with_state(this, "<op>", ..) or measure_call, and the pipeline is tracked in a new per-list
    bound_pipeline atomic (set in set_pipeline and reset, cleared on close).
  • Release cost: the timing is under #[cfg(feature = "diagnostics")]. In non-diagnostics builds the only
    addition is a relaxed AtomicUsize store per SetPipelineState and Reset, which is negligible.
    Kal0s-design checked the play profile.
  • Dead code (AGENTS.md "no dead code"): copystat::recorded and timeline::called no longer have callers.
    They are kept with #[allow(dead_code)] (copystat.rs:1090, timeline/record.rs:343). git grep at the head
    finds no caller. Remove them.
  • Fragile caller attribution: called_from_list records the return site with a fixed skip = 3. The
    comment explains it as called_from_list, then recorded_op (#[inline(never)]), then the list.rs op
    function (kept from a sibling call by std::hint::black_box(&started)), then its caller. That depends on
    with_state / measure_call being inlined (#[inline(always)] is a strong hint, not a guarantee under every
    profile or LTO setting) and on black_box defeating tail calls. If either changes, the report names the wrong
    frame with no error. Capture the return address at the extern entry (list.rs op functions) and pass it down,
    or check the resolved symbol in a test, so a shift is caught.
  • Size: most of the list.rs churn is mechanical (each entry wrapped in a named op). It is reviewable, but a
    split into "name the ops" and "pipeline + caller site" would have been easier to audit.
  • Tests: timeline/report.rs gains report-format tests. Kal0s-design ran the suites natively on an NVIDIA card
    and on WARP, including several recording threads and the play profile.

Process

  • Claim and AI disclosure (Gemini 4 Carbon author, Gemini 4 Neon reviewer) are present.

Verdict: defects (minor). Remove the #[allow(dead_code)] functions, and make the caller-site skip robust or
covered by a test.

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


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354334547 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7354334547). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:18:23Z. --- **Verification of #3136 (third party, code review on Linux; not built: Windows-only `leonida-gpu`)** - Head verified: `0518fc48eb705382fd1d60cf5975c0ac476c4a5c` (5 files: `list.rs`, `copystat.rs`, `timeline.rs`, `timeline/record.rs`, `timeline/report.rs`; +1054/-297). - Merge base `128648cfe`. `git merge-tree --write-tree origin/main pr/3136` against `main` `45dc41f95` is clean (70 commits behind). CI on the head: 6/6 success. - `python -I scripts/check_no_game_data.py` on the 5 files: exit 0. **Review** - Purpose (#3105): slow command-list calls (>= 50 µs) in stall and timed timelines now name the list op, the caller's return site and the bound title pipeline. Each `list.rs` entry point goes through `with_state(this, "<op>", ..)` or `measure_call`, and the pipeline is tracked in a new per-list `bound_pipeline` atomic (set in `set_pipeline` and `reset`, cleared on close). - Release cost: the timing is under `#[cfg(feature = "diagnostics")]`. In non-diagnostics builds the only addition is a relaxed `AtomicUsize` store per `SetPipelineState` and `Reset`, which is negligible. Kal0s-design checked the `play` profile. - **Dead code (AGENTS.md "no dead code"):** `copystat::recorded` and `timeline::called` no longer have callers. They are kept with `#[allow(dead_code)]` (`copystat.rs:1090`, `timeline/record.rs:343`). `git grep` at the head finds no caller. Remove them. - **Fragile caller attribution:** `called_from_list` records the return site with a fixed `skip = 3`. The comment explains it as `called_from_list`, then `recorded_op` (`#[inline(never)]`), then the `list.rs` op function (kept from a sibling call by `std::hint::black_box(&started)`), then its caller. That depends on `with_state` / `measure_call` being inlined (`#[inline(always)]` is a strong hint, not a guarantee under every profile or LTO setting) and on `black_box` defeating tail calls. If either changes, the report names the wrong frame with no error. Capture the return address at the extern entry (`list.rs` op functions) and pass it down, or check the resolved symbol in a test, so a shift is caught. - Size: most of the `list.rs` churn is mechanical (each entry wrapped in a named op). It is reviewable, but a split into "name the ops" and "pipeline + caller site" would have been easier to audit. - Tests: `timeline/report.rs` gains report-format tests. Kal0s-design ran the suites natively on an NVIDIA card and on WARP, including several recording threads and the play profile. **Process** - Claim and AI disclosure (Gemini 4 Carbon author, Gemini 4 Neon reviewer) are present. **Verdict: defects (minor).** Remove the `#[allow(dead_code)]` functions, and make the caller-site skip robust or covered by a test. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
zmasi commented 2026-12-02 19:39:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-02T19:39:52Z.


Thanks @MoonEyes for the sharp catch on both points! Addressed in c9f63c3b85 (merged with current origin/main):

  1. Removed dead code (AGENTS.md): deleted copystat::recorded (copystat.rs) and timeline::called (timeline/record.rs) along with their #[allow(dead_code)] attributes (0 remaining callers).
  2. Structural .pdata caller attribution + --profile play COM vtable test (list.rs, copystat.rs, timeline/record.rs):
    • Replaced with_state / measure_call wrapper functions with with_state! / measure_call! macros expanding directly inside all 41 timed list.rs entry points (eliminating intermediate helper frames across all profiles/LTO), passing [entry_fn, optional_wrapper_fn] function-pointer anchors down to timeline::called_from_list on the >= 50 us slow path.
    • resolve_list_caller_in uses RtlLookupFunctionEntry [BeginAddress, EndAddress) .pdata bounds to step past contiguous list.rs entry/wrapper frames (falling back to recorded_op's immediate caller when an entry is inlined or tail-called, and degrading cleanly when .pdata is absent) instead of relying on fixed skip = 3.
    • Added unit tests for all 8 unwind/inlining/tail-call/missing-.pdata shapes (resolve_list_caller_handles_inlining_wrappers_tail_calls_and_missing_pdata) and updated long_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modes to invoke real COM vtable extern "system" slots (SetPipelineState, tail-position OMSetStencilRef, and ResourceBarrier) plus external from #[inline(never)] callers, verifying Event.a.saturating_sub(1) resolves inside each caller's .pdata [BeginAddress, EndAddress) in both dev (20/20 timeline::, 4/4 copystat::) and --profile play (13/13 timeline::record::, 4/4 copystat::, 12/12 list::).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7356528776 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7356528776). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-02T19:39:52Z. --- Thanks @MoonEyes for the sharp catch on both points! Addressed in `c9f63c3b85` (merged with current `origin/main`): 1. **Removed dead code (`AGENTS.md`)**: deleted `copystat::recorded` (`copystat.rs`) and `timeline::called` (`timeline/record.rs`) along with their `#[allow(dead_code)]` attributes (`0` remaining callers). 2. **Structural `.pdata` caller attribution + `--profile play` COM vtable test (`list.rs`, `copystat.rs`, `timeline/record.rs`)**: - Replaced `with_state` / `measure_call` wrapper functions with `with_state!` / `measure_call!` macros expanding directly inside all 41 timed `list.rs` entry points (eliminating intermediate helper frames across all profiles/LTO), passing `[entry_fn, optional_wrapper_fn]` function-pointer anchors down to `timeline::called_from_list` on the `>= 50 us` slow path. - `resolve_list_caller_in` uses `RtlLookupFunctionEntry` `[BeginAddress, EndAddress)` `.pdata` bounds to step past contiguous `list.rs` entry/wrapper frames (falling back to `recorded_op`'s immediate caller when an entry is inlined or tail-called, and degrading cleanly when `.pdata` is absent) instead of relying on fixed `skip = 3`. - Added unit tests for all 8 unwind/inlining/tail-call/missing-`.pdata` shapes (`resolve_list_caller_handles_inlining_wrappers_tail_calls_and_missing_pdata`) and updated `long_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modes` to invoke real COM vtable `extern "system"` slots (`SetPipelineState`, tail-position `OMSetStencilRef`, and `ResourceBarrier`) plus `external` from `#[inline(never)]` callers, verifying `Event.a.saturating_sub(1)` resolves inside each caller's `.pdata` `[BeginAddress, EndAddress)` in both `dev` (`20/20` `timeline::`, `4/4` `copystat::`) and `--profile play` (`13/13` `timeline::record::`, `4/4` `copystat::`, `12/12` `list::`).
MoonEyes commented 2026-12-02 22:01:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:01:07Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360107546 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7360107546). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:01:07Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
fiestorra commented 2026-12-02 23:15:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:15:15Z.


VERIFY-3136 — Windows nativo: 41 pruebas de list y el control muerde el resolutor; el módulo pide diagnostics

Own commits 985661b34, c9f63c3b8 — list.rs (+752/−…), timeline/{record,report}.rs, copystat.rs
Head 74bd1bcd4 (the branch also merges main)

Ran

cargo test -p leonida-gpu --lib list                       41 passed; 0 failed; 8 ignored
cargo test -p leonida-gpu --lib --features diagnostics long_list    2 passed
cargo test -p leonida-gpu --lib --features diagnostics resolve_list_caller ... ok

The trap again, third time tonight: timeline::record and timeline::report are #[cfg(all(windows, feature = "diagnostics"))]. Without the feature the resolve test does not exist, and cargo test -p leonida-gpu --lib resolve_list_caller answers 0 passed; 762 filtered out with exit 0 — "no test" for a test that is there.

Negative control, and my first attempt was wrong: I disabled the Win32 .pdata lookup (RtlLookupFunctionEntry) and the test still passed — because the test drives resolve_list_caller_in, the pure resolver, with synthetic ranges; the Win32 call is not on its path. A control that does not change what the test exercises proves nothing. Moved into the resolver:

FAILED: resolve_list_caller_handles_inlining_wrappers_tail_calls_and_missing_pdata
assertion `left == right` failed

It bites.

What the change is: on a list call deeper than DEEP, the runtime now captures a short stack walk and resolves the caller structurally through .pdata function ranges, recording the op, the caller site and the bound pipeline — and the report formats them in both stall and timed modes. The doc comment explains why .pdata and not the stack alone: inlining and wrappers make the frame above called_from_list the wrong answer, and a tail call can remove it entirely — which is exactly what the resolver's four cases in the test name cover.

What I could not test: the attribution in a real slow list call under the title — the resolver and the formatting are unit-tested, the walk itself is not.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361757773 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7361757773). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:15:15Z. --- ## VERIFY-3136 — Windows nativo: 41 pruebas de `list` y el control muerde el resolutor; **el módulo pide `diagnostics`** | | | |---|---| | Own commits | `985661b34`, `c9f63c3b8` — `list.rs` (+752/−…), `timeline/{record,report}.rs`, `copystat.rs` | | Head | `74bd1bcd4` (the branch also merges `main`) | **Ran** ``` cargo test -p leonida-gpu --lib list 41 passed; 0 failed; 8 ignored cargo test -p leonida-gpu --lib --features diagnostics long_list 2 passed cargo test -p leonida-gpu --lib --features diagnostics resolve_list_caller ... ok ``` **The trap again, third time tonight**: `timeline::record` and `timeline::report` are `#[cfg(all(windows, feature = "diagnostics"))]`. Without the feature the resolve test **does not exist**, and `cargo test -p leonida-gpu --lib resolve_list_caller` answers **`0 passed; 762 filtered out`** with exit 0 — **"no test" for a test that is there**. **Negative control, and my first attempt was wrong**: I disabled the **Win32 `.pdata` lookup** (`RtlLookupFunctionEntry`) and the test **still passed** — because the test drives **`resolve_list_caller_in`**, the pure resolver, with synthetic ranges; the Win32 call is not on its path. **A control that does not change what the test exercises proves nothing.** Moved into the resolver: ``` FAILED: resolve_list_caller_handles_inlining_wrappers_tail_calls_and_missing_pdata assertion `left == right` failed ``` **It bites.** **What the change is**: on a list call deeper than `DEEP`, the runtime now **captures a short stack walk and resolves the caller structurally through `.pdata` function ranges**, recording **the op, the caller site and the bound pipeline** — and the report formats them in both stall and timed modes. **The doc comment explains why `.pdata` and not the stack alone**: inlining and wrappers make the frame above `called_from_list` the wrong answer, and a tail call can remove it entirely — which is exactly what the resolver's four cases in the test name cover. **What I could not test**: the attribution **in a real slow list call under the title** — the resolver and the formatting are unit-tested, the walk itself is not. Written with an AI assistant.
MoonEyes commented 2026-12-03 00:02:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T00:02:09Z.


RUN (in game, batch of nine pull requests), each head merged with git merge --no-ff onto main 81efe4566, in one build: #3136 74bd1bcd4, #3156 53c3100ce, #3206 d024194b3, #3248 efd21d867, #3256 e7aad1d4c, #3262 3643c2879, #2851 b83b0b375, #3125 89bf1d328, #2642 164506d01. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 15.6, mean 15.6
Rendered fps, last 120 s median 14.3
Time under 5 fps in the world 3 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. The precompile before the world took 619 s, against 157 s for the previous batch; the shader-side changes in this batch (#3156, #3262) probably left the pipeline cache cold (not checked). Switches that are off by default (for example #2851's LEONIDA_TITLE_MEMORY_SCALE, #3136's timeline attribution) were not turned on: this run covers their default path only. #2642 targets Wine and was run on Windows only.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362719660 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3136#issuecomment-7362719660). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T00:02:09Z. --- RUN (in game, batch of nine pull requests), each head merged with `git merge --no-ff` onto main `81efe4566`, in one build: #3136 `74bd1bcd4`, #3156 `53c3100ce`, #3206 `d024194b3`, #3248 `efd21d867`, #3256 `e7aad1d4c`, #3262 `3643c2879`, #2851 `b83b0b375`, #3125 `89bf1d328`, #2642 `164506d01`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 15.6, mean 15.6 | | Rendered fps, last 120 s | median 14.3 | | Time under 5 fps in the world | 3 % | For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. The precompile before the world took 619 s, against 157 s for the previous batch; the shader-side changes in this batch (#3156, #3262) probably left the pipeline cache cold (not checked). Switches that are off by default (for example #2851's `LEONIDA_TITLE_MEMORY_SCALE`, #3136's timeline attribution) were not turned on: this run covers their default path only. #2642 targets Wine and was run on Windows only. AI-assisted (Claude Code).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3136:upstream-pr/3136'
git switch 'upstream-pr/3136'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3136'
git switch 'upstream-pr/3136'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3136'
git switch 'upstream-pr/3136'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3136'
git switch 'main'
git merge --squash 'upstream-pr/3136'
git switch 'main'
git merge --ff-only 'upstream-pr/3136'
git switch 'main'
git merge 'upstream-pr/3136'
git push origin 'main'
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!3136
No description provided.