Skip to content

Pipeline cache does not cover the runtime's pipeline libraries: 197 built on demand, 55 -> 9 fps, geometry never submitted (RTX 4060 Laptop 8 GB) #2585

Not planned

Description

@YUYING234

First: thank you for the build and the docs. What follows is a complete build and three runs on an 8 GB laptop card, and one thing I think is worth a look because it is not what the README predicts.

Setup

  • 4a54aed (main, 28 Nov), built by make_game.py to D:\Leonida with --work D:\Leonida-work.
  • RTX 4060 Laptop 8 GB, i9-14900HX, 32 GB DDR5, Windows 11 build 26300, driver 621.01.
  • Runtime rebuilt with -FetchSdl3 because the first build served no input devices at all (gameinput: served without SDL3 (no devices; E_NOTIMPL for every other slot)). After that the pad sits on player 1 and presses register.
  • Xbox Series package 1.0.2.1, --display-mode 1920x1080.

Stages, for the record: assets 343,327 models exported (0 failed, 24 min, 223 GB), 26,503 shaders translated, pipelines 26,555 modules ok, 0 failed, 0 skipped in 84 min, pipeline_cache.bin 4.08 GB.

What the runs do

Everything the README describes works: the launch movie plays, the first-run pages respond to the pad, and the run gets past them. Frames are 50-60 a second and the picture is correct.

Then it stops being like that, and geometry is never submitted again. Every sampling of the submit-phase line in two runs reads geometry 0.00 (0) - 27 of 27 samples in one run and 82 of 82 in another, never non-zero. The frames keep coming (52 fps with 523 submissions in 5.0 s) but they carry no geometry, so the window is a black rectangle that does not change a pixel (two screenshots four minutes apart hash identically).

That may simply be where the port is - your README says a first world frame has not been verified on any test machine - and if so this is just another data point for it on an 8 GB card. But two things around it look like a separate problem, which is why I am writing.

1. The pipeline cache does not cover what the runtime asks for

I finished the pipeline stage to 100 % before these runs, and it still compiles 197 pipeline libraries on demand:

compute pipeline library/lib_cs_01394 (210556 B SPIR-V, warmup) build starts at t=125.602 s
compute pipeline library/lib_cs_01018 took 2.5 s to build (211416 B SPIR-V)
... 197 records in one run

My reading is that vk_pipeline_check builds individual pipelines, while the runtime builds linked pipeline libraries (library/lib_cs_NNNNN), and the cache therefore cannot serve them. If that is right, the offline check cannot remove this cost no matter how long it runs, and it would be worth the checker building the libraries too (or the runtime consulting the cache by library hash).

2. The frame rate collapses exactly when those builds start, and the run dies

t<113 s    50-60 fps      launch movie and pages
t=113 s    11.77 -> 4.07 fps
t=125.6 s  first library build starts
t=153-187 s lib_cs_01056, 01048, 01542, 01410, 01405, 01543 ...
t~190 s    unhandled exception 0xc0000005: writing the session pipeline cache before the process ends
           one pipeline build still running at exit

At the crash the card held 7,766 MiB (the 4060 Laptop reports a budget near 6,400 MB) and the process 18.8 GB of working set. The same signature came from two earlier runs on the same build with the cache only 79 % done, at t~163 s. So a complete cache changed the timing but not the outcome.

What I am asking

  1. Is building pipeline libraries on demand the intended path, and is there a switch or an offline step that pre-builds them?
  2. Is the geometry 0.00 (0) a known consequence of the pipeline that runs before the world - i.e. the documented "no world frame yet" - or does it point at something in this tree?
  3. Is the 0xc0000005 at exit a fault in the session-cache write, or is that message only the handler describing what it was doing? The wording reads like the latter to me, but I would rather ask than guess.

I have the full logs (run-20261128-193908.log, run-20261128-223025.log, run-20261128-223511.log), the checker output and the three screenshots, and can attach or paste whatever is useful. The machine is idle now and I can run anything you want measured.

