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

Merged
Leyukaka merged 1 commit from upstream-pr/3396 into main 2026-11-28 21:57:42 +00:00
Leyukaka commented 2026-11-28 19:39:01 +00:00 (Migrated from github.com)

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


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 #3392 (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 #3392 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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5543882191 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3396). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T19:39:01Z. --- ## 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 #3392 (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 #3392 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.
KelboLive commented 2026-11-28 20:33:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:33:47Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6099976305 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6099976305). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T20:33:47Z. **Review:** APPROVED --- 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 commented 2026-11-28 21:02:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:02:32Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100075061 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100075061). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:02:32Z. **Review:** APPROVED --- 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 commented 2026-11-28 21:56:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:56:52Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100252263 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100252263). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:56:52Z. **Review:** APPROVED --- 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.
tedin7 commented 2026-11-28 21:57:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T21:57:38Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100254755 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3396#pullrequestreview-6100254755). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T21:57:38Z. **Review:** COMMENTED --- 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.
Sign in to join this conversation.
No reviewers
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!3396
No description provided.