tooling: translate requests written during a watch pass first #3398

Manually merged
github merged 1 commit from github-bot/gh-3396 into gh-pr/3396/base 2026-11-28 22:02:39 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-28 19:39 UTC · original
Leyukaka:tooling-watch-newest-first → main · +179 −30 · 6 files · 1 commits · merged 2026-11-28 21:57 UTC

Change

gfx2hlsl.py --watch sorted pending requests by key (pending_keys) and translated the whole list before it scanned again, so a request written during a pass waited for the entire backlog. Within a watch pass, requests whose ready marker is newer than the watcher's start now go first, newest first. They run in batches of up to four keys per worker, with a rescan between batches at most once per second. The worker pool is sized by --jobs once and reused across batches. A request written after the pass has used its last snapshot, within a second of the last scan, waits for the next pass, as before. --pending keeps its order. The first-pass retry of earlier failures and --skip-failed are unchanged, and each key's outputs are the same.

Refs #3394 (the gfx2hlsl.py half; compile_dxil --watch is not changed here).

Verification

Commit d6c879a1 on main 543c250c, Windows 11, Python from out/pe-env.

  • python -B tests/startup_gfx2hlsl_watch_order_check.py: passes. It uses a synthetic cache with 8 old requests, 1 new request and 1 request written during the pass, with translation stubbed and the clock faked. The new request is in the first batch, the mid-pass one is taken by the first rescan, older requests keep their key order, and both orders write byte-identical files.
  • python -B tests/startup_gfx2hlsl_watch_order_check.py --negative-control: fails on purpose (the old order puts the new request last).
  • python -B tests/startup_gfx2hlsl_watch_check.py: passes.
  • Synthetic measurement (measure_watch_order.py, a local script), 3,500 old requests and 5 new ones present when the pass starts, 2 ms per stubbed translation, one worker:
Order Directory scans Pass time Marker to manifest, new requests (median)
By key (before) 1 9.02 s 9.02 s
Newest first (this PR) 10 9.11 s 0.02 s

The table covers requests present when the pass starts; a request written during the pass is covered by the test only. Rescanning after every batch of one key per worker would rescan about 220 times per 3,513 requests with 16 workers, hence the once-per-second limit.

Evidence and follow-up

Synthetic requests only, written by the test; no application data. Not measured: a real run with -Translate, and passes with several worker processes (the stub cannot cross process boundaries). The compile_dxil --watch half of #3394 is left for a follow-up.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • No application files, dumps, distribution links or secrets included.
**@⁠Leyukaka** on GitHub · 2026-11-28 19:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3396) `Leyukaka:tooling-watch-newest-first` → `main` · +179 −30 · 6 files · 1 commits · merged 2026-11-28 21:57 UTC ## Change `gfx2hlsl.py --watch` sorted pending requests by key (`pending_keys`) and translated the whole list before it scanned again, so a request written during a pass waited for the entire backlog. Within a watch pass, requests whose ready marker is newer than the watcher's start now go first, newest first. They run in batches of up to four keys per worker, with a rescan between batches at most once per second. The worker pool is sized by `--jobs` once and reused across batches. A request written after the pass has used its last snapshot, within a second of the last scan, waits for the next pass, as before. `--pending` keeps its order. The first-pass retry of earlier failures and `--skip-failed` are unchanged, and each key's outputs are the same. Refs #3394 (the `gfx2hlsl.py` half; `compile_dxil --watch` is not changed here). ## Verification Commit `d6c879a1` on `main` `543c250c`, Windows 11, Python from `out/pe-env`. - `python -B tests/startup_gfx2hlsl_watch_order_check.py`: passes. It uses a synthetic cache with 8 old requests, 1 new request and 1 request written during the pass, with translation stubbed and the clock faked. The new request is in the first batch, the mid-pass one is taken by the first rescan, older requests keep their key order, and both orders write byte-identical files. - `python -B tests/startup_gfx2hlsl_watch_order_check.py --negative-control`: fails on purpose (the old order puts the new request last). - `python -B tests/startup_gfx2hlsl_watch_check.py`: passes. - Synthetic measurement (`measure_watch_order.py`, a local script), 3,500 old requests and 5 new ones present when the pass starts, 2 ms per stubbed translation, one worker: | Order | Directory scans | Pass time | Marker to manifest, new requests (median) | |---|---|---|---| | By key (before) | 1 | 9.02 s | 9.02 s | | Newest first (this PR) | 10 | 9.11 s | 0.02 s | The table covers requests present when the pass starts; a request written during the pass is covered by the test only. Rescanning after every batch of one key per worker would rescan about 220 times per 3,513 requests with 16 workers, hence the once-per-second limit. ## Evidence and follow-up Synthetic requests only, written by the test; no application data. Not measured: a real run with `-Translate`, and passes with several worker processes (the stub cannot cross process boundaries). The `compile_dxil --watch` half of #3394 is left for a follow-up. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] No application files, dumps, distribution links or secrets included.
gfx2hlsl.py --watch sorted pending requests by key and translated the whole list before scanning
again, so a request written during a pass waited for the whole backlog. Within a watch pass, requests
whose ready marker is newer than the watcher's start now go first, newest first, in batches of up
to four keys per worker, with a rescan between batches at most once per second. --pending keeps its
order; outputs are unchanged.

Refs #3392.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 19:40:53 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 20:33 UTC · original · approved these changes

LGTM — clean, well-tested.