Activity

  1. Maticcm commented on Nov 28, 2026

    @Maticcm
    Contributor

    I checked the source at your build, 4a54aedcb6b66525e0c9f72a6ea10263337c9141. The offline stage passes the root SPIR-V directory to vk_pipeline_check, which reads that directory's index.json. The stage separately seeds the bvh index. The runtime also loads separate compute indexes under library/ and fspx_compute/; the offline stage at this revision never passes those directories to the checker. So the root checker tally does not establish that those runtime compute entries were seeded. Offline stage · Checker index · Runtime indexes

    #2392 is already working on this gap by having the pipeline stage call the runtime's own precompiler and populate its journal. This was a source check. I have no measured cache-hit rate or evidence tying the cache gap to the missing geometry.

    AI-assisted (Codex).

  2. JoshRob297 commented on Nov 28, 2026

    @JoshRob297

    Intel iGPU data point for this gap, and a case where the helper does not save the run.

    Machine: Intel Meteor Lake iGPU, Mesa ANV 26.2.6, 30 GB RAM, Wine 11.22, Linux. Runtime from main, 1280x720.

    The front-end load requests a library compute program that Mesa takes a very long time to compile:

    submit-lock: held 133019 ms by thread 336, t=11.655..144.674 s
    compute pipeline fspx_compute/lib_cs_00000_caecbbcc... took 125.4 s to build
    

    The title's watchdog (30 s) fires at game+0x2215c35 before that build finishes, so the run never reaches the landing. Memory is not involved (16 GB free, /tmp on disk).

    LEONIDA_COMPILE_HELPER=1 LEONIDA_ASYNC_PIPELINES=1 starts the helper (it journaled its way to 1,824 files), but the title still hits the same watchdog trap: on this program the helper's build does not finish before the watchdog either.

    gta6rt --precompile-pipelines --all --threads 4 --big-threads 1 lists 8,136 compute entries / 12,373 MB of SPIR-V and stays more than 11 minutes on one program (Jindirect_diffuse_lighting_CS_ScreenProbes_ActivateProbes_9083c094_Wrapped, 25,486,392 B). So on Intel/ANV the offline precompile is the only path, and even it is measured in many minutes per large program; the 30 s watchdog cannot be survived at play time.

    Two possible directions: (a) a way to make the title's watchdog tolerate a long first-use build, or (b) an Intel/ANV-specific expectation that these programs must be journaled offline before the first run. Either way, pipeline_cache.bin/journal coverage of the library is what decides whether this GPU boots.

  3. YUYING234 commented on Nov 29, 2026

    @YUYING234
    Author

    Thank you - that is the answer I was guessing at, with the code to back it, and it matches what the runtime log showed from the outside:

    compute pipeline library/lib_cs_01394 (210556 B SPIR-V, warmup) build starts at t=125.602 s
    compute pipeline library/lib_cs_01018 took 2.5 s to build (211416 B SPIR-V)
    ... 197 such records in one run
    

    The run had a complete root cache at the time (26,555 modules ok, 0 failed, 0 skipped, 84 minutes, pipeline_cache.bin 4.08 GB), so those 197 were not the checker's leftovers - they were a population the checker never seeded, exactly as you describe with library/ and fspx_compute/. Good to know #2392 is on it; I will re-run and report a before/after cache-hit count when it lands, if that is useful.

    One more number for the record, since it lines up with JoshRob297's. In our own offline pipeline stage on the RTX 4060 Laptop, the slowest single program was:

    818.70 s  Pindirect_diffuse_lighting_CS_ScreenProbes_ActivateProbesTarget_534f271f_Wrapped
    493.50 s  Mcascadeshadows_rendering_CS_ShadowRenderTiledCascadesCBPPPC_9945271c_Wrapped
    390.31 s  Urtdirectionalshadows_CS_RTShadowTrace32TemporalHQ_OneOver2RPP_Tiled_bfd3b062_Wrapped
    220.77 s  _rtdirectionalshadows_CS_RTShadowTrace32TemporalHQ_..._TiledFarOnly_878e50eb_Wrapped
    

    That is 13.6 minutes for one program on an NVIDIA card with 24 checker threads, so an Intel/ANV figure of 11+ minutes for the sibling ActivateProbes_9083c094 is the same order - this is not an ANV peculiarity, it is the program.

    What we could not settle. With the root cache complete the run still ended at about t=190 s with unhandled exception 0xc0000005 while one library build was still running, and geometry read 0.00 (0) in every one of 27 samples across the run - the title never submitted geometry in that phase. I have no evidence that connects the cache gap to that, which is why I am not claiming it; if #2392 makes the library builds go away, that run becomes the clean test of whether the geometry shows up without them.

  4. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    MEASURED, on an RTX 4090 with the corpus cache this build produces, and READ IN CODE in the runtime: the session cache is never written, and the reason is a cap rather than a missing feature.

    1. The writer refuses the file. Every run of mine logs:
    [rt] d3d12: pipeline cache is 4875748145 bytes, over the 268435456-byte write limit
    

    So pipeline_cache.session.bin is never created, and every boot recompiles exactly what you are seeing (197 libraries
    on demand). My own numbers for the same effect: single compute libraries at 17.8 s, 20.0 s and 29.7 s of build time.

    1. LEONIDA_PIPELINE_CACHE_BYTES does not fix it. Setting it to 6000000000 changes the line to
    [rt] d3d12: pipeline cache is 4875832367 bytes, over the 536870912-byte write limit
    

    536,870,912 is 512 MiB, and that is the cap applied to a checkpoint write in runtime/shims/d3d12_vulkan_device.cpp:

    if (checkpoint) limit = (std::min)(limit, std::size_t{512} << 20);

    The environment variable only lifts the limit of a non-checkpoint save, so the checkpoint path clamps it. A corpus-sized
    seed (4.87 GB here) therefore cannot produce a session file by construction, with or without the variable.

    1. What this means for your 197 libraries: the compile cost you are paying every run is not a warm-up that fails to
      persist through a bug - it is a save that is refused for size. The three ways out I can see are raising the cap (with the
      cost of writing ~5 GB at a checkpoint, unmeasured), seeding from something under 512 MiB, or writing only new entries -
      and the code's own comment argues the last one is the only incremental answer, since "a prefix is not an incremental
      cache".

    What I have not measured: whether a session file written with the cap raised actually absorbs those compiles, and what
    writing 4.87 GB mid-run costs. Both need the cap raised first, which is a code change; I have a knob for it in a
    measurement tree (LEONIDA_PIPELINE_CACHE_CHECKPOINT_BYTES) but no PR, because I have not run the A/B that would say it
    helps.

    If it is useful, the check that decides it is one variable: same run, one with the cap raised and one without, and see
    whether the second boot still builds those libraries.

    Written with an AI assistant.

  5. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    That last measurement is the important one, and it matches what I see on this machine: with a complete root cache the
    run still ends around t=190 s with an unhandled exception. So once the compiles are out of the way, what is left is the
    failure I have been chasing, and it is not the cache.

    For the record, on an RTX 4090 my runs end between 105 s and 288 s, and every one of them ends with this in the Windows
    Application Error log:

    Exception code: 0xc0000005
    Fault offset: 0x00000001423cf683
    Faulting module name: unknown
    

    0x1423cf683 - 0x140000000 = 0x23cf683 is inside the title's own image (mapped at 0x140000000), and the instruction
    there is a store to address 0: the compiler's encoding of a deliberate trap, not a corrupted pointer. In other words
    the title is deciding to die, not falling over.

    Two different things produce that ending on my side, and they are worth telling apart because only one is a GPU problem:

    • a VIDEO_ENGINE_TIMEOUT_DETECTED (bugcheck 141, nvlddmkm.sys) leaves a dump in
      C:\Windows\LiveKernelReports\WATCHDOG\WATCHDOG-*.dmp at the time of the run - the engine stopped responding, and the
      title then reaches its trap;
    • with no such dump, the trap still happens, so there is a second path to it that does not need a GPU hang.

    If your t≈190 s exception has no watchdog dump beside it, you are in the second case, and the question becomes which call
    the title treated as unrecoverable. That is currently an open item on the runtime side, not a cache one.

    One caveat on my side: I have only reproduced this on NVIDIA, never on an AMD card, so the RDNA3 path may well differ.

    Written with an AI assistant.

  6. merzleckeier commented on Nov 29, 2026

    @merzleckeier
    Contributor

    Checkpoint-limit cross-check for the 512 MiB diagnostic. The old writer can produce that exact message. a0313920c removed the separate checkpoint cap, and 66e96ccea made the limit apply to growth beyond an accepted offline seed. Both commits are ancestors of this issue’s 4a54aedcb as well as cc0f662a7. The current rejection line also reports how many bytes came from the offline seed. Could you share the runtime commit that produced the old diagnostic, or whether the current runtime shows loaded ... bytes from pipeline_cache.bin before the save?

    I cross-compiled the old and current checkpoint writer functions and ran them under Wine 11.22 with synthetic Vulkan callbacks and sparse test files. The old writer rejected the 4,875,748,145-byte snapshot at 512 MiB even with LEONIDA_PIPELINE_CACHE_BYTES=6000000000. The current writer rejected that size with an empty seed at the default, then published and reopened all 4,875,748,145 bytes with an accepted 4,850,000,000-byte seed. The header and end-of-file sentinel matched. A limit one byte below the observed growth and a separate VK_INCOMPLETE result both preserved the previously published file.

    This exercises size accounting and Win32 file publication. Driver serialization cost, automatic checkpoint scheduling, and library hits on the next boot remain unmeasured here. #2392 is still the relevant work for seeding the runtime’s own compute journal. AI-assisted with OpenAI Codex (GPT-6).

  7. YUYING234 commented on Nov 29, 2026

    @YUYING234
    Author

    Answering the checkpoint question with the sequence from our runs, since it happens to span exactly what you are asking about.

    Runtime: 4a54aedcb - the same commit this issue is against, built from main on 28 Nov 12:10 and used for every run below.

    Yes, the current runtime prints the line before the save, and it also merges the session file from the previous run. Our sequence (times local, all run-2026....log):

    18:04  loaded 2959730064 bytes from pipeline_cache.bin
    18:09  loaded 2959730064 bytes from pipeline_cache.bin
           wrote 2960105509 bytes to pipeline_cache.session.bin
           wrote 16279914 bytes to pipeline_cache.heavy.bin  (56 slow builds, 39 others)
    19:39  loaded 3444887983 bytes from pipeline_cache.bin
           merged 2960105509 bytes from pipeline_cache.session.bin
           loaded 16393821 bytes from pipeline_cache.heavy.bin
           wrote 3445268062 bytes to pipeline_cache.session.bin
    22:30  loaded 4385210610 bytes from pipeline_cache.bin
           merged 3445268062 bytes from pipeline_cache.session.bin
    22:35  loaded 4385210610 bytes from pipeline_cache.bin
           merged 3445268062 bytes from pipeline_cache.session.bin
           wrote 4385590689 bytes to pipeline_cache.session.bin   (this is the run that trapped)
    

    So on this machine:

    • nothing was rejected at 512 MiB. The largest load is 4385210610 bytes (4.08 GB), and a session file of 3445268062 bytes (3.21 GB) merged without complaint on the next start.
    • the acceptance and the growth both went through with no LEONIDA_PIPELINE_CACHE_BYTES set at all - the defaults took a 4.08 GB cache and a 3.21 GB merge.
    • the run that trapped wrote 4385590689 bytes to pipeline_cache.session.bin after the exception, and the next start merged it back, which is why the cache grows by roughly the session size each time.

    That may be the difference from the old diagnostic you reproduced under Wine: with a0313920c and 66e96cce in, I never see the cap mentioned in any log line, and no save has been refused.

    What I have not done is run the 512 MiB case deliberately (a cold cache with the cap set low), so I cannot say the current writer handles it - only that the everyday path here neither hits it nor reports it.

    Two things I can add if useful:

    1. The full logs quoted above, plus one from a run with LEONIDA_PIPELINE_CACHE_BYTES set low on a cold cache, to see whether the current writer refuses or grows.
    2. Whether the trap at image+0x23cf683 (as fiestorra identified it: a store to 0, a deliberate trap) correlates with the moment the session cache is written. In our 22:35 run the write is logged after the exception line, but the file was produced, so the handler ran.
  8. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    CORRECTION to my comment above, and it matters for your build specifically: the cap I described is not in your tree. I quoted a
    512 MiB checkpoint clamp and a 256 MiB default from the branch I had been measuring on; both were replaced on main before the commit you
    built.

    On main:

    • runtime/src/pipeline_cache_store.h sets default_save_limit to 4 GiB, and applies it to size - seed - what a session adds
      on top of the offline seed - rather than to the whole blob.
    • runtime/shims/d3d12_vulkan_device.cpp save_session_pipeline_cache now refuses with a different line: "pipeline cache is %zu bytes
      (%zu of them the offline seed), over the %zu-byte write limit for what a session adds".

    When the change landed:

    • a0313920c, 25 Nov 15:27 - "the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT)"
    • 66e96ccea, 26 Nov 02:36 - "the session cache limit counts what a session adds to an offline seed"

    Your build is 4a54aed from 28 Nov, so it includes both. That means the explanation I gave does not explain 197 libraries built on
    demand in your run, and I should not have offered it without checking the tree your commit contains.

    What would settle it on your side, and it is one grep of your own log: does it contain the string "for what a session adds", or the
    older "over the … write limit"? If it is the first, the size cap is not your problem and the session file is being refused or skipped for
    another reason - has_compile_waiter() is the next thing that stops a checkpoint from writing, and a boot that compiles continuously would
    never satisfy it. If your log has neither line and no pipeline_cache.session.bin appears, then the save is not being attempted at all, and
    LEONIDA_STARTUP_CACHE_CHECKPOINTS / the checkpoint timing is where to look.

    The part of my previous comment that stands unaffected: the run that ends at about t=190 s with an unhandled exception, with a complete root
    cache, is a separate failure from the compile cost.

    Written with an AI assistant.

  9. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    Follow-up that answers my own question from the correction above, READ IN CODE on main (8fb9748). The size cap is not why
    you get 197 libraries on demand in a build that already has the 4 GiB limit. This is:

    The session cache is written in three places, and a crashing run reaches none of them. In
    runtime/shims/d3d12_vulkan_device.cpp:

    1. maybe_checkpoint (line 13387) - gated by
      startup_cache_checkpoints_enabled() (line 2168), which is true only if LEONIDA_STARTUP_CACHE_CHECKPOINTS=1 is
      set. Off by default.
    2. device teardown (line 16232) - and it refuses if any build is still running, printing "…pipeline build(s) still running
      at device teardown; pipeline_cache.session.bin not written".
    3. process exit (line 21814), on a detached thread.

    Your run does not exit: it ends with an unhandled exception around t=190 s, so neither teardown nor exit runs, and with the
    env var unset the checkpoint cannot save either. That is a complete explanation of "197 built on demand" that needs no
    size cap: the work is never persisted because the process dies first.

    So the cheap experiment on your side, and it needs no rebuild:

    set LEONIDA_STARTUP_CACHE_CHECKPOINTS=1
    

    and see whether any run produces pipeline_cache.session.bin next to pipeline_cache.bin. If one appears, the next boot
    should build fewer libraries, and the compile cost becomes a one-time cost per boot instead of every boot. If it never
    appears, the reason to look at next is in the same function: a checkpoint is skipped while
    PipelineCompiler::instance().has_compile_waiter() is true (line 13396), and a boot that compiles continuously may never
    be idle at the moment the checkpoint fires.

    Two honest limits on this: I have not run it (no rebuild from main here yet), so it is a prediction from the code, not a
    measurement; and it does nothing for the crash at t≈190 s itself, which stays the separate item.

    Written with an AI assistant.

  10. merzleckeier commented on Nov 29, 2026

    @merzleckeier
    Contributor

    The reported write after the exception matches a path in 4a54aedcb: the fatal exception filter invokes the exit cache writer before forwarding to the registered title filter. That path also works with LEONIDA_STARTUP_CACHE_CHECKPOINTS unset.

    I used the unchanged filter and D3D12/Vulkan cache code from that commit in a Windows fixture under Wine 11.22. With a live device, one synthetic compute pipeline and an empty driver-generated offline seed, the filter published the session cache in 3/3 trials each on RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV Mesa 26.3.1). The same synthetic exception going straight to the title filter produced no session file in 3/3 each. With the runtime filter, each next process read the unchanged offline seed, merged the session file and reported hit=1 for the same pipeline. Cold runs reported hit=0. The journal was disabled for this fixture.

    This verifies the exception-save and reload paths with synthetic inputs. For the reported library workload, an existing LEONIDA_TRACE_PIPELINE_COMPILE=1 run with aggregate hit=0/1/-1 counts for the library entries after the merge would show how many on-demand creates actually missed the Vulkan cache. Counts are enough. The precompile journal coverage in #2392 is separate. AI-assisted with OpenAI Codex.

  11. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    RUN | 2026-11-29 13:39Z and 13:46Z | fiestorra | AI-assisted
    BASE: main at 8fb974878, runtime built here with -DLEONIDA_SDL3_FETCH=ON
    MACHINE: RTX 4090, 24 GB, desktop | driver 32.0.16.2124 | Windows 11 | 63 GB RAM
    RECIPE: the documented session-1 runner + LEONIDA_STARTUP_CACHE_CHECKPOINTS=1, both runs identical
    OS/DRIVER: default TdrDelay; adapter clean before the pair
    TARGET: whether the session pipeline cache, once written, stops the libraries being built on demand (#2585)
    PREDICTED: run 1 writes no session file unless a checkpoint lands; run 2 builds fewer libraries

    MEASURED, and the prediction was wrong in an interesting way:

    run length took N s to build session file device lost
    1 413 s 16 written at the crash, 4.323 GB 0
    2 333 s 18 merged 4,641,625,619 bytes, rewritten to 4,654,707,923 0

    Both runs ended 0xc0000005, as this machine has all day. What matters is the middle column: run 2 merged the session
    cache and still built 18 libraries
    , so loading the file does not stop the compiles.

    Two things this settles:

    1. The file is written even when the run crashes. main has a hook for it - the log says "unhandled exception
      0xc0000005: writing the session pipeline cache before the process ends" - so the missing session file I described
      earlier was a feature of the older tree, not of main.
    2. Persistence is not the problem. With 4.64 GB merged, the same libraries are still compiled. So the claim in Pipeline cache does not cover the runtime's pipeline libraries: 197 built on demand, 55 -> 9 fps, geometry never submitted (RTX 4060 Laptop 8 GB) #2585
      ("the pipeline cache does not cover the runtime's pipeline libraries") is right for a reason that has nothing to do
      with writing the file: the cache the runtime creates does not hold those library entries.

    What it does not establish: why. The obvious candidates are that the libraries are built against a different
    VkPipelineCache than the one that is merged and saved, or that their key changes every boot (shader module bytes that
    differ run to run, or a cache header that invalidates). Both are readable in the code and neither is measured yet.

    One caveat on the counts: 16 against 18 is not a rate - the two runs died at different points (413 s and 333 s) and may
    not have reached the same libraries. The claim that survives is the qualitative one: a merged 4.64 GB session cache did
    not remove the on-demand builds, when a working cache would have removed most of them.

    Next: read where vkCreateComputePipelines for library/lib_cs_* gets its cache handle, and whether it is
    device_.pipeline_cache_handle at all.

    Written with an AI assistant.

  12. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    MEASURED here, and it splits #2585's problem in two: the per-pipeline journal works, and the builds you see are of a different
    kind of object.

    Run 2 on main (8fb9748), same recipe as the run before it, with the session cache from that run already on disk. The runtime's own
    counters, at the end:

    [rt] d3d12: pipeline journal: 800 compute pipeline(s) found in their journal file (so far: 800 from journal files,
                 0 written, 352 from the shared cache …)
    [rt] d3d12: pipeline journal: 1 compute pipeline(s) compiled and written to their journal file
                 (so far: 841 from journal files, 1 written, 361 from the shared cache …)
    

    So on this machine 841 pipelines came from their journal files, 361 from the shared cache, and exactly one was compiled and written.
    pipeline_cache.d holds 849 files, 1,748 MB, and it is where those come from (compute pipelines are journaled one file each).

    What is still built every boot, and is what you are counting, is the other kind of object:

    [rt] d3d12: compute pipeline library/lib_cs_01907 took 4.1 s to build (506020 B SPIR-V)
    [rt] d3d12: compute pipeline library/lib_cs_03279 took 4.2 s to build (509416 B SPIR-V)
    [rt] d3d12: compute pipeline library/lib_cs_01089 took 2.5 s to build (783076 B SPIR-V)
    

    16 of those in one run and 18 in the next, with the merged 4.64 GB session cache present in both. They are named library/… - shader
    library entries - and they are the ones that keep being built, while the individually journaled pipelines are not.

    That reframes the item: it is not "the pipeline cache does not work", it is "the library/… entries are not covered by the journal that
    covers every other compute pipeline
    ". Why is the next thing to read, and the candidates are that these builds go through the warm-up path
    (queue_build(..., warm_bytes)) which may not journal, or that their identity changes per boot.

    A number that may help you check the same on your machine: in your log, the line pipeline journal: N compute pipeline(s) found in their journal file … M written tells you whether the journal is doing its job there at all. If N is large and M is small, your journals are
    warm and the cost is the library/… entries as well.

    One limit worth stating: 16 and 18 are not a rate - the two runs ended at different points (413 s and 333 s), so they need not have reached
    the same set of libraries.

    Written with an AI assistant.

  13. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    CORRECTION to what I said above about those took N s to build lines, and it changes what the cost is: the number is the duration of the
    whole call, not a compile.

    runtime/shims/d3d12_vulkan_device.cpp prints it from one condition:

    out.ms = GetTickCount64() - started;
    if (created == VK_SUCCESS && built && out.ms >= 2000)
        std::fprintf(stderr, "[rt] d3d12: compute pipeline %s took %.1f s to build (%zu B SPIR-V)\n", …);

    and started is taken before the journal file is read and before the shared cache is asked. So a line saying "took 4.1 s to build" is saying
    "this pipeline took 4.1 s to be obtained", which includes a journal load or a hit in the shared cache - both of which can be slow when
    the cache is 4.6 GB - and not necessarily a compile at all.

    The same function records what actually happened, and the run's own counters said it: 841 pipelines from their journal files, 361 from the
    shared cache, and 1 compiled and written
    . With 1 compile in the whole run, the 16-18 lines of "2-5 s" in that log are not 16-18 compiles.

    So the item is narrower than "the libraries are rebuilt every boot". What the numbers support is:

    • the journal is doing its job (841 hits);
    • the shared cache is also answering (361 hits);
    • and there are still 16-18 pipelines per boot whose path costs 2-5 s each, which is a lookup or load cost over a very large cache, not
      code generation.

    That points at the size and the shape of the shared cache rather than at missing entries: a 4.6 GB blob has to be consulted per pipeline, and
    the 4 GiB session limit means it is being saved near its ceiling. Trimming what is kept, or preferring the per-pipeline journal so the big blob
    is asked less, are the two directions I would look at - neither is measured.

    I should not have called those lines compiles without checking where the timer starts. That is the second time in this thread that I read a log
    line more literally than the code behind it allows.

    What would settle it on your side: the pipeline journal: … N from journal files, M written, K from the shared cache line and the number of
    took N s to build lines in the same run. If M and K are small and the "took" lines are many, then your boot really is compiling, unlike
    mine, and the difference between our caches is the thing to compare.

    Written with an AI assistant.

  14. merzleckeier commented on Nov 29, 2026

    @merzleckeier
    Contributor

    I checked the timing boundary in the correction above. On 8fb974878, journal.load(path) runs before started. The measured interval includes the DriverTurn wait and Vulkan cache creation from the journal bytes. The original journal file read is outside it.

    I added a test-only holder for the real submit lock and ran the same synthetic compute pipeline against the same per-pipeline journal, with no shared seed. On RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV Mesa 26.3.1) under Wine 11.22, all warm runs returned Vulkan hit=1. With the lock free, the timer reported 0–1 ms and no slow line in 3/3 runs per GPU. Holding the lock for 2.3 s after the timer started produced the took 2.3 s to build line in 3/3 runs per GPU. The separately timed vkCreateComputePipelines call was below the clock resolution in both arms.

    This isolates one possible source of a slow line. For the retail measurements, the submit-handoff line on the same thread and the per-pipeline feedback can help attribute the time before drawing conclusions about cache size. AI-assisted with OpenAI Codex.

  15. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    CORRECTION, and this one supersedes what I said an hour ago: those slow lines are compilations after all. The new line, built from my
    branch diag/pipeline-slow-line-source, says so on the same warm cache where I claimed otherwise:

    [rt] d3d12: compute pipeline library/lib_cs_01968 took 5.0 s to obtain from a compile (534980 B SPIR-V)
    [rt] d3d12: compute pipeline library/lib_cs_01915 took 4.0 s to obtain from a compile (515596 B SPIR-V)
    …
    

    One run, MEASURED here: 21 lines, all "from a compile", 0 from the shared cache, 0 from a journal file, 91.9 s of total
    compile time, the longest 20.4 s
    . Same run's journal counters: 874 from journal files, 1 written, 379 from the shared cache.

    So my previous message was wrong twice over: I first called these compiles, then "corrected" myself to say they were cache
    lookups, and the instrument I wrote to settle it says they are compiles. The timer does start before the journal load, but
    for these entries the journal load is a miss and the time really is code generation.

    What the numbers now say, and it is the useful part:

    • 21 pipelines are compiled every boot and only 1 is written to its journal file. So 20 of them will be compiled again
      next boot, which is exactly the "197 built on demand" in your report.
    • The decision is in runtime/shims/d3d12_vulkan_device.cpp JournalCache::finish:
      write_ = built && pipeline_journal::should_write(seeded, hit, driver_ms), and in
      runtime/src/pipeline_cache_journal.h:
    inline bool should_write(bool seeded, int hit, std::uint64_t driver_ms) {
        if (!seeded) return true;          // the pipeline is in no file yet
        if (hit >= 0) return hit == 0;     // write only when the creation reported a miss
        return driver_ms >= unreported_compile_ms;
    }

    For a file that already exists, a build is written only if hit == 0. These builds compiled, so either hit came
    back as something else for them, or publish() refused the blob afterwards (it only writes when the cache data is
    between the header size and entry_read_limit).

    So the question is now a single one and it is answerable: what does hit report for a library/… build whose cache file
    already exists, and does publish() then write it?
    I have not instrumented that yet; it is the next thing I will do,
    rather than guessing which of the two it is.

    The branch is not ready for a pull request: the honest thing is to land this line with the print fixed (it is a strict
    improvement - it named the source of every slow call, which is how this correction was possible) and then a second change
    that addresses the missing writes once the cause is measured.

    Written with an AI assistant.

  16. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    CORRECTION, and it removes the alarming part of what I said a moment ago: 20 of those 21 are not silently lost. They are written. My "only 1 written,
    so they recompile forever" was wrong because I read a sampled log line as a total.

    The counter line is printed at thresholds, not every time. Proof from the very run I was quoting, MEASURED:

    • the last journal line of that run says … so far: 916 from journal files, 1 written, 384 from the shared cache;
    • E:\Games\Leonida\pipeline_cache.d went from 849 files to 932 during the same period, 83 of them modified in ten minutes.

    So writes are happening; 1 written is just the value at the moment the line last printed.

    And the instrumented build (diag/pipeline-slow-line-source) says the same thing directly. Its slow lines now carry the flags:

    compute pipeline library/lib_cs_01908 took 5.3 s to obtain from a compile (589216 B SPIR-V; hit 0, seeded 0, written 1)
    compute pipeline library/lib_cs_03429 took 3.5 s to obtain from a compile (601200 B SPIR-V; hit 0, seeded 0, written 1)
    

    All 23 slow lines in that run: seeded 0, written 1. seeded 0 means the entry had no journal file at all when it was
    built, and written 1 means it left one behind.

    What that actually establishes, and it changes the shape of #2585 again:

    • These are first-sight pipelines: each boot meets library/… entries it has never built before, compiles them once, and
      journals them. The journal is growing (932 files and counting), not stuck.
    • So the compile cost is a first-run cost that amortises, as long as the journal directory persists between runs. It is
      not "the cache does not cover the libraries"; it is "the cache has never seen these particular ones yet".

    For your 197 libraries on a build where the pipeline stage was run to 100 %, the question becomes: did that stage populate
    pipeline_cache.d next to the cache, or only the single pipeline_cache.bin blob? A stage that fills the blob does nothing
    for these entries, and the runtime has a knob for the other direction: LEONIDA_PIPELINE_JOURNAL_SEED_DIR seeds journal files
    from a directory, which is what a pipeline stage would need to write for a fresh machine to start warm.

    To check it on your side, one number: how many files are in pipeline_cache.d after your run, and does that number grow
    between runs. If it does not grow, the journal is not persisting (cache directory moved, or the file writes are refused), and
    that is a different bug from the one this thread has been chasing.

    Two of my last three messages here have been corrections of the one before, both times because I read a log line more
    literally than the code behind it allows. The instrumented line is what finally settled it, and that is the change worth
    landing.

    Written with an AI assistant.

  17. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    The change discussed in this thread is written, built and run; what I cannot do is open the pull request, so here it is with
    everything a maintainer needs.

    • Branch: diag/pipeline-slow-line-source on fiestorra/leonida-carry (pushed), commit 9d3f0bc01, based on
      main 8fb974878.
    • Blocker: gh pr create --repo ProjectLeonida/mandy fails with
      GraphQL: fiestorra does not have the correct permissions to execute CreatePullRequest, and git push to both
      ubiquitarianism/leonida and ProjectLeonida/mandy is a 403. My account can read and comment here but not write, so the
      branch sits in the fork until someone opens the pull request or grants access.
    • Item: D3D12-PIPELINE-SLOW-LINE-SOURCE, claimed in the coordination issue.

    What the change does, in one line of output before and after:

    before: compute pipeline library/lib_cs_01908 took 5.3 s to build (589216 B SPIR-V)
    after:  compute pipeline library/lib_cs_01908 took 5.3 s to obtain from a compile (589216 B SPIR-V; hit 0, seeded 0, written 1)
    

    It names the source (a compile, the shared cache, or the pipeline's own journal file) and carries the journal hit, whether
    the cache was seeded from a file, and whether the file was written. No behaviour change and no new knob; the threshold is
    unchanged.

    Tests, with the baselines:

    • python -I scripts/run_semantic_tests.py tests/semantic: 529 files, 6525 tests, 2 files failed
      (test_interp_computed_ij_fallback, test_valu_cvt_f16_int16_m). Both fail the same way on unmodified main
      8fb974878, so they are not from this change.
    • ctest --test-dir runtime/build -C RelWithDebInfo: 528 tests, one failure (xbox_present). Unmodified main's binary
      exits 1 on the same test with present failed (VkResult -11), so that one is not from this change either.
    • Runtime built from the branch and run on the RTX 4090; the line above is from that run.

    Honest note on sequencing: I would normally open the pull request and let CI settle this, but with no write access the
    only thing I can offer is the branch plus these baselines. If a maintainer prefers, the change can also be reproduced as a
    one-hunk patch from the commit message.

    Written with an AI assistant.

  18. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    READ IN CODE, and it explains why a completed pipelines stage does not make a boot warm: the stage writes one file, the shared
    blob, and never the per-pipeline journal that the runtime asks first.

    make_game.py, the pipelines stage:

    cache = os.path.join(out, "pipeline_cache.bin")   # line 2665
    base = [exe, spirv, cache, *jobs_args]

    vk_pipeline_check.exe is given <translated shaders dir> <cache path> and fills that one blob. Nothing in the stage creates or seeds
    pipeline_cache.d, the directory where the runtime keeps one cache file per compute pipeline.

    On the runtime side, pipeline_cache_path() (runtime/shims/d3d12_vulkan_device.cpp:1234) resolves the cache next to the executable unless
    LEONIDA_PIPELINE_CACHE_DIR says otherwise, and the journal directory is derived from it as pipeline_cache.d
    (pipeline_journal_roots). The build order is: the pipeline's own journal file, then the shared cache, then a compile.

    So the two mechanisms are seeded by different things:

    where what fills it
    pipeline_cache.bin (shared blob) the offline pipelines stage and every run, at the 4 GiB accounting
    pipeline_cache.d/<name> (per pipeline) only runs, as each pipeline is first built; LEONIDA_PIPELINE_JOURNAL_SEED_DIR can seed it from a directory

    That means a fresh machine after a 100 % pipelines stage starts with zero journal files, and the first boot compiles whatever the shared
    blob does not answer for. On a machine of mine that is exactly what happened: 23 slow lines, all seeded 0, written 1 - no journal file, so a
    compile, and each one written afterwards (the directory went 849 -> 932 files during that run).

    Two things this does not settle for your run, and both are one command each:

    1. Are the stage and the runtime looking at the same directory? The stage writes <out>/pipeline_cache.bin; the runtime reads next to
      gta6rt.exe unless LEONIDA_PIPELINE_CACHE_DIR is set. If you built with --out D:\Leonida and ran the exe from elsewhere, the blob you
      spent the stage on is not the one the runtime opens.
    2. Does pipeline_cache.d exist and grow in your build, and do your slow lines say seeded 0 or seeded 1? With the diagnostic line in
      diag/pipeline-slow-line-source that is visible directly; without it, the answer is whether the journal's … N from journal files, M written line appears at all.

    Written with an AI assistant.

  19. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    MEASURED here, and it is a way to start warm without the shared blob at all: LEONIDA_PIPELINE_JOURNAL_SEED_DIR works, and the per-pipeline
    journal is independent of pipeline_cache.bin.

    Setup, deliberately isolating the two mechanisms: a fresh, empty cache directory (LEONIDA_PIPELINE_CACHE_DIR, so there is no
    pipeline_cache.bin to answer anything) plus LEONIDA_PIPELINE_JOURNAL_SEED_DIR pointing at a directory of 932 journal files from earlier
    runs. One boot, RTX 4090, main ddfe24fba:

    pipeline journal: 1 compute pipeline(s) found in their journal file (so far: 1 from journal files, 0 written, 0 from the shared cache)
    …
    pipeline journal: 1000 compute pipeline(s) found in their journal file (so far: 1000 from journal files, 406 written, 0 from the shared cache)
    
    • 1,000 pipelines came from the journal, and the shared cache contributed 0 - because there was no shared cache. The seed was doing all
      the work.
    • 406 were compiled and written into the new, writable journal directory (407 files appear there), while the seed directory stayed as it was.
    • 27 calls still took 2 s or more, which is the first-sight cost of the pipelines the seed did not contain.

    What this means for your 197 libraries: a pipeline stage that produced a pipeline_cache.d would make a fresh machine warm through this
    variable. Your stage writes only pipeline_cache.bin today (make_game.py, cache = os.path.join(out, "pipeline_cache.bin")), which is why a
    fresh machine starts with zero journal files and compiles what the blob does not answer for.

    Concretely, two ways to use it now, neither of which needs a code change:

    1. On a machine that has already run the game, copy its pipeline_cache.d next to wherever the runtime expects the cache, and point
      LEONIDA_PIPELINE_JOURNAL_SEED_DIR at the copy. The runtime reads from it and writes new entries to its own directory.
    2. Ask for the pipeline stage to also emit the journal: the runtime already writes one file per pipeline during a run, so the stage's checker is
      the only piece that does not.

    One limit worth stating: the seed is read-only by convention, and resolve_roots refuses a pair of directories that overlap (it compares
    directory identity, not path strings). If you point the seed at the same directory the runtime writes to, the journal is disabled rather than
    half-written - I took that from runtime/src/pipeline_cache_journal.h, and it is what the "invalid or overlapping compute journal directories"
    message reports.

    Written with an AI assistant.

  20. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    Shorter answer than mine above, and it needs no copying of directories: the runtime already has a mode that fills the journal ahead of play.

    gta6rt --precompile-pipelines [--threads N] [--big-threads N] [--all] [--smallest-first] [--limit N] [--min-bytes N] [--max-bytes N] [--filter PART]... [--skip-listed] [--list]

    From docs/d3d12_vulkan.md (line 2823 on main), it creates the Vulkan device as --run does - same LEONIDA_SHADERS, same
    LEONIDA_PIPELINE_CACHE_DIR, same LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH, because those change the journal file names - and builds every
    compute entry of the library through the dispatch path, largest first, on below-normal-priority threads. No game needed, entries with a
    usable journal file are skipped by reading only their header, so it can be stopped and started again. docs/linux_proton.md step 3 describes
    the same thing as the way to fill the journal on Linux.

    That is the tool for your 197 libraries: run it once on that machine and the boot should find them in pipeline_cache.d instead of compiling
    them.

    Where the documented build leaves you stuck: make_game.py --stages pipelines does not use this mode. It runs vk_pipeline_check.exe,
    which fills only pipeline_cache.bin (make_game.py:2665), and grep precompile make_game.py finds nothing. So the documented path produces a
    shared blob and an empty journal, and the runtime asks the journal first.

    And the journal alone is enough, measured here rather than argued: a boot with an empty cache directory (LEONIDA_PIPELINE_CACHE_DIR
    pointing at a new folder, so no blob could answer anything) plus LEONIDA_PIPELINE_JOURNAL_SEED_DIR pointing at 932 journal files from earlier
    runs reported 1000 from journal files, 406 written, 0 from the shared cache. The shared cache contributed nothing and the boot was still warm
    for a thousand pipelines.

    So, for the pipeline stage, the change I would propose to the project is not to teach the checker to journal: it is to have --stages pipelines
    call gta6rt --precompile-pipelines after its blob pass, or to document that users should run it once themselves. The first is a build-order
    question for whoever owns make_game.py, and it is not mine to decide.

    Written with an AI assistant.

  21. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    I said above that gta6rt --precompile-pipelines is the way to warm the journal, quoting the docs. Having run it here, it works - and the
    default order makes the first pass look hung, which is worth knowing before anyone else tries it.

    Verified on this machine (RTX 4090, main ddfe24fba, a fresh LEONIDA_PIPELINE_CACHE_DIR and LEONIDA_SHADERS at the translated
    shaders):

    [precompile] 3 compute entries to build (0.0 MB of SPIR-V; 5448 filtered out, …)
    [precompile] 1/3 library/lib_cs_01309 (3984 B): compiled and journaled in 0.0 s
    [precompile] 2/3 library/lib_cs_03282 (3984 B): compiled and journaled in 0.0 s
    [precompile] 3/3 library/lib_cs_03316 (3984 B): journaled already
    [precompile] done: 2 built (2 compiled, 0 from a cache), 1 journaled already, 0 failed
    

    --smallest-first --limit 3 --threads 2 finished in 4 s and left 2 files in <cache>/pipeline_cache.d. So the mode does what the
    documentation says: it fills the per-pipeline journal without the game.

    The default order is the problem. Without --smallest-first, the same command with --limit 6 picked the largest entries first:

    6 compute entries to build (107.7 MB of SPIR-V …)
    compute pipeline Jindirect_diffuse_lighting_CS_ScreenProbes_ActivateProbes_9083c094_Wrapped (25599888 B SPIR-V …)
    compute pipeline Pindirect_diffuse_lighting_CS_ScreenProbes_ActivateProbesTarget_534f271f_Wrapped (25425976 B SPIR-V …)
    

    After 30 minutes and 20 GB resident it had written no journal file: none of those had finished. I killed it. Those are 25 MB programs
    each, and they are the ones your report is about - 818 s and 493 s for single programs in the offline stage.

    So, practically: --smallest-first in batches (or --filter PART for the ones you care about) turns this into something that finishes and can be
    resumed, rather than a first run that looks stuck on the biggest entry. --limit N does bound the count - the six-entry run did pick six - but
    "six" can mean 107 MB of SPIR-V and an hour.

    One claim I am not making: that the big entries would eventually finish here. I stopped at 30 minutes, so what I know is that they did not finish
    in that time, not that they never do.

    Written with an AI assistant.

  22. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    One check that matters for this thread: the mode I pointed at exists in your build. Your commit is 4a54aed (28 Nov); at that commit
    runtime/shims/d3d12_precompile.h is the implementation ("gta6rt --precompile-pipelines: builds the compute pipelines of the whole translated
    …"), and runtime/src/main.cpp:12 documents the invocation with the same flags I quoted. So the remedy does not need a newer runtime than the one
    you already built - only the shaders stage's output and a GPU.

    Which is worth pairing with the two measurements from above, because together they say what to expect:

    • --smallest-first --limit 3 --threads 2 finished in 4 s and wrote 2 files into pipeline_cache.d;
    • without --smallest-first the same command spent 30 minutes on two 25 MB programs and wrote none. The default order starts with the biggest
      entries, so a cold run looks hung: use --smallest-first, and bound it with --limit or --filter if you want to see progress.

    And the caveat that makes this a per-machine job rather than a distributable artifact: the docs are explicit that the journal names depend on the
    environment the device was created with (LEONIDA_SHADERS, LEONIDA_PIPELINE_CACHE_DIR, and LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH on
    NVIDIA, whose diagnostics config changes the pipelines), and scripts/windows-boot/README.md goes further - it names the executable, so a journal
    built by gta6rt.exe is the one gta6rt.exe boots with. Copying it from another machine's build with a different LEONIDA_DEVICE_FAULT is the
    case where "my journal is full but the boot still compiles" happens.

    If you run it and the boot still compiles those 197, the next thing to compare is the environment of the two invocations, not the files.

    Written with an AI assistant.

  23. lerapeurdu62280-debug commented on Nov 30, 2026

    @lerapeurdu62280-debug

    A related data point from the D3D12 runtime (leonida.exe, not the Vulkan path of this report), on AMD: pipelines that are not covered ahead of time are built in play, and here the driver also refuses to load what the pipeline library saved, so nothing carries over.

    Setup: AMD Radeon RX 6600 8 GB (driver 32.0.21045.29003), Ryzen 5 3600, 32 GB, Windows 11 26300. main at afb511541, built with --profile diag --features diagnostics,mimalloc, started by scripts\play-d3d12.ps1 with its defaults (Series X profile, 2560x1440 output). First start: 25,689 shaders precompiled (200 do not translate) in 138 s; leonida warm --used had 0 pipelines to make (and stopped with os error 3, fixed in #2774).

    What happened:

    • 81 pipelines were made in play by pipeline library: made [compute …], and each one logged (the library did not load it: Paramètre incorrect. (0x80070057)): E_INVALIDARG from loading the library's entry on this AMD driver.
    • 45 of the 81 took over 1 s; most 5-9 s; the longest 171,471 ms for one compute pipeline.
    • After about 13 minutes (around world entry, right after a burst of texture uploads), the device was removed (0x887A0007, DXGI_ERROR_DEVICE_RESET):
      when the host device went: the submitting thread was preparing a submission (nothing of ours was running on the card), of 1 lists, for 2.5 ms; pipeline library: make of … [compute d0130073bb6f7a7d] running for 5556.0 ms, make of … [compute a0ce4bef0ae97c3f] running for 5328.4 ms, make of … [compute 77af7adee63083f5] running for 5228.1 ms, …
      device-removed data; none
      
      Several compute pipeline builds were in flight when it went. Video memory budget at start: 7378 MB.

    Not tried yet: LEONIDA_D3D12_DEBUG=1 to name the command, -SeriesS, or a second start with a warm cache. I can run any of those on this card if it helps.

    AI-assisted (Claude Opus 5.5).

    Contribution : EI S.O.S INFO LUDO

  24. aslan2142 commented on Dec 1, 2026

    @aslan2142
    Collaborator

    Closing this issue because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the report/contribution! If you believe this issue was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions