Shader disk cache never hits, so every run is cold and can trip the title's watchdog #180
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T23:14:56Z.
Reported by @ItsMariusBC in #110, and it matches our runs: a "warm" run still translates everything. In a cold run and a warm run on the same build, every
native shader translationline saidhit=false, andlibrary conversion … from the disk cachewas never true, though the cache folder grew from 517 to 610 files.Why it matters: the first world frame needs about 1,400 shader translations (roughly 108 s of CPU). When that holds the frame for more than 30 s, the title's own watchdog ends the game. It writes to address 0 at
image+0x23cf683, and then the crash reporter faults atimage+0x55e56f8(found by @Olima34 in #15). With a cache that works, only the very first run would risk that.Being worked on: finding which part of the key or the save path is unstable between runs, fixing it with a test, and measuring the hit rate on two runs in a row.
Testers: if you have two run logs of the same commit, a count of
hit=trueagainsthit=falsein each helps.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-26T23:20:01Z.
From my macOS 15.8.2 / M4 Pro 24 GB runs, with the shader cache folder kept between runs:
native shader translationhit=true534049b534049b(plus local, off-by-default texture/watchdog patches)49b5521Run 2 is the warm one, with the same commit as run 1, and it still had no hits.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T23:32:46Z.
A data point that may change the diagnosis: on this Mac the cache does hit, but the log can't show it.
Both lines are logged only when the step takes ≥ 20 ms:
native shader translation(shader_cache.rs,if ms >= 20) andmetal: library conversion … from the disk cache(msc.rs,note). A disk hit almost never takes 20 ms, so the lines that do get logged are nearly alwayshit=false/from the disk cache: false, warm or cold. "hit=false everywhere" doesn't show the cache missing. What tells is the number of those lines.Our counts: Apple M5 Pro, 48 GB, Series S, commit
5267da7c, the same binary throughout,VICTORY_CACHE_DIRpinned to one folder:After the cold run the folder held 21,620 translations and 943
metal/files.One caution on the warm runs above: the cache key includes the translator's source hash (
build()). A warm run with local patches, or on a newer commit, can be a genuinely cold run. A second run of the same binary is the fair check.Logging hits too, or a hits/misses counter at the end of a run, would settle it for everyone.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ItsMariusBC on 2026-11-27T00:04:36Z.
Two runs of the same commit, one right after the other, as asked. Apple M5 Pro, 24 GB, macOS 27.2.1,
b16bd61,--console series-s --seconds 300, windowed. The pull gave a new cache folder, so run 1 started empty; run 2 found 20,200 files (349 MB) in it.native shader translationlineshit=truems, summedlibrary conversionlinesfrom the disk cache: trueThis agrees with @Olima34: the cache does hit here, and the log cannot show it. Nine in ten of the translation lines are gone in run 2, and none of those left says
hit=true. Run 1 was killed with shaders still waiting to be prewarmed (pending=5180in its last report), which is probably why run 2 still has 603.Same picture on the build before (
561e783with #144 and #145): 5,983 lines cold, none at all in the run after it.But the warm run still trips the watchdog on this Mac. In run 2 the first world frame is frame 2336. Its first bind is at 00:00:49.6 and the write at
image+0x23cf683comes at 00:01:16.0, 26.4 s later. Between the two:native shader translationline (33 ms);library conversionlines of the run, the longest 768 ms, 2.8 s in all;XPC_ERROR_CONNECTION_INTERRUPTED(the same two as in #15), the first after 3.2 s without a log line.So translation is not what holds that frame here, and the log does not say where the rest of the time goes: the first-bind lines carry no timing. Frames were already slow before it (2304 to 2336 took 71 s).
On screen, both runs: after the loading screen the game goes into the world with a black picture. There is sound at first, then it stops and the game exits.
I can attach both logs, or run again with a trace variable if you name one.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T00:05:57Z.
Correction: the cache was never broken.
native shader translationandmetal: library conversionare only logged for work of 20 ms or more, and a hit is never that slow, so every logged line sayshit=false. The hit counter was only logged on Windows. Every part of both keys was checked; nothing changes between runs.Main
0c990fb3addsVICTORY_TRACE_SHADER_CACHE=1, which logsshaders_cached/shaders_translated/libraries_cached/libraries_convertedevery 64 frames on macOS. Two runs of one build here (Series S, headless):So the very first run of a build is the one that risks the watchdog. Next: on later runs, prewarm the shaders the first world frame used first, and never translate inline on the render thread long enough to stall the title. Some warm runs still stall for about 23 s after the world frame with no shader work; that is a separate wait being looked at with #179.
Testers: one cold run, then one warm run, with
VICTORY_TRACE_SHADER_CACHE=1, tells us how well this works on your Mac.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T00:06:58Z.
Thanks @ItsMariusBC, that's the clean same-binary pair we needed: 5,361 → 603 lines, and the log simply can't show the hits.
On the 26.4 s your warm world frame still takes, here's what our local measurements point to (Apple M5 Pro, 48 GB, Series S, warm cache,
49b5521b), in case it helps you look:glue::submit(ExecuteCommandLists) holds that lock 3.65–4.5 s of every 5 s. Inside it is the texture sync of #179: read title memory, blake3, detile, upload, for each new or changed texture. Every other title thread waits behind it, the thread that moves the watchdog's heartbeat included, so a long enough submit alone can trip it with no shader work at all.XPC_ERROR_CONNECTION_INTERRUPTEDpipelines also cost seconds inside the frame: Metal's compiler service crashes, then the conversion is retried. On your log that's the 3.2 s gap before the first refusal. With 2.8 s of library conversions on top, that's roughly 6 s of the 26.4 s.So the rest is likely #179's texture sync, which the maintainer is on. For a run that would show it directly:
VICTORY_TRACE_SHADER_CACHE=1as asked, and, once #179'sVICTORY_TRACE_TEXTURE_SYNClands, the MiB per second and ms per step around frame 2336.@LakshanSivakumar, on "never translate inline on the render thread long enough to stall the title": we have a local branch doing that. It sets a per-frame translation budget; a draw whose pipeline isn't ready is deferred a frame instead of stalling it, while dispatches are still made. Its final cold run is going now. I'll post the result here within the hour. If it holds, take it or fold it into yours, so we don't build it twice.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T02:17:19Z.
Landed
6812e81a(642dd4e5,7abaf9b2,1d3b2cc7,51c9578a): the shader prewarm takes first the shaders earlier runs bound first (first-binds.txt in the cache folder, keyed by container so it survives translator changes); each frame has a 10 s wall-time budget from its first new pipeline, after which pipelines whose shaders aren't translated yet are put off (their draw is dropped that time) instead of holding the frame past the title's 30 s watchdog, guessed rect-list and extra-parameter translations included; *_tests.rs modules are left out of the translator hash; old build folders are pruned but never one used in the last hour. Measured on Series S: fully cold with no first-binds list, first world frame 20.0-20.1 s and no watchdog; cold with the list 17.8 s; warm 10.5-11.9 s. Separately, some single translations got much slower recently (46-48 KB pixel shaders at 10-20 s each); that is being bisected.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T04:17:05Z.
Landed
9e5b1fcc: lowering speed.lower_graphicsreran the whole lowering once per join without a value (574 passes for one 46 KB pixel shader); all failing joins are now collected per pass, anddescriptor_datauses a table built once. Measured on main7f70c8da(with #240 merged) against the fix: the worst pixel shader 44.7 s -> 0.25 s; 19 slow pixel shaders 297 s -> 3.2 s; whole corpus (36,197 dumps) 1,012 s -> 474 s; slowest single translation 33.4 s -> 1.0 s; translations of 5 s or more 16 -> 0. #240 alone gave no measurable gain on these shaders, and the two do not conflict. Corpus comparison by output fingerprint: 0 changed, 0 newly refused, 0 newly translated; 484 shaders are refused for a different reason or at a different offset than before, so refusal tallies by class shift without any shader changing state. Not verified: no game run of its own (a shared cold run is pending), and only one shader option set was compared.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:09:33Z.
Landed on main as
38786fd2: render, mesh and compute pipelines are converted and compiled off the frame's thread, mesh pipelines are kept in the pipeline archive, and the archive is written by its own thread.Headless Series S, 300 s, private caches:
d77e766dd77e766dChanges to #243's behaviour: the compile deadline is 60 s instead of 10 s (compiles now run side by side; one compute compile took 15.4 s), and the archive is no longer written after a slow compile or at submission, since the archive thread writes every 5 s.
Still open: one earlier warm run of the branch lost 3 command buffers to a GPU timeout and died; it did not recur in the later runs and the cause is not known. Draws whose pipeline is not ready yet are dropped until it is. The pause is bounded by the frame budget, not gone.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:39:01Z.
The cache turned out to be working: the log lines were only written for work of 20 ms or more, so every line said hit=false. The watchdog death on the first world frame is fixed by
38786fd2: pipelines now compile off the frame's thread, and runs go the full time cold and warm. Remaining speed work is in #179, and the black world is in #258.