startup: use cached native compute frontend results before translating live #3524
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!3524
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3522"
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?
@Leyukaka on GitHub · 2026-11-29 22:11 UTC · original
Leyukaka:runtime-native-compute-csir-cache→main· +195 −40 · 8 files · 1 commits · draftRefs #2935
What changes
At the first Dispatch of a slot-67 request,
translate_compute_natively(src/startup_stubs/d3d12_compute_dispatch.inl) now looks for a cached frontend result in<cache>\nativebefore it callstranslate_compute. The lookup runs after a pack miss or when no pack is loaded. A pack hit or a pack refusal behaves as before.lookup_compute_frontend(src/direct_compute_cache.cpp) builds the key withslot67_digest, the function the pack andprepare_direct_computealready use: frontend revision, entry offset, SHA-256 of the six request parts. It reads<key>.csironly. It never publishes.lookupintolookup_frontend_payload: size bounds, stored identity equal to the key, SHA-256 of the payload.lookupis now a wrapper around it, andcached_compute_irgoes through the same reader (lookup_compute_ir), which also runsdecode.hit,missing,identity_mismatchorinvalid. Anything buthitgoes to the sametranslate_compute(*frozen, entry, true)call as before.<cache>\nativeis the directory the route already passed to the DXC bytecode compile.compile_dxilfills it when it gets that directory asCACHE_DIRECTORY(documented indocs/experiments/native-startup-request-cache.md).(frontend cached), or with(frontend live)plus the reason. The heartbeat gains acompute frontend cache: hits, misses, identity mismatches, invalidline.With no
.csirpresent, the route does one extra file open per key at first Dispatch, then translates live as before.Why
On
ff9dcef0the route translated live at first Dispatch unlessX2W_NATIVE_COMPUTE_PACKheld the key. The.csirfiles thatcompile_dxilwrites were never read there, so an offlinecompile_dxilbatch over saved requests did not shorten a later run unless a pack was also built.Evidence
Local build of
compile_dxil,native_compute_pack_check,startup_stream_consumerandd3d12_xs_shim, thenctest -R '^(native_compute_csir_hardware|native_compute_pack(_hardware)?|native_compile_dxil_watch|startup_compute_dispatch_native_(hardware|warp))$':native_compute_csir_hardware(new)native_compute_packnative_compute_pack_hardwarenative_compile_dxil_watchstartup_compute_dispatch_native_hardwarestartup_compute_dispatch_native_warpThe same filter gives the same results in a clean Windows Sandbox build (dev preset, MSVC, network off).
The WARP test skips because the adapter has no 32-lane waves. Before it exits 77 it still checks the refusal and the published-translation fallback (320 words).
native_compute_csir_hardwaredoes the following on a hardware adapter, comparing all 320 words with the CPU reference and with the live run each time:(frontend live) (frontend cache miss), and no.csiris left behind.compile_dxilbuilds the same request offline into<cache>\native. The bytecode.binfiles are deleted. A fresh runtime process logs(frontend cached).(frontend live) (frontend cache identity mismatch).(frontend live) (invalid frontend cache entry).(frontend live) (invalid frontend cache entry).In 3 and 4 the damaged file is byte-identical after the run.
Mutations, each built and run alone, each fails
native_compute_csir_hardware:missing: fails on the(frontend cached)check.lookup_frontend_payload: fails on the identity-mismatch check.return Result::hit): fails on the damaged-entry check.Not covered
--jobs(#3474).direct_compute_cache.cppchanges the frontend revision, so.csirfiles and packs built before this commit miss and need regenerating.@lukaslw-lab on GitHub · 2026-11-30 07:44 UTC · original · approved these changes
Reviewed
a5a2eb57(draft) by reading the diff; not built or run.Verdict: approve. The runtime reads
.csirwith the same key, file checks and decoder thatcompile_dxiland the pack already use, and every result excepthitfalls back to the sametranslate_computecall. No MUST.src/startup_stubs/d3d12_compute_dispatch.inlconflicts with main on thetranslated natively ... (frontend %s)log line (9fcfe0de, native shader totals). It is a small merge, but the new log suffix your test checks lives there..csirafter a live translation; the test asserts this (tests/native_compute_csir_check.py:42). So a warm run still needs an offlinecompile_dxilbatch. If the runtime stays read-only on purpose (keeping cache writes offdraw_lock, a single writer), say so indocs/experiments/native-startup-request-cache.md, so nobody "fixes" it later.slot67_digest, the same one the pack andprepare_direct_computeuse, and the frontend revision comes from the sharedx2w_shader_compilersources..csir(prepare_direct_computethrows).invalidand goes live.lookupkeeps its old result forcached_compute_irand the pack builder.Tests:
native_compute_csir_hardwareproves the hit (with the bytecode deleted, so the frontend really came from.csir), the identity, checksum and decode fallbacks, and that every route gives the same 320 words. The three mutations show each check is reached. CI did not run it: it is not in the Windowsprfilter, and it needs wave32 hardware. The only results are the author's local run and the sandbox run.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.