d3d12: 522 host pipelines still made during play freeze the picture 1 to 2.6 s each (RTX 5080, Series S), with shaders and warm --used already complete #3103
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Reference
No Branch/Tag specified
Notifications
3 participants
Due date
No due date set.
Reference
leonida/mandy#3103
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
What happens
Even with every shader of the title coming out of the translation cache in 1 s and
warm --useddone, an 8 1/2 minute run still makes 522 host pipelines while the title plays
(
host pipeline library saved ... made=522 loaded=2814), and each of the big ones freezes thepicture for 1 to 2.6 s while
SHADERS COMPILING: n LEFTstands next to the frame rate.Commit
30742ccb1of my forkldx-007/mandy, which is upstreammainat393901a5bplus two.github/workflows/commits only (no runtime file touched). The exe is that workflow's build ofthe
diagprofile,built-with.txt=diagnostics,dlss,mimalloc.System
Windows 11 Insider build 26300 x64, Ryzen 7 9800X3D, 64 GB, RTX 5080 16 GB (driver 32.0.16.2124),
HAGS on. Xbox Series package 1.0.2.1, Series S profile, DLSS on.
Where
pipelines
Command and steps
Started through
scripts/play-d3d12.ps1 -Game <the title's folder> -Data <a folder outside the checkout>.leonida shaders <the title's folder>\shaders.rpf, run from a window holding exactly theLEONIDA_*settings that same play start uses (taken fromplay-nvidia.ps1 -DryRun):25687 shaders in the cache, 202 do not translate, 1 s.leonida warm --used:83576 pipelines known, 2966 made before (06d3d9d172e378a7), 0 bad; 0 to make, 10 processesthen
2966 of 2966 in the pipeline library, written in 4 s.Every time the top-left line shows
SHADERS COMPILING: n LEFTthe picture stops for one to threeseconds. Every run: yes. Every run also adds a few hundred pipeline keys the next run then has to
make or load.
Output
start:
end of the same run:
Gaps between two log records of more than 0.5 s: 63, 69.1 s of a 514 s run (13 %). 36 of them
(45.9 s) are closed by a host-pipeline-made line, 19 of those for a compute pipeline. The ten
largest gaps are all of that shape:
(12 other gaps sit exactly at 1.00 s and are most likely the once-a-second reporter, so the count
above only takes what the log can attribute.)
The layer's own counts, the worst five seconds of the run:
Adding
frames x ms waiting for pipelinesover all 95 five-second samples of the run:267 thread-seconds waited for pipelines. The fps line goes from 60.1 (menus, loading) down to
0.2, 1.0 and 1.2 in those moments. Over the run
slow-pipelines.txtgrew 449 to 473 lines andearly-pipelines.txt3136 to 3704, while only 36 shader files were written to the cache duringthe whole run - so the translation is not what costs here, making the host pipeline is.
What I would like to ask
warmwithout--used(the 83576 known pipelines) the intended way to reach the steadystate? The launcher only ever runs
warm --used, so a run keeps meeting pipelines that werewritten down but never made; 2966 of them go through in 4 s, so the whole set does not look
unreasonable, but nothing says how long it takes or that it is expected.
slow-pipelines.txtalready knows which keys took over a second.Queue::push_asputs those inthe
slowdeque, which only orders what is queued already, andmake::early()starts one aheadof time only when
wanted_early(key)holds -used(), orLEONIDA_EARLY_ALL=1. Could the keysrecorded as slow join the early-start set when the device is made, so a pipeline that has blocked
a frame once is never awaited again?
LEONIDA_EARLY_ALL=1is what I would try next for a second and later visit of the same ground.Is that the expected way, or does it cost too much at start-up to be more than a debugging step?
Two warnings of the same log, both already reported
Only as another data point, not a new report: #3016 (
LOCAL dynamic descriptor slots on a capped view heap slots=499999 title_in_place=500000andhost view heap capped at 1000000; views past it read a null slot count=1245184) and #2831 (therenderer port 2: a view record in the title's heap that no store told offallback, 8683 lines of it in this log).One more observation, and a different topic (I will open its own issue if you prefer)
In the same windows, the recording threads alone spend 662 to 839 ms a frame on list calls while
the same line says
0.0 on the GPU, at a median of 4086 draws a frame (max 7195). So in the worldthe run looks bound by recording rather than by the card, and a lower render height does not help
that part; I have the 95 samples of
fps,ms/frame,list callsandwaiting for pipelinesifa separate report is wanted.
finding: code walkthrough answering the three questions in #3103 (inspected against
main69cd4106c):Is
warmwithout--used(-PrecompileAll) the intended way to reach steady state?Yes.
warm --usedonly precompiles the keys already recorded inearly-pipelines.txt(3136at start ->3704at exit in your log,+568newly seen keys matchingmade=522). Any new area, LOD, or target/sampler variant encountered during play still has to be compiled on demand until it entersearly-pipelines.txtor the driver cache.Running
-PrecompileAll(leonida warmwithout--used) compiles all known keys fromknown-pipelines.binahead of time into the driver's on-disk cache. Noted3d12/apps/leonida/src/warm.rs:162-173(into_library): even with-PrecompileAll, onlyearly-pipelines.txtkeys are packed intohost-pipelines.bin(never-drawn keys are intentionally left in the driver's own disk cache because packing ~85k entries intohost-pipelines.bincausedDEVICE_REMOVEDon burst loads). Once a newly met key is in the driver cache, its firstCreate*PipelineStateduring play hits the driver cache rather than doing a 1-2.6 s cold DXIL->SASS compile.One extra caveat (
warm.rs:179-189,driver_mark): NVIDIA keys its shader cache by executable filename, so if Smooth Motion is active on your launch (leonida_sm.exe), runningleonida.exe warmmanually populatesleonida.exe's driver cache rather thanleonida_sm.exe's; launching with-PrecompileAllthrough the script keeps them aligned.Should
slow-pipelines.txtjoin the early-start set?Yes -- open PR #3132 (
D3D12-PIPELINE-WAIT-AND-SLOW-EARLY) directly implements this alongside per-pipeline waiter wakeups and priority donation for live draw/dispatch waiters over background early compiles.Should
LEONIDA_EARLY_ALL=1be used for normal play?No -- as noted in
d3d12/crates/leonida-gpu/src/pipeline/known.rs:10-13, starting all ~84k pipelines in-process inside the running game has crashed inside the driver compiler and causes heavy startup CPU/RAM contention. Out-of-processleonida warm(-PrecompileAll) is the intended path because a hanging or crashing driver compile only kills one child worker and records that key inwarm-bad.txt.On the extra observation (
list calls 839.3 ms ... 723.5 ms waiting for pipelines; 0.0 on the GPU):In those windows,
list callsis summed across all recording threads and includes the723.5 msblocked on those synchronous pipeline compiles; while recording threads stall on compiles, the GPU queue drains to0.0 ms. Checking a steady-state 5 s window wherewaiting for pipelinesis0.0 mswill separate real recording-thread overhead from compile-wait inflation (if you still see high recording ms with0.0 mspipeline wait, a separate issue with those steady-state samples would be useful).AI-assisted: yes (Antigravity).
Another data point, with
-PrecompileAll(the launcher's default, which precompiles every known pipeline) instead ofwarm --used. Pipelines thatwarmhad precompiled still got compiled again in play, so on my setup the driver's disk cache isn't keeping whatwarmputs into it. That also bears on question 1 above:-PrecompileAlldidn't get me to a steady state.Setup:
mainat2791b7756,diagbuild (diagnostics,dlss,mimalloc), started throughLauncher.batandplay-nvidia.ps1with Series S and DLSS. There's noleonida_sm.exein the build folder, so precompile and the game both ran asleonida.exe. RTX 5080 16 GB, driver 621.47, Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 26200. Shader Cache Size is Unlimited in the NVIDIA control panel. I may have changed that while run 2 was still going; it was set before run 3 started.I played the same save three times in one evening, from the intro cutscene into the prison prologue. Run 1 had no log, so the table covers runs 2 and 3.
warmhad recorded as made (warm-done.txt)host pipeline library loadedlibrary savedat the endTo check whether the slow ones had been precompiled, I compared keys across the cache files (counts only):
early-pipelines.txtwent from 2,600 to 3,360). 709 of them were inwarm-done.txtfrom that run's own precompile, including both pipelinesslow-pipelines.txtgained in run 3, at 1.9 s and 2.5 s to make.slow-pipelines.txt(median 1.8 s, p90 4.2 s, max 19.8 s) were inwarm-done.txt. That file includes earlier runs, so I'd weigh it less than the run 3 numbers.warmmarked them done without building them, or it built them and the game asks for something that doesn't match. I don't have that run'sN made in X ssummary line to tell which. I'll grab it next run.#3132 (starting slow keys early) and #3150 (building drawn pipelines straight into the library) would cover pipelines that have been drawn before. Neither helps a precompiled pipeline that has never been drawn and misses the driver cache the first time it's used.
AI-assisted (Claude Code). Numbers come from my own logs and cache files; no game data.
With #3172, full warm-up attempts every PSO key recorded before warm-up. Could the first-use report show whether the key was in the warm-up snapshot, what happened during warm-up, and whether the runtime loaded or compiled it? It would also help to record how long the first caller waited.
Synthetic test. A is warmed and ready at first use. B is a new render-target-format variant that is first compiled on demand. C is warmed, then its runtime library lookup is forced to miss and it is compiled again. The report should distinguish all three cases.
A shutdown and reload test would help document
LEONIDA_LIBRARY_PLAY_SAVE_MB. The threshold applies to writes during a run. A library above that threshold should be saved on clean exit and available for the next launch.Synthetic test. Use an isolated cache directory and set the in-session write limit to zero. Create one synthetic PSO, exit through the normal shutdown path, and wait for shutdown to finish. Restart on the same device and assert that the PSO loads from the saved library.
Another data point after a full
warm(no--used), plus a same-machine control from another runtime of the same title.Machine. Windows 11 26H2 (26300.9974), Ryzen 7 5700G, 32 GB RAM, RTX 4070 Ti 12 GB, driver 621.40. NVIDIA Shader Cache Size = Unlimited (set before the warm).
Build. Upstream
maind9b618f10150f275c30088e4769c1acbf1d8d689(includes #3154 and #3230), built from source withd3d12/scripts/build-nvidia.ps1:diagprofile,built-with.txt=diagnostics,dlss,mimalloc, its own cache folder.Steps.
leonida shaders <the title's folder>:25783 shaders in the cache, 202 do not translate, 131 s.leonida warm(full):83553 pipelines known, 0 made before, 0 bad; 83553 to make, 8 processes83553 made in 1978 s (7 have no host pipeline, 0 ended their process); ms each: median 2.2, p90 284.1, p99 4775.3, most 23778.leonida.exe run <title> --execute --console series-x; Series X profile, 2560x1440 output, the title's own dynamic resolution from 0.75,LEONIDA_FRAME_GEN=0(frame generation off), DLSS not used,LEONIDA_THIN=1on 6 threads. 13:02, closed withWM_CLOSE, exit0x00000000.What the run still made. At exit:
host pipeline library saved bytes=296114760 early=3059 made=493 loaded=2595 started_early=2393— 493 host pipelines made while the title played, after the full warm and with the driver cache Unlimited.
Freezes. 129 periodic in-world frame lines (more than 1000 draws): 18 frames over 500 ms, worst 6.3 s; in-world median 56.7 ms at 5.0–7.5k draws. The runtime's own summary in one window:
frame times over 13.0 s, 96 frames: median 48.6 ms, 95th percentile 64.9, 99th 8241.8, longest 8241.8; 1 over 100 ms, 1 over 1 s.Two examples, with the lines around them:
08:06:54.829 4738 ms, 4454 drawsand08:07:05.017 5094 ms, 4458 draws— the twelve lines before each are the runtime's periodic reports only, no pipeline line among them.08:13:01.207 first bind pipeline=... stage="compute"→08:13:01.482 host pipeline shaders=[compute b01e713adfd1b66a]→08:13:05.195 host pipeline shaders=[compute 592680ab38031b20]: one compute build spans about 3.7 s of log.08:13:10.774 host mesh pipeline shaders=[mesh 8a1dba33b00fc298, pixel 428832e0a62f137f masked]— a masked variant built during the same stretch, which matches the masked-twin finding in #3105 (and #3200).Control: another runtime of the same title, same PC, same day. Darner
v2026.12.02.02(fa84f7e6, built from source), DLSS off, frame generation off, its ownwarm(73536 pipelines known,66596 made in 950 s), 12:50 in the world, exit 0. There: 2 frames over 500 ms, worst 1.0 s (host pipelines all made made=78 loaded=2239 started_early=3911), and the two stalls reada pass over the screen was waited for (DARNER_SCREEN_WAIT_MS=0: dropped past half a second a frame) ms=4828 made=true.Caveats. The two runtimes were not on the same camera/scene, so this is not a speed A/B. Mandy drops about 210 draws a frame on purpose in this configuration (skip list and the structure builder off), Darner drops 0, so equal draw counts are not equal work. Card use: Mandy 9.7 of a 10.7 GB budget; Darner 11.7 of 10.9 GB plus 5.1 GB shared.
What I take from it. A full
warmdid not reach a steady state here either, and the freezes that remain line up with #3103's on-demand host pipelines and with #3105/#3200's masked twins. The sibling runtime, whose warm also fills its own pipeline library and which builds 78 host pipelines during the run, does not show them — so it looks less like the driver cache and more like where and when the pipeline is built. Happy to run a build with #3200 or any diagnostic switch you point at (stall timeline,LEONIDA_PIPELINE_WAIT_MS) and report the same numbers.Two pieces of the pipeline-population program are open, both code-complete and tested without the game:
LEONIDA_PIPELINE_FIRST_USE=1): per pipeline,warmed|newxloaded|made|refusedand the first caller's wait, plus a summary whosein-play (new/made)is the count behind "522 made during play". It also says whether aloadedcame from the library or amadewas really a compile. Off by default, no draw-path cost.LEONIDA_LIBRARY_PLAY_SAVE_MB=0. Child 1 saves a named PSO; child 2 loads it (LOADED+1,MADE-1); child 3, with the library file deleted, makes it again. That falsifier is committed in the test.Run request (no game data leaves your machine - keys are hashes):
leonida warm(orwarm --used) against your cache.LEONIDA_PIPELINE_FIRST_USE=1.pipeline first use summary:line and the slowestpipeline first use:rows.That one summary separates the three causes: new keys (dynamic-resolution/target variants or a new area), warmed keys the library did not serve, and driver-cache losses (the case where even a full warm was recompiled). Each needs a different fix, and I would rather build the right one than guess.
Item: D3D12-PIPELINE-FIRST-USE, claimed in #3312.
AI-assisted: DeepSeek V4.1 Flash (OpenCode).
An experimental profile records observed ready PSO recipes and their translated DXIL stage keys. At a normal session end it selects those recipes and stage files, verifies a ZIP and makes it available to the next local session. On the next launch it can reuse the verified snapshot in a fresh cache. The build identity gates the recipe book and driver library. A ready shader already present in the new cache is preserved.
I reproduced the archive lifecycle with generated PSO events and placeholder cache bytes on Windows. The separate restore process recovered only the observed recipe and its stage. The 12 checks also covered a mismatched library receipt, a different build, a corrupt entry, and retention of the previous snapshot after a failed refresh. A later successful refresh included the newly observed recipe. The fixture establishes filesystem behavior and cache selection. Native driver reuse is the hardware test in #3489, and #3490 tracks what is warmed, loaded, or compiled at first use.
Would this profile-scoped persistence be useful as an opt-in launcher follow-up to #3103? The Windows PowerShell reproduction used generated event records and placeholder bytes for a shader, a recipe book, and a native library. Native library restart #3489 · First-use accounting #3490
I checked a generated case in the standalone profile-cache fixture. Two PSO keys reached ready, used the same available generated shader stage, and met the priority wait threshold. The input catalog supplied a recipe for one key. Earlier profile-cache check
Save-MandyLearnedCachekept both keys in the snapshot's observations. The saved recipe catalog andPriorityKeyscontained one key, the one with a recipe. A separatemissing recipecount would show how many observed pipelines still need a recipe before warmup can schedule them.The generated Windows PowerShell fixture passed. AI-assisted.
Two generated checks for an experimental compute PSO path passed on Windows.
Dispatchcan enqueue its compute PSO ahead of replay. Two unit tests verified the shared queue budget and recipe deduplication. A requested job could overtake the early work with a single build.The archive check exercises
Import-MandyPipelineArchive. It gives a regression case for a possible launcher integration. The queue checks cover the compute scheduling path independently. Earlier cache fixtureAI-assisted.