d3d12/timeline: attribute slow command-list ops, caller sites, and bound pipelines in stall and timed traces (D3D12-TIMELINE-STALL-LIST-OP) #3136
Open
github-bot
wants to merge 5 commits from
github-bot/gh-3136 into main
AGit
pull from: github-bot/gh-3136
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3136
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3136"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zmasi on GitHub · 2026-12-02 13:33 UTC · original
zmasi:feat/d3d12-timeline-stall-list-op→main· +1666 −359 · 5 files · 5 commits · openClaimed in the coordination issue as:
D3D12-TIMELINE-STALL-LIST-OP(#2570)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:"a long list call"blindness in#3105:timeline::record::calledemitted generic"a long list call"withEvent.a = 0andEvent.b = 0, while gatingstack()behindtimed_on()so stall mode (STACKunallocated,Event.stack == 0) retained zero operation, callsite, or pipeline context.list.rsonly timedwith_stateclosures anonymously and left non-with_statehost-list recording methods (ResourceBarrier,BarrierGroups,Sync,CopyBufferRegion,CopyResource,CopyTextureRegion,ResolveSubresource,ClearRenderTargetView,ClearDepthStencilView,CopyMemoryToMemoryX, andWaitValue/WaitValue64list cuts) untimed.timeline::reporthad no long-list-call section insummary_stall_with_freqand ignoredEvent.a/Event.bon long-list-call spans in Chrome JSONargs.copystat.rs,list.rs,timeline.rs,timeline/record.rs):copystat::recorded_op(started, op, pipeline)gatingtimeline::called_from_list(took, op, pipeline)behindtimeline::on(), adding zero call overhead when timeline recording is off.bound_pipeline: AtomicUsizeat the end ofList(preservingoffset_of!(List, put) == 0x18andoffset_of!(List, pipeline_shadow) + 32 == 0x560) across creation,Reset,SetPipelineState,Close,detach, anddetach_parts.with_statecallers with static"a long list call: <Op>"and wraps non-with_statehost-list recording operations (ResourceBarrier,BarrierGroups,Sync, copies, resolves, clears, andWaitValue/WaitValue64cuts) once viameasure_call+with_state_untimedwithout double-counting, usingblack_box(&started)and alignedexternal/upscale->run_external/upscale_nowframe depth soRtlCaptureStackBackTrace(3, 1, ...)resolves the list op's caller (thin::translate/thin::run_plainor title callsite) identically indevand optimized (diag) builds without touchingSTACK(Event.stack == 0in stall mode andsize_of::<Event>() == 64preserved).timeline/report.rs):Trace::doing/chain_stallattributes stall chains directly to"a long list call: <Op>".summary_stall_with_freqadds"list calls of 50 us or more in trigger interval: who, op, caller site, bound title pipeline", formattingEvent.bin hex ({:#x}, matching the hex value ofpipelinein"first bind"log lines).chrome_inneremits"op","at","site", and"pipeline"inargsfor long-list-call spans (preferringEvent.stackin timed mode and falling back toEvent.a).Tested
985661b34ontoorigin/maind0bf821fa):python -I scripts/red_green.py HEAD --no-fetch --no-python(with--features diagnosticstimeline::runner):verdict: red then green(2/2new testsred -> green,17/17existingtimeline::tests pass on both).x86_64-pc-windows-msvc):cargo test -p leonida-gpu --features diagnostics --lib --target x86_64-pc-windows-msvc timeline::(devand--releaseopt-level=3):19 passed, 0 failed(verifies exact caller identity via PE.pdataRtlLookupFunctionEntryin both unoptimized andopt-level=3builds,Event.stack == 0in 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 failedin bothdiagnosticsand default builds.cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc:0warnings in touched files.python -I scripts/check_no_game_data.pyandpython -I tests/test_text_write_line_endings.py: exit0.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=3sibcall frame-depth alignment and zero-overhead!timeline::on()gate).Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.@Kal0s-design on GitHub · 2026-12-02 17:01 UTC · original
Ran natively on Windows 11, head
0518fc48emerged intomain(43fc605ed, merges cleanly; still merges cleanly into today's5b1fff821), on an NVIDIA card and on WARP. Besides the suites, I checked what the body does not cover: theplayprofile (thin LTO, one codegen unit), several threads recording at once, the bounds, the cost, and the reports.Suites on the merge. MEASURED.
leonida-gpu --lib --features diagnostics, cardleonida-gpu --lib(no diagnostics)long_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modes,--profile playtimeline::+copystat::,--profile playreal_waits_are_recorded_with_who_ended_themfails, and fails the same way onmainunderplay: a symbol-name check, unrelated to this PRclippy -p leonida-gpu --all-targets, with and without diagnosticsCaller 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 200externalcalls of about 100 us. Every retained event was checked:Event.aresolved through.pdatato that thread's caller, andEvent.bwas that list's pipeline. MEASURED.So attribution holds under concurrency and with thin LTO. What is lost is lost whole: the stall ring's
try_lockdrops the event (and counts it indropped_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_calldirectly 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 timedwith_stateinside ameasure_callclosure. 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.
EVENTS+ 5,000 slow callsSTACKS(65,536); stall mode leavesEvent.stackat 0 throughoutNo new buffer:
LIST_RUNis oneCellper 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.mainSyncResourceBarrierClearRenderTargetViewTurning the timeline on (stall mode, calls under 50 us) costs nothing I can see over it being off. Against
main,Syncis the same. The barrier and the clear came out about 70 and 200 ns slower at the median. Those two are now timed (twoInstantreads andrecorded_op) where they were not before. But themainand 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.mainSyncResourceBarrierClearRenderTargetViewCopies, resolves, clears, barrier groups and value waits are now timed, and nested
with_statecalls 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.mainthe 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::translateor 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 witha == 0gives"at":"","site":"0x0","pipeline":"", which is valid. MEASURED.Smaller things (READ IN CODE).
copystat::recordedandtimeline::calledhave no callers left and are kept with#[allow(dead_code)]. A test still callscalledwith its own frame depth (skip 1), whilerecordedwould go throughcalled_from_listwith skip 3, one frame too far for a direct caller. Removingrecordedavoids that trap.git merge-treeagainst #2834's head conflicts inleonida-gpu/src/list.rs. #2834 adds two-argumentwith_statecalls (targets_writtenin clear, clear-depth and resolve, and itswait). 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
diagprofile itself (dev,playand the body's opt-level 3 runs bracket it).GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:18 UTC · original
Verification of #3136 (third party, code review on Linux; not built: Windows-only
leonida-gpu)0518fc48eb705382fd1d60cf5975c0ac476c4a5c(5 files:list.rs,copystat.rs,timeline.rs,timeline/record.rs,timeline/report.rs; +1054/-297).128648cfe.git merge-tree --write-tree origin/main pr/3136againstmain45dc41f95is clean(70 commits behind). CI on the head: 6/6 success.
python -I scripts/check_no_game_data.pyon the 5 files: exit 0.Review
caller's return site and the bound title pipeline. Each
list.rsentry point goes throughwith_state(this, "<op>", ..)ormeasure_call, and the pipeline is tracked in a new per-listbound_pipelineatomic (set inset_pipelineandreset, cleared on close).#[cfg(feature = "diagnostics")]. In non-diagnostics builds the onlyaddition is a relaxed
AtomicUsizestore perSetPipelineStateandReset, which is negligible.Kal0s-design checked the
playprofile.copystat::recordedandtimeline::calledno longer have callers.They are kept with
#[allow(dead_code)](copystat.rs:1090,timeline/record.rs:343).git grepat the headfinds no caller. Remove them.
called_from_listrecords the return site with a fixedskip = 3. Thecomment explains it as
called_from_list, thenrecorded_op(#[inline(never)]), then thelist.rsopfunction (kept from a sibling call by
std::hint::black_box(&started)), then its caller. That depends onwith_state/measure_callbeing inlined (#[inline(always)]is a strong hint, not a guarantee under everyprofile or LTO setting) and on
black_boxdefeating tail calls. If either changes, the report names the wrongframe with no error. Capture the return address at the extern entry (
list.rsop functions) and pass it down,or check the resolved symbol in a test, so a shift is caught.
list.rschurn is mechanical (each entry wrapped in a named op). It is reviewable, but asplit into "name the ops" and "pipeline + caller site" would have been easier to audit.
timeline/report.rsgains report-format tests. Kal0s-design ran the suites natively on an NVIDIA cardand on WARP, including several recording threads and the play profile.
Process
Verdict: defects (minor). Remove the
#[allow(dead_code)]functions, and make the caller-site skip robust orcovered by a test.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@zmasi on GitHub · 2026-12-02 19:39 UTC · original
Thanks @MoonEyes for the sharp catch on both points! Addressed in
c9f63c3b85(merged with currentorigin/main):AGENTS.md): deletedcopystat::recorded(copystat.rs) andtimeline::called(timeline/record.rs) along with their#[allow(dead_code)]attributes (0remaining callers)..pdatacaller attribution +--profile playCOM vtable test (list.rs,copystat.rs,timeline/record.rs):with_state/measure_callwrapper functions withwith_state!/measure_call!macros expanding directly inside all 41 timedlist.rsentry points (eliminating intermediate helper frames across all profiles/LTO), passing[entry_fn, optional_wrapper_fn]function-pointer anchors down totimeline::called_from_liston the>= 50 usslow path.resolve_list_caller_inusesRtlLookupFunctionEntry[BeginAddress, EndAddress).pdatabounds to step past contiguouslist.rsentry/wrapper frames (falling back torecorded_op's immediate caller when an entry is inlined or tail-called, and degrading cleanly when.pdatais absent) instead of relying on fixedskip = 3..pdatashapes (resolve_list_caller_handles_inlining_wrappers_tail_calls_and_missing_pdata) and updatedlong_list_calls_record_op_caller_site_and_pipeline_in_stall_and_timed_modesto invoke real COM vtableextern "system"slots (SetPipelineState, tail-positionOMSetStencilRef, andResourceBarrier) plusexternalfrom#[inline(never)]callers, verifyingEvent.a.saturating_sub(1)resolves inside each caller's.pdata[BeginAddress, EndAddress)in bothdev(20/20timeline::,4/4copystat::) and--profile play(13/13timeline::record::,4/4copystat::,12/12list::).@MoonEyes on GitHub · 2026-12-02 22:01 UTC · original
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:mainSHA it was merged onto;mainalone 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 on GitHub · 2026-12-02 23:15 UTC · original
VERIFY-3136 — Windows nativo: 41 pruebas de
listy el control muerde el resolutor; el módulo pidediagnostics985661b34,c9f63c3b8—list.rs(+752/−…),timeline/{record,report}.rs,copystat.rs74bd1bcd4(the branch also mergesmain)Ran
The trap again, third time tonight:
timeline::recordandtimeline::reportare#[cfg(all(windows, feature = "diagnostics"))]. Without the feature the resolve test does not exist, andcargo test -p leonida-gpu --lib resolve_list_calleranswers0 passed; 762 filtered outwith exit 0 — "no test" for a test that is there.Negative control, and my first attempt was wrong: I disabled the Win32
.pdatalookup (RtlLookupFunctionEntry) and the test still passed — because the test drivesresolve_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: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.pdatafunction 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.pdataand not the stack alone: inlining and wrappers make the frame abovecalled_from_listthe 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 on GitHub · 2026-12-03 00:02 UTC · original
RUN (in game, batch of nine pull requests), each head merged with
git merge --no-ffonto main81efe4566, in one build: #313674bd1bcd4, #315653c3100ce, #3206d024194b3, #3248efd21d867, #3256e7aad1d4c, #32623643c2879, #2851b83b0b375, #312589bf1d328, #2642164506d01. 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.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;
-PrecompileUsedwas 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'sLEONIDA_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).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.