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

Closed
opened 2026-11-28 18:55:17 +00:00 by Leyukaka · 2 comments
Leyukaka commented 2026-11-28 18:55:17 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T18:55:17Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6669851068 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3392). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T18:55:17Z. --- ### 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 commented 2026-11-28 19:11:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T19:11:21Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7244356757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3392#issuecomment-7244356757). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T19:11:21Z. --- 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 commented 2026-11-29 09:36:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T09:36:39Z.


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: #3396 (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 #3396: median marker-to-manifest for new requests 9.02 s -> 0.02 s, files byte-identical under both orders.
  • compile_dxil --watch: #3403 (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7253877953 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3392#issuecomment-7253877953). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T09:36:39Z. --- 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`: #3396 (`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 #3396: median marker-to-manifest for new requests 9.02 s -> 0.02 s, files byte-identical under both orders. - `compile_dxil --watch`: #3403 (`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.
Sign in to join this conversation.
No labels
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.

Reference
R0Y00/Xbox2Windows#3392
No description provided.