Shader watcher: a request written during a pass waits for the whole backlog #3394

Closed
opened 2026-11-28 18:59:04 +00:00 by github-bot · 2 comments
Owner

@⁠Leyukaka on GitHub · 2026-11-28 18:55 UTC · original

Question

When tools/startup/gfx2hlsl.py --watch (or compile_dxil --watch) has a backlog, how long does a request the application has just written wait for its manifest, and does processing newer requests first shorten that wait without changing any output?

Evidence so far

  • pending_keys sorts pending requests by file name, i.e. by key (tools/startup/gfx2hlsl.py:13848), and watch_pass translates the whole list before it scans again (:13738, :13746). A request written during a pass waits for the end of that pass.
  • compile_dxil --watch does the same: collect_watch_requests sorts by marker path (tools/startup/compile_dxil.cpp:809, :828), and run_watch processes the whole pending vector before the next scan (:944-1003).
  • Sources of a large backlog: the watcher's first pass retries every earlier failure once (docs/startup-runtime.md:968, gfx2hlsl.py:13726), and a revision change followed by a re-key (docs/startup-runtime.md:1368-1373). The only timing on record: 3,513 requests took 56.9 s with one process and 7.8 s in parallel on 16 threads (docs/startup-runtime.md:985-986).
  • The runtime looks for an absent manifest again after 1 s, doubling up to 32 s (docs/startup-runtime.md:963-964).
  • Inference, not measured: a pipeline the application has just requested waits behind every older request, and its draws stay "not drawn" meanwhile.

Completion condition

  1. Measure, from file times only: for each key, the time from its ready marker to its manifest (<key>.txt, or <key>.ms57.txt for mesh), on a synthetic cache with an old backlog and a few new requests, under the current order.
  2. Repeat with an order that takes requests written since the watcher started first and rescans between batches.
  3. The set of files produced under both orders is byte-identical.

A follow-up tooling: PR would change the order only, with a test where the new request is published before the backlog ends and a negative control with the current order. Not in scope: how anything is translated.

Required environment

None for the gfx2hlsl.py half (pure-Python synthetic cache). Windows x64 and the Windows SDK for the compile_dxil half. A local cache is optional; only counts and durations from it would be posted.

Part of #870. Refs #2120, #2925, #2899, #2992.

**@⁠Leyukaka** on GitHub · 2026-11-28 18:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3392) ### Question When `tools/startup/gfx2hlsl.py --watch` (or `compile_dxil --watch`) has a backlog, how long does a request the application has just written wait for its manifest, and does processing newer requests first shorten that wait without changing any output? ### Evidence so far - `pending_keys` sorts pending requests by file name, i.e. by key (`tools/startup/gfx2hlsl.py:13848`), and `watch_pass` translates the whole list before it scans again (`:13738`, `:13746`). A request written during a pass waits for the end of that pass. - `compile_dxil --watch` does the same: `collect_watch_requests` sorts by marker path (`tools/startup/compile_dxil.cpp:809`, `:828`), and `run_watch` processes the whole `pending` vector before the next scan (`:944-1003`). - Sources of a large backlog: the watcher's first pass retries every earlier failure once (`docs/startup-runtime.md:968`, `gfx2hlsl.py:13726`), and a revision change followed by a re-key (`docs/startup-runtime.md:1368-1373`). The only timing on record: 3,513 requests took 56.9 s with one process and 7.8 s in parallel on 16 threads (`docs/startup-runtime.md:985-986`). - The runtime looks for an absent manifest again after 1 s, doubling up to 32 s (`docs/startup-runtime.md:963-964`). - Inference, not measured: a pipeline the application has just requested waits behind every older request, and its draws stay "not drawn" meanwhile. ### Completion condition 1. Measure, from file times only: for each key, the time from its ready marker to its manifest (`<key>.txt`, or `<key>.ms57.txt` for mesh), on a synthetic cache with an old backlog and a few new requests, under the current order. 2. Repeat with an order that takes requests written since the watcher started first and rescans between batches. 3. The set of files produced under both orders is byte-identical. A follow-up `tooling:` PR would change the order only, with a test where the new request is published before the backlog ends and a negative control with the current order. Not in scope: how anything is translated. ### Required environment None for the `gfx2hlsl.py` half (pure-Python synthetic cache). Windows x64 and the Windows SDK for the `compile_dxil` half. A local cache is optional; only counts and durations from it would be posted. Part of #870. Refs #2120, #2925, #2899, #2992.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 18:59:05 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-28 19:11 UTC · original

Working on this: an order-only change to gfx2hlsl.py --watch (newest requests first, rescan between batches) with a pure-Python test and a negative control, plus the measurement from the completion condition. compile_dxil --watch after that.

**@⁠Leyukaka** on GitHub · 2026-11-28 19:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3392#issuecomment-7244356757) Working on this: an order-only change to `gfx2hlsl.py --watch` (newest requests first, rescan between batches) with a pure-Python test and a negative control, plus the measurement from the completion condition. `compile_dxil --watch` after that.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 09:36 UTC · original

The question was whether a request written while a --watch pass has a backlog waits for the whole backlog, and whether taking newer requests first shortens that wait without changing any output. Both halves are on main (1a0120ba):

  • gfx2hlsl.py --watch: #3398 (6747721c). Requests whose marker is newer than the watcher's start go first, newest first (tools/startup/gfx2hlsl.py:14044-14052). Conditions 1-3 are covered by the synthetic measurement in #3398: median marker-to-manifest for new requests 9.02 s -> 0.02 s, files byte-identical under both orders.
  • compile_dxil --watch: #3405 (e6f2b3ed). Same order (tools/startup/compile_dxil.cpp:924-925), rescan between batches (:1044). The test checks the order and byte-identical outputs (tests/native_compile_dxil_watch_check.py:222-249).

Not measured: the wait itself for compile_dxil, and a real run for either half (synthetic requests only). Closing.

**@⁠Leyukaka** on GitHub · 2026-11-29 09:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3392#issuecomment-7253877953) The question was whether a request written while a `--watch` pass has a backlog waits for the whole backlog, and whether taking newer requests first shortens that wait without changing any output. Both halves are on `main` (`1a0120ba`): - `gfx2hlsl.py --watch`: #3398 (`6747721c`). Requests whose marker is newer than the watcher's start go first, newest first (`tools/startup/gfx2hlsl.py:14044-14052`). Conditions 1-3 are covered by the synthetic measurement in #3398: median marker-to-manifest for new requests 9.02 s -> 0.02 s, files byte-identical under both orders. - `compile_dxil --watch`: #3405 (`e6f2b3ed`). Same order (`tools/startup/compile_dxil.cpp:924-925`), rescan between batches (`:1044`). The test checks the order and byte-identical outputs (`tests/native_compile_dxil_watch_check.py:222-249`). Not measured: the wait itself for `compile_dxil`, and a real run for either half (synthetic requests only). Closing.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#3394
No description provided.