Updates gfx2hlsl.py watch pass to prioritize fresh requests by timestamp. Adds pending_batches for rate-limited batch processing (up to 4×jobs keys per batch, 1s scan interval). pending_keys now returns recent requests (written since watch start) in newest-first order, followed by older ones. Handles retry of earlier failures only once. New test startup_gfx2hlsl_watch_order_check.py verifies priority, batch boundaries, and parity with legacy ordering. Minimal diff, no behavioral regressions.

Ready to land.

**@⁠KelboLive** on GitHub · 2026-11-28 20:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6099976305) · **approved these changes** LGTM — clean, well-tested. Updates gfx2hlsl.py watch pass to prioritize fresh requests by timestamp. Adds pending_batches for rate-limited batch processing (up to 4×jobs keys per batch, 1s scan interval). pending_keys now returns recent requests (written since watch start) in newest-first order, followed by older ones. Handles retry of earlier failures only once. New test startup_gfx2hlsl_watch_order_check.py verifies priority, batch boundaries, and parity with legacy ordering. Minimal diff, no behavioral regressions. Ready to land.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:02 UTC · original · approved these changes

LGTM — substantial but well-structured.

tools/startup/compute_native.py implements the offline native gfx1013 compute adapter and cache (Stage 4B.2) with clear stage separation (request, translate, compile). Record serialization/parsing with strict validation, translation through existing translator (machine code -> HLSL via LLVM), DXC compilation with embedded root signature, dxil.dll validation, intrinsic gate, PSO probing, and integrity-checked manifest publication. Single-writer cache with O_EXCL lock, atomic writes, and token-based ownership. Exit codes properly distinguish permanent refusals, retryable failures, and cache hits.

Ready to land.

**@⁠KelboLive** on GitHub · 2026-11-28 21:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100075061) · **approved these changes** LGTM — substantial but well-structured. tools/startup/compute_native.py implements the offline native gfx1013 compute adapter and cache (Stage 4B.2) with clear stage separation (request, translate, compile). Record serialization/parsing with strict validation, translation through existing translator (machine code -> HLSL via LLVM), DXC compilation with embedded root signature, dxil.dll validation, intrinsic gate, PSO probing, and integrity-checked manifest publication. Single-writer cache with O_EXCL lock, atomic writes, and token-based ownership. Exit codes properly distinguish permanent refusals, retryable failures, and cache hits. Ready to land.
github-bot changed target branch from main to gh-pr/3396/base 2026-11-28 22:02:37 +00:00
github manually merged commit d6c879a158 into gh-pr/3396/base 2026-11-28 22:02:39 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:56 UTC · original · approved these changes

LGTM — targeted, well-tested change.

tools/startup/gfx2hlsl.py --watch now prioritizes requests written during a pass ahead of the older backlog. pending_keys splits results into recent (newest-first) and legacy order; translate_pending batches them at four keys per worker and rescans between batches at most once per second; the worker pool is sized by --jobs once and reused. watch_since_ns tracks the pass start so only newer-than-pass markers get priority. New test startup_gfx2hlsl_watch_order_check.py validates priority, batch boundaries, and byte-identical outputs against the legacy order. Non-breaking — same keys translated, different order.

Ready to land.

**@⁠KelboLive** on GitHub · 2026-11-28 21:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100252263) · **approved these changes** LGTM — targeted, well-tested change. `tools/startup/gfx2hlsl.py --watch` now prioritizes requests written during a pass ahead of the older backlog. `pending_keys` splits results into recent (newest-first) and legacy order; `translate_pending` batches them at four keys per worker and rescans between batches at most once per second; the worker pool is sized by `--jobs` once and reused. `watch_since_ns` tracks the pass start so only newer-than-pass markers get priority. New test `startup_gfx2hlsl_watch_order_check.py` validates priority, batch boundaries, and byte-identical outputs against the legacy order. Non-breaking — same keys translated, different order. Ready to land.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 21:57 UTC · original · reviewed

Reviewed head d6c879a1.

Code read: translate_pending now takes batches from pending_batches; a watch pass puts ready markers newer than the watcher start first (newest first), rescans at most once per second, and reuses one pool. Each key is attempted once per pass (attempted), so first-pass retries are unchanged. Without watch_since_ns the old single-snapshot order is kept (--pending unchanged). No issue found.

Verification (Win2025, dev and release, this head):

  • x2w_pipe.py win2025 3396 --regex 'gfx2hlsl_watch': startup_gfx2hlsl_watch_order and startup_gfx2hlsl_watch 2/2 passed on dev and 2/2 on release; the pipeline's Windows Python checks passed.
  • Required CI on the head is green; 13 commits behind main; no change requests.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-28 21:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100254755) · **reviewed** Reviewed head d6c879a1. Code read: `translate_pending` now takes batches from `pending_batches`; a watch pass puts ready markers newer than the watcher start first (newest first), rescans at most once per second, and reuses one pool. Each key is attempted once per pass (`attempted`), so first-pass retries are unchanged. Without `watch_since_ns` the old single-snapshot order is kept (`--pending` unchanged). No issue found. Verification (Win2025, dev and release, this head): - `x2w_pipe.py win2025 3396 --regex 'gfx2hlsl_watch'`: `startup_gfx2hlsl_watch_order` and `startup_gfx2hlsl_watch` 2/2 passed on dev and 2/2 on release; the pipeline's Windows Python checks passed. - Required CI on the head is green; 13 commits behind main; no change requests. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.