startup: translate in-process compute programs on worker threads (opt-in) #3573
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!3573
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3571"
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/native-compute-worker-v2→main· +1449 −73 · 9 files · 4 commits · closed without mergingStacked on the cache-index PR from the same series: the first two commits here are that PR's. Rebased onto current main; one conflict in the compute dispatch translation (now calls
compile_native_shader) was resolved by hand. This rebase was not rebuilt or re-run; the measurements below were taken before it.Summary
With
X2W_NATIVE_SHADERS, the first Dispatch of a compute key translates it in the stand-in (frontend + DXC) whileholding
draw_lock. A translation takes from milliseconds to several seconds. When a new scene brings hundreds of newkeys,
draw_lockis held for most of the wall time, and draws and Dispatches on other threads wait behind it.X2W_NATIVE_COMPUTE_WORKERS=<1-8>moves that translation onto worker threads (src/startup_stubs/native_compute_worker.h):Dispatches are refused with
in-process translation still running(counted as untranslated).the key reads its published manifest in that Dispatch, as before. The native-first order is kept: no published
manifest is read while a key is still translating.
requests are locked; the D3D12 device is free-threaded; DXC and frontend cache publishes use unique temporary names
and accept an identical winner.
x2w-draw native compute workers <n>: ...every 10 s: queued, translated, refused, waiting, most at once, longestwait, time translating, and Dispatches refused while their key was translating.
0or any other value: unchanged. The Dispatch translates, and its first Dispatch is recorded, asstartup_compute_dispatch_native_checkstep 1 requires. That is why the switch is opt-in.Trade-off
The first Dispatches of a key that would translate are now skipped until a worker has it. Before, they waited (with
the whole stand-in) and then ran. In the measured run below (one worker, the same mechanism):
480-510 s, at 11-14k per second.
(487.8 s). In the first 600 logged keys, the queue wait reached 240 s and a key was adopted on average 95 s after
it was queued.
the 121 that translated, which is 91% of the worker's time.
Ideas to reduce it, not in this PR:
Tests
Wine only (Proton wine 11.0, clang-cl cross build). Windows CI has not run. No device fixture covers the switch
yet. The existing native compute fixtures run unchanged with the switch unset, but were not run locally.
Measured (local game run, one console executable under test, on
26df1826with the commits cherry-picked)wait was 95 s (D1: 240 s), and the queue was empty about 130 s after the burst began.
0-3 s per 10 s). It matches the title's streaming phase: storage decompression requests rise and then flatten exactly
where frames recover. That is an inference from timing; what bounds that phase was not measured.
@lukaslw-lab on GitHub · 2026-11-30 09:34 UTC · original
This overlaps #3508 (which continues #3469). Both move the in-process compute translation off
draw_lockonto worker threads, and both rewritetranslate_compute_nativelyand its call inrecord_translated_dispatch. Whichever merges second has to be redone on top of the other.What each one does that the other doesn't:
b3a48a59X2W_NATIVE_SHADERSis setX2W_NATIVE_COMPUTE_WORKERS=1..8d3d12_compute_dispatch.inl:714there):631)native_compute,:718)draw_lock, one load per keydraw_lockYour E1/D1 numbers are the case for more than one worker: 36 k refused Dispatches with three workers against 1.0 M with one. #3508's published fallback covers the other side: Dispatches of a pending key that has a published translation are drawn, not refused. #3508 has an approving review.
Proposal: rebase this onto #3508 and keep only the multi-worker part, i.e. the per-thread compiler, the worker count and the status line, as a follow-up to it. With the fallback in place, only keys with no published translation are refused while they translate, which shrinks the trade-off that keeps this switch opt-in. #3572 (the index) is independent and can stay as it is.
@JohnConnorNPC on GitHub · 2026-11-30 10:07 UTC · original
Closing this one: it overlaps #3508, which already moves the in-process compute translation off
draw_lockonto workers and rewrites the sametranslate_compute_nativelypath. Having two competing rewrites of that function would only force a redo for whichever lands second, so the worker change is better reviewed in #3508.The cache-index change in #3572 is separate and stays open.
AI-assisted.
Pull request closed