startup: answer draw and Dispatch cache probes from the cache index #3572
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3572
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3570"
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?
@JohnConnorNPC on GitHub · 2026-11-30 09:22 UTC · original
JohnConnorNPC:startup/cache-index-probes-v2→main· +847 −65 · 6 files · 3 commits · merged 2026-11-30 09:57 UTCSummary
Under Wine, looking up a name that is missing from a shader cache directory with ~274k entries costs ~155 ms, because
the case-insensitive lookup reads the whole directory. The draw and Dispatch paths make such lookups with
draw_lockheld: request parts, the slot 57 base manifest, the graphics and compute manifests, and the compute
<key>.cs.hlsl.Compute manifest retries also re-read every stale
<key>.txton the retry schedule.This PR extends
src/startup_stubs/cache_index.h(#3435, #3438). Those probes now ask the index first and skip thedisk for an absent name. An unchanged compute manifest miss is repeated without I/O.
ReadDirectoryChangesWon the cache (top level: names, last writes, sizes) and thenmakes the listing, so every file created after the listing began is in a change record. Created and renamed-to
names are added to the index. The listing moves off the caller: these probes never make or wait for it.
req_names (written only by runtimes): absent from the listing and from this process's own writes means skip thedisk. A write that finds such a name present is counted as a contradiction.
<key>.txt,<key>.cs.hlsl): answered absent only while the feed is reading, and only if it wasreading before the listing began. A dropped batch or any feed error sends them back to the disk.
<key>.*name has a change record from that mark on, the next retry repeats the miss without I/O. A created, removed,
renamed or rewritten file of that key, or a feed that is not reading, sends the retry back to the disk.
x2w-draw cache probes (skipped as absent/on disk): ...every 10 s: per probe, the feed state, records, added names,lookups that found a name added after the listing, and contradictions.
On its own, this did not change where the measured runs stop (below). It removes the file-system cost from
draw_lock; the in-process compute translation remains the main holder of the lock (#PR-2).Tests
Wine only (Proton wine 11.0, clang-cl cross build, main52 init cache). Windows CI has not run.
startup_cache_index_checkand controls, judged by their CTest PASS/FAIL regular expressions:Under Wine: (j) another process's create and rename are seen; (m) a 16-byte batch buffer drops with error 1022;
(q) 50 retries of an absent manifest make 1 look on disk, and a manifest published later is picked up with one more.
docs_links_checkandbidi_controls_check: exit 0.Measured (local game runs, one console executable under test; same inputs and recipe for every run)
The runs are on main
26df1826with these commits cherry-picked (same patch-ids), so that the native shader revisionmatches the baseline's warm cache. A local diagnostic timed the
draw_lock-held translation blocks.26df1826.cs.hlslprobes; every other probe was a hit on disk. No file was created inthe cache during these runs, so the feed read 0 records.
draw_lockfor 9.5 s of each 10 s after thestop (manifest load: at most 0.6 s per 10 s).
.cs.hlslprobes;without it, those would be ~57 min of
draw_lock-held misses (inference: count x 155 ms). That run ended when~700 stale compute manifests were re-read on every retry: the manifest load held
draw_lockfor 4.8-8.8 s per 10 s,with no changes in the cache (feed: 10 records in the run). The second commit targets exactly those re-reads.
retry cache. All 38,999 manifest retries were repeated without I/O, none went to disk (feed: 48 records,
0 contradictions). The manifest load's longest call was 403 ms; at the end of the run it took 0-0.1 ms per 10 s. That
run ended when the host ran out of memory (swap full, memory pressure 57% over 5 min; measured right after the run),
not on a stand-in stall.
Hypothesis, not measured: on Windows a miss is cheap, so the gain there is small; the change targets Wine.