startup: translate shader requests in parallel and during a run #1742

Closed
NiiRoZz wants to merge 6 commits from upstream-pr/1749 into main
NiiRoZz commented 2026-11-24 18:06:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-24T18:06:39Z.


Change

Two changes to how tools/startup/gfx2hlsl.py consumes the startup shader cache, so translations stop being the slow step between runs.

Parallel --pending. Requests are independent (each writes only its own <key>.* files), so a scan with more than one pending request now translates them in a process pool.

  • X2W_TRANSLATE_JOBS sets the worker count. The default is the processor count, capped at 61 on Windows because ProcessPoolExecutor refuses more there.
  • A single pending request is still translated in-process. Batches are sized to keep every worker busy.
  • An unexpected translator error is written to <key>.fail instead of ending the scan.

Translation during a run.

  • gfx2hlsl.py --watch <dir> [seconds] repeats the pending scan (every 2 s by default) until it is stopped.
  • run.ps1 -Render -Translate starts the watcher on the shader cache beside the debugger, logs to <log>/translate.txt, and stops it, together with its worker processes (taskkill /T), in a finally block that still returns the debugger's exit code.
  • A pipeline the title creates during the run is therefore translated within seconds, and the runtime picks it up on a later draw (the polling from #1416) instead of on the next run.
  • The watcher's first pass retries earlier failures once, so a translator update reaches them. After that, a failure is not retried during the run, because the runtime writes each request once and never rewrites it. The one-shot --pending still retries every failure, as before.

Related: #1641 caches the driver's PSO blobs. That is a different layer, and the two compose. A follow-up PR writes requests from the shader archive before any run.

Verification

Branch head 7b4275cb (baadbfae plus a commit addressing review findings), on main at a4d17cf5. Windows 11 (26300), Python 3.13, x64.

python -B tests/startup_gfx2hlsl_watch_check.py      # startup_gfx2hlsl_watch_check passed
python -B tests/startup_run_ps1_check.py             # 0 failed (executed with powershell)
python -B tests/startup_run_ps1_check.py --text-only # 0 failed (text only: requested)
python -B tests/startup_gfx2hlsl_capture_check.py    # passed
python -B tests/startup_gfx2hlsl_operand_count_check.py  # 0 failed
python -B tests/docs_links_check.py                  # 17 files, 367 links
python -B tests/bidi_controls_check.py               # no bidirectional controls

Mutation checks, each run against a temporary edit that was then reverted. Every mutant failed the check:

Mutant Caught by
Watch mode ignores the .fail-newer-than-marker rule startup_gfx2hlsl_watch (3 failures, including a failure rewritten on later passes)
First watcher pass does not retry earlier failures startup_gfx2hlsl_watch
Translator error not caught per request startup_gfx2hlsl_watch (no .fail written)
Invalid X2W_TRANSLATE_JOBS raises startup_gfx2hlsl_watch (ValueError)
Watcher stopped without its child processes (Stop-Process instead of taskkill /T) startup_run_ps1
Parallel results printed against the wrong keys startup_gfx2hlsl_watch (parallel output ≠ serial)
run.ps1 never stops the watcher startup_run_ps1 ("translator left running")

Local data, not in the repository. A Scarlett package's 3,513 shader requests (132 translated, 3,381 refused) took 56.9 s with one process and 7.8 s with 16 workers on a 16-thread Ryzen. Every result file (.txt, .hlsl, .cso, .fail) was byte-identical between the two runs. On this branch the eleven requests recorded by a cold startup run all translate in parallel, and their .cso files are identical to the sequential ones.

A cold-cache startup run with -Render -Translate translated all eleven requests during the run, and the presented surface went from mean level 0 to 87.8/255 in that same run. One pipeline still counted as missing at the end of that run; I did not trace why, so this run is not claimed as evidence for anything beyond the watcher translating during a run.

Evidence and follow-up

  • All fixtures are synthetic: request files written by the tests, and an invalid RTV request used as a deterministic failure that needs no GPU or compiler.
  • Assumption: the runtime publishes .b and .root before .a, each through a temporary file and a rename (publish_shader_request in d3d12_draw.inl), so .a existing means the request is complete.
  • Docs: docs/startup-runtime.md gains "Translating shaders during a run", a translate.txt row in the log table, and the X2W_SHADER_CACHE row now points to -Translate.

Checklist

  • This pull request covers one reviewable behavior: how pending shader requests are consumed (in parallel, and continuously during a run).
  • 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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588282612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T18:06:39Z. --- ## Change Two changes to how `tools/startup/gfx2hlsl.py` consumes the startup shader cache, so translations stop being the slow step between runs. **Parallel `--pending`.** Requests are independent (each writes only its own `<key>.*` files), so a scan with more than one pending request now translates them in a process pool. - `X2W_TRANSLATE_JOBS` sets the worker count. The default is the processor count, capped at 61 on Windows because `ProcessPoolExecutor` refuses more there. - A single pending request is still translated in-process. Batches are sized to keep every worker busy. - An unexpected translator error is written to `<key>.fail` instead of ending the scan. **Translation during a run.** - `gfx2hlsl.py --watch <dir> [seconds]` repeats the pending scan (every 2 s by default) until it is stopped. - `run.ps1 -Render -Translate` starts the watcher on the shader cache beside the debugger, logs to `<log>/translate.txt`, and stops it, together with its worker processes (`taskkill /T`), in a `finally` block that still returns the debugger's exit code. - A pipeline the title creates during the run is therefore translated within seconds, and the runtime picks it up on a later draw (the polling from #1416) instead of on the next run. - The watcher's first pass retries earlier failures once, so a translator update reaches them. After that, a failure is not retried during the run, because the runtime writes each request once and never rewrites it. The one-shot `--pending` still retries every failure, as before. Related: #1641 caches the driver's PSO blobs. That is a different layer, and the two compose. A follow-up PR writes requests from the shader archive before any run. ## Verification Branch head `7b4275cb` (`baadbfae` plus a commit addressing review findings), on `main` at `a4d17cf5`. Windows 11 (26300), Python 3.13, x64. ```powershell python -B tests/startup_gfx2hlsl_watch_check.py # startup_gfx2hlsl_watch_check passed python -B tests/startup_run_ps1_check.py # 0 failed (executed with powershell) python -B tests/startup_run_ps1_check.py --text-only # 0 failed (text only: requested) python -B tests/startup_gfx2hlsl_capture_check.py # passed python -B tests/startup_gfx2hlsl_operand_count_check.py # 0 failed python -B tests/docs_links_check.py # 17 files, 367 links python -B tests/bidi_controls_check.py # no bidirectional controls ``` Mutation checks, each run against a temporary edit that was then reverted. Every mutant failed the check: | Mutant | Caught by | |---|---| | Watch mode ignores the `.fail`-newer-than-marker rule | `startup_gfx2hlsl_watch` (3 failures, including a failure rewritten on later passes) | | First watcher pass does not retry earlier failures | `startup_gfx2hlsl_watch` | | Translator error not caught per request | `startup_gfx2hlsl_watch` (no `.fail` written) | | Invalid `X2W_TRANSLATE_JOBS` raises | `startup_gfx2hlsl_watch` (`ValueError`) | | Watcher stopped without its child processes (`Stop-Process` instead of `taskkill /T`) | `startup_run_ps1` | | Parallel results printed against the wrong keys | `startup_gfx2hlsl_watch` (parallel output ≠ serial) | | `run.ps1` never stops the watcher | `startup_run_ps1` ("translator left running") | **Local data, not in the repository.** A Scarlett package's 3,513 shader requests (132 translated, 3,381 refused) took **56.9 s** with one process and **7.8 s** with 16 workers on a 16-thread Ryzen. Every result file (`.txt`, `.hlsl`, `.cso`, `.fail`) was byte-identical between the two runs. On this branch the eleven requests recorded by a cold startup run all translate in parallel, and their `.cso` files are identical to the sequential ones. A cold-cache startup run with `-Render -Translate` translated all eleven requests during the run, and the presented surface went from mean level 0 to 87.8/255 in that same run. One pipeline still counted as missing at the end of that run; I did not trace why, so this run is not claimed as evidence for anything beyond the watcher translating during a run. ## Evidence and follow-up - All fixtures are synthetic: request files written by the tests, and an invalid RTV request used as a deterministic failure that needs no GPU or compiler. - Assumption: the runtime publishes `.b` and `.root` before `.a`, each through a temporary file and a rename (`publish_shader_request` in `d3d12_draw.inl`), so `.a` existing means the request is complete. - Docs: `docs/startup-runtime.md` gains "Translating shaders during a run", a `translate.txt` row in the log table, and the `X2W_SHADER_CACHE` row now points to `-Translate`. ## Checklist - [x] This pull request covers one reviewable behavior: how pending shader requests are consumed (in parallel, and continuously during a run). - [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] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-24 19:01:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:13:32Z.

Review: COMMENTED


Peer review at commit baadbfaea3d968d451781ccd2ac5abf512c75049 (PRODUCTION_REVIEW_ONLY).

Findings

  • P2 — run.ps1 Stop-Process does not terminate ProcessPoolExecutor child processes on Windows (tools/startup/run.ps1): Stop-Process -Id $translator.Id -Force in the finally block only kills the parent python.exe --watch process. If the debugger exits while translate_pending is running a ProcessPoolExecutor batch, spawned worker python.exe processes (and any fxc.exe children) are left running. Using taskkill /PID $($translator.Id) /T /F (or a job object) would tear down the process tree.
  • P2 — Unhandled decode/translation exceptions terminate --watch (tools/startup/gfx2hlsl.py): translate_request catches (Unsupported, OSError, UnicodeError) and translate_to catches Unsupported. Any unexpected exception from a malformed request (e.g. struct.error, ValueError, IndexError) propagates out of pool.map and stops the --watch loop instead of recording a .fail for that key.
  • Nit — X2W_TRANSLATE_JOBS="" (tools/startup/gfx2hlsl.py): int(os.environ.get('X2W_TRANSLATE_JOBS', 0)) raises ValueError when X2W_TRANSLATE_JOBS is set to an empty string (int(os.environ.get('X2W_TRANSLATE_JOBS') or 0) avoids it).
  • Nit — Parallel key-pairing check (tests/startup_gfx2hlsl_watch_check.py): All 8 synthetic RTV requests in pending_run fail with the same message (unsupported: invalid RTV variant request), so swapping keys in pool.map (tested locally with list(reversed(keys))) is not caught by the check.

Verification

  • Linux checks:
    • python3 -B tests/startup_gfx2hlsl_watch_check.py → startup_gfx2hlsl_watch_check passed
    • python3 -B tests/startup_run_ps1_check.py --text-only → 0 failed (text only: requested)
    • python3 -B tests/startup_gfx2hlsl_capture_check.py → startup_gfx2hlsl_capture_check passed
    • python3 -B tests/startup_gfx2hlsl_operand_count_check.py → operand count checks: 0 failed
    • python3 -B tests/docs_links_check.py → Checked 17 Markdown files and 367 links.
    • python3 -B tests/bidi_controls_check.py → Checked 1299 tracked source, script and build/CI files: no bidirectional controls.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at baadbfaea3d968d451781ccd2ac5abf512c75049:
    • Debug (--preset dev): cmake --build --preset dev --target startup_stub_consumer -- -j 8 (3.51s), ctest --preset dev -R '^(startup_gfx2hlsl_watch|startup_run_ps1|startup_gfx2hlsl_capture|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure → 5/5 passed (124.66s).
    • Release /O2 (--preset release): cmake --build --preset release --target startup_stub_consumer -- -j 8 (1.09s), ctest --preset release -R '^(startup_gfx2hlsl_watch|startup_run_ps1|startup_gfx2hlsl_capture|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure → 5/5 passed (124.74s).
  • Local mutation checks (each reverted immediately):
    1. Disabled skip_failed .fail mtime check in pending_keys → caught by tests/startup_gfx2hlsl_watch_check.py (rc=1: watch pass, failure left unchanged by later passes, watcher output lines).
    2. Allowed .b as a ready marker in pending_keys (r'req_([0-9a-f]{16})\.(?:a|b|rtv)') → caught by tests/startup_gfx2hlsl_watch_check.py (rc=1: watch pass, one-shot pass).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044838345 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#pullrequestreview-6044838345). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:13:32Z. **Review:** COMMENTED --- Peer review at commit `baadbfaea3d968d451781ccd2ac5abf512c75049` (`PRODUCTION_REVIEW_ONLY`). ### Findings - **P2 — `run.ps1` `Stop-Process` does not terminate `ProcessPoolExecutor` child processes on Windows** (`tools/startup/run.ps1`): `Stop-Process -Id $translator.Id -Force` in the `finally` block only kills the parent `python.exe` `--watch` process. If the debugger exits while `translate_pending` is running a `ProcessPoolExecutor` batch, spawned worker `python.exe` processes (and any `fxc.exe` children) are left running. Using `taskkill /PID $($translator.Id) /T /F` (or a job object) would tear down the process tree. - **P2 — Unhandled decode/translation exceptions terminate `--watch`** (`tools/startup/gfx2hlsl.py`): `translate_request` catches `(Unsupported, OSError, UnicodeError)` and `translate_to` catches `Unsupported`. Any unexpected exception from a malformed request (e.g. `struct.error`, `ValueError`, `IndexError`) propagates out of `pool.map` and stops the `--watch` loop instead of recording a `.fail` for that key. - **Nit — `X2W_TRANSLATE_JOBS=""`** (`tools/startup/gfx2hlsl.py`): `int(os.environ.get('X2W_TRANSLATE_JOBS', 0))` raises `ValueError` when `X2W_TRANSLATE_JOBS` is set to an empty string (`int(os.environ.get('X2W_TRANSLATE_JOBS') or 0)` avoids it). - **Nit — Parallel key-pairing check** (`tests/startup_gfx2hlsl_watch_check.py`): All 8 synthetic RTV requests in `pending_run` fail with the same message (`unsupported: invalid RTV variant request`), so swapping keys in `pool.map` (tested locally with `list(reversed(keys))`) is not caught by the check. ### Verification - **Linux checks**: - `python3 -B tests/startup_gfx2hlsl_watch_check.py` → `startup_gfx2hlsl_watch_check passed` - `python3 -B tests/startup_run_ps1_check.py --text-only` → `0 failed (text only: requested)` - `python3 -B tests/startup_gfx2hlsl_capture_check.py` → `startup_gfx2hlsl_capture_check passed` - `python3 -B tests/startup_gfx2hlsl_operand_count_check.py` → `operand count checks: 0 failed` - `python3 -B tests/docs_links_check.py` → `Checked 17 Markdown files and 367 links.` - `python3 -B tests/bidi_controls_check.py` → `Checked 1299 tracked source, script and build/CI files: no bidirectional controls.` - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** at `baadbfaea3d968d451781ccd2ac5abf512c75049`: - **Debug (`--preset dev`)**: `cmake --build --preset dev --target startup_stub_consumer -- -j 8` (`3.51s`), `ctest --preset dev -R '^(startup_gfx2hlsl_watch|startup_run_ps1|startup_gfx2hlsl_capture|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure` → **5/5 passed** (`124.66s`). - **Release `/O2` (`--preset release`)**: `cmake --build --preset release --target startup_stub_consumer -- -j 8` (`1.09s`), `ctest --preset release -R '^(startup_gfx2hlsl_watch|startup_run_ps1|startup_gfx2hlsl_capture|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure` → **5/5 passed** (`124.74s`). - **Local mutation checks** (each reverted immediately): 1. Disabled `skip_failed` `.fail` mtime check in `pending_keys` → caught by `tests/startup_gfx2hlsl_watch_check.py` (rc=1: `watch pass`, `failure left unchanged by later passes`, `watcher output lines`). 2. Allowed `.b` as a ready marker in `pending_keys` (`r'req_([0-9a-f]{16})\.(?:a|b|rtv)'`) → caught by `tests/startup_gfx2hlsl_watch_check.py` (rc=1: `watch pass`, `one-shot pass`). AI-assisted; commands listed were executed locally.
NiiRoZz commented 2026-11-24 19:01:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-24T18:38:45Z.


Thanks for the review. All four points are addressed. The review was on baadbfae.

Point Fix Commit
P2: Stop-Process leaves the pool workers and fxc.exe running run.ps1 stops the watcher with taskkill /T /F. The startup_run_ps1 stub watcher now starts a child process, and the check requires both to be gone; reverting to Stop-Process -Force is detected. 7b4275cb
P2: an unexpected exception escapes pool.map and stops --watch Each request runs through translate_one, which writes translator error: <type>: <message> to <key>.fail and carries on. Tested with an injected ZeroDivisionError. 7b4275cb
Nit: empty X2W_TRANSLATE_JOBS raises translation_jobs() falls back to the processor count for empty, non-numeric or non-positive values, and the Windows cap of 61 is applied there. 7b4275cb
Nit: identical failure messages hide a key-order mix-up The 16 parallel-test requests are RTV variants that each name a different missing base, so every failure names its own base, and the test checks each printed result against its key. A mutant that reverses the key order is detected. 95d59d2f

Two more changes from a separate review pass, also in 7b4275cb:

  • Failure retry. The runtime never rewrites a request (publish_shader_request returns early when the file exists), so "retry once the request is rewritten" could never fire. The watcher's first pass now retries earlier failures once, and later passes skip them.
  • Batch size. chunksize is now len(keys) // (jobs * 4) instead of a fixed 8, so small scans use every worker.

The PR description has the updated verification and timings.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140935569 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#issuecomment-7140935569). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T18:38:45Z. --- Thanks for the review. All four points are addressed. The review was on `baadbfae`. | Point | Fix | Commit | |---|---|---| | P2: `Stop-Process` leaves the pool workers and `fxc.exe` running | `run.ps1` stops the watcher with `taskkill /T /F`. The `startup_run_ps1` stub watcher now starts a child process, and the check requires both to be gone; reverting to `Stop-Process -Force` is detected. | `7b4275cb` | | P2: an unexpected exception escapes `pool.map` and stops `--watch` | Each request runs through `translate_one`, which writes `translator error: <type>: <message>` to `<key>.fail` and carries on. Tested with an injected `ZeroDivisionError`. | `7b4275cb` | | Nit: empty `X2W_TRANSLATE_JOBS` raises | `translation_jobs()` falls back to the processor count for empty, non-numeric or non-positive values, and the Windows cap of 61 is applied there. | `7b4275cb` | | Nit: identical failure messages hide a key-order mix-up | The 16 parallel-test requests are RTV variants that each name a different missing base, so every failure names its own base, and the test checks each printed result against its key. A mutant that reverses the key order is detected. | `95d59d2f` | Two more changes from a separate review pass, also in `7b4275cb`: - **Failure retry.** The runtime never rewrites a request (`publish_shader_request` returns early when the file exists), so "retry once the request is rewritten" could never fire. The watcher's first pass now retries earlier failures once, and later passes skip them. - **Batch size.** `chunksize` is now `len(keys) // (jobs * 4)` instead of a fixed 8, so small scans use every worker. The PR description has the updated verification and timings. AI-assisted (Claude Code).
tedin7 commented 2026-11-24 20:00:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:28:04Z.

Review: COMMENTED


Peer review of head 95d59d2f7a6211708eca110e1d495638eaad9576 (retest after the earlier review at baadbfaea3d968d451781ccd2ac5abf512c75049).

Result: no P1/P2 defects found in the local verification. All four earlier points are addressed.

Earlier points:

  • Worker processes left running after the debugger exits (tools/startup/run.ps1): fixed. The finally block now runs taskkill.exe /T /F /PID $translator.Id, and tests/startup_run_ps1_check.py has a stand-in watcher that starts a child process and checks that both are gone, with two mutants (no stop at all, parent-only Stop-Process).
  • Unexpected translator exceptions ending --watch (tools/startup/gfx2hlsl.py): fixed. translate_one records any Exception as <key>.fail (translator error: ...), and the watch check covers it.
  • X2W_TRANSLATE_JOBS="": fixed. int(os.environ.get(...) or 0) inside a try, and the check covers '', 'abc', '-3'.
  • Key pairing in the parallel scan: fixed. The check now uses sixteen RTV variants that each name a different missing base, and requires every printed result to name its own base.

Read in full: the diff of tools/startup/gfx2hlsl.py, tools/startup/run.ps1, the two checks, CMake, the workflow list and the docs. Points checked:

  • Each request writes only its own <key>.* files, and the manifest is published with a temporary file and os.replace (gfx2hlsl.py:1392-1395), so killing the watcher in the middle of a translation cannot leave a half-written .txt.
  • The __main__ guard is in place for ProcessPoolExecutor on Windows (spawn), the 61-worker limit is applied, and an empty pending list gives zero jobs and no pool.
  • pending_keys yields each key once (an .a and an .rtv for the same key would need an FNV collision).
  • X2W_SHADER_CACHE is set in run.ps1:53 before the watcher starts.

Non-blocking notes (P3):

  • pool.map can still raise BrokenProcessPool if a worker is killed from outside (for example out of memory), which would end --watch. Catching it in the watch loop and retrying the pass would make the watcher match the new per-request error handling.
  • The Win2025 run used --regex '^(startup_stream_request_warp|startup_stubs)$', so startup_run_ps1 (the only check that executes taskkill) and startup_gfx2hlsl_watch did not run on Windows in that phase. The text-only mode of the run.ps1 check ran here on Linux.

Win2025 (coordinator run, Windows Server 2025 build 26100, WARP, target startup_stream_consumer): Debug dev and Release /O2 both gave startup_stubs and startup_stream_request_warp 2/2 passed (Debug 0.48 s and 1.42 s, Release 0.53 s and 1.45 s).

Linux checks run locally in a clean worktree at this head:

  • git diff --check origin/main...HEAD: clean
  • tests/docs_links_check.py: passed (17 files, 367 links)
  • tests/bidi_controls_check.py: passed (1299 files)
  • tests/startup_gfx2hlsl_watch_check.py: passed
  • tests/startup_run_ps1_check.py --text-only: 0 failed
  • tests/startup_gfx2hlsl_capture_check.py: passed
  • tests/startup_gfx2hlsl_operand_count_check.py: 0 failed

Mutations (local, each reverted with git checkout -- .; tree clean):

  1. zip(keys, pool.map(...)) changed to zip(reversed(keys), pool.map(...)): startup_gfx2hlsl_watch_check.py exits 1 (sixteen "names its own base" failures).
  2. except Exception changed to except ValueError in translate_one: the check exits 1 (a translator error escaped translate_pending).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045921193 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#pullrequestreview-6045921193). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:28:04Z. **Review:** COMMENTED --- Peer review of head `95d59d2f7a6211708eca110e1d495638eaad9576` (retest after the earlier review at `baadbfaea3d968d451781ccd2ac5abf512c75049`). **Result: no P1/P2 defects found in the local verification. All four earlier points are addressed.** Earlier points: - Worker processes left running after the debugger exits (`tools/startup/run.ps1`): fixed. The `finally` block now runs `taskkill.exe /T /F /PID $translator.Id`, and `tests/startup_run_ps1_check.py` has a stand-in watcher that starts a child process and checks that both are gone, with two mutants (no stop at all, parent-only `Stop-Process`). - Unexpected translator exceptions ending `--watch` (`tools/startup/gfx2hlsl.py`): fixed. `translate_one` records any `Exception` as `<key>.fail` (`translator error: ...`), and the watch check covers it. - `X2W_TRANSLATE_JOBS=""`: fixed. `int(os.environ.get(...) or 0)` inside a `try`, and the check covers `''`, `'abc'`, `'-3'`. - Key pairing in the parallel scan: fixed. The check now uses sixteen RTV variants that each name a different missing base, and requires every printed result to name its own base. Read in full: the diff of `tools/startup/gfx2hlsl.py`, `tools/startup/run.ps1`, the two checks, CMake, the workflow list and the docs. Points checked: - Each request writes only its own `<key>.*` files, and the manifest is published with a temporary file and `os.replace` (`gfx2hlsl.py:1392-1395`), so killing the watcher in the middle of a translation cannot leave a half-written `.txt`. - The `__main__` guard is in place for `ProcessPoolExecutor` on Windows (spawn), the 61-worker limit is applied, and an empty pending list gives zero jobs and no pool. - `pending_keys` yields each key once (an `.a` and an `.rtv` for the same key would need an FNV collision). - `X2W_SHADER_CACHE` is set in `run.ps1:53` before the watcher starts. Non-blocking notes (P3): - `pool.map` can still raise `BrokenProcessPool` if a worker is killed from outside (for example out of memory), which would end `--watch`. Catching it in the watch loop and retrying the pass would make the watcher match the new per-request error handling. - The Win2025 run used `--regex '^(startup_stream_request_warp|startup_stubs)$'`, so `startup_run_ps1` (the only check that executes `taskkill`) and `startup_gfx2hlsl_watch` did not run on Windows in that phase. The text-only mode of the run.ps1 check ran here on Linux. Win2025 (coordinator run, Windows Server 2025 build 26100, WARP, target `startup_stream_consumer`): Debug `dev` and Release `/O2` both gave `startup_stubs` and `startup_stream_request_warp` 2/2 passed (Debug 0.48 s and 1.42 s, Release 0.53 s and 1.45 s). Linux checks run locally in a clean worktree at this head: - `git diff --check origin/main...HEAD`: clean - `tests/docs_links_check.py`: passed (17 files, 367 links) - `tests/bidi_controls_check.py`: passed (1299 files) - `tests/startup_gfx2hlsl_watch_check.py`: passed - `tests/startup_run_ps1_check.py --text-only`: 0 failed - `tests/startup_gfx2hlsl_capture_check.py`: passed - `tests/startup_gfx2hlsl_operand_count_check.py`: 0 failed Mutations (local, each reverted with `git checkout -- .`; tree clean): 1. `zip(keys, pool.map(...))` changed to `zip(reversed(keys), pool.map(...))`: `startup_gfx2hlsl_watch_check.py` exits 1 (sixteen "names its own base" failures). 2. `except Exception` changed to `except ValueError` in `translate_one`: the check exits 1 (`a translator error escaped translate_pending`). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 21:00:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:25:13Z.

Review: COMMENTED


Retest at head d4bfa263ea (comment only, not an approval). Earlier review was at 95d59d2f7a.

Result: no P1/P2 findings. Both P3 notes of the earlier review are addressed.

  • BrokenProcessPool ending --watch: tools/startup/gfx2hlsl.py now has watch_pass(), which catches BrokenProcessPool, reports "translation pass interrupted, retrying", and does not mark the pass as done, so the next pass retries; the watch check covers it. docs/startup-runtime.md describes it.
  • Windows coverage of the taskkill path: the Win2025 run below includes tests/startup_run_ps1_check.py and tests/startup_gfx2hlsl_watch_check.py on Windows.

Read the PR diff against origin/main (8 files) in full for tools/startup/gfx2hlsl.py, tools/startup/run.ps1 and the two checks. The run.ps1 finally block runs taskkill.exe /T /F /PID on the watcher, and the check's stand-in watcher starts a child and requires both to be gone.

Linux checks run locally in a clean worktree at this head:

  • git diff --check origin/main...HEAD: clean
  • tests/docs_links_check.py: passed (18 files, 378 links)
  • tests/bidi_controls_check.py: passed (1327 files)
  • tests/startup_gfx2hlsl_watch_check.py: passed
  • tests/startup_run_ps1_check.py --text-only: 0 failed
  • tests/startup_gfx2hlsl_capture_check.py: passed

Mutations (local, each reverted; tree clean afterwards), run against tests/startup_gfx2hlsl_watch_check.py:

  1. 'except BrokenProcessPool' replaced by 'except KeyError': exits 1 ("a broken process pool escaped watch_pass").
  2. watch_pass returning False after a successful pass: exits 1 (the check's subprocess hits its timeout, because the first-pass retry never ends). Killed, though by a timeout and not a named assertion.

Win2025 (Windows Server 2025 build 26100, WARP, coordinator run, target startup_stream_consumer set): Debug dev and Release /O2 builds succeeded; startup_stubs and startup_stream_request_warp 2/2 passed in both (Debug 1.74 s, Release 1.57 s). Windows Python checks: tests/startup_gfx2hlsl_watch_check.py ok (2.6 s), tests/startup_run_ps1_check.py ok (126.9 s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046801824 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#pullrequestreview-6046801824). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T20:25:13Z. **Review:** COMMENTED --- Retest at head d4bfa263ea8b7d3daf7398ed209dd9163d663e65 (comment only, not an approval). Earlier review was at 95d59d2f7a6211708eca110e1d495638eaad9576. Result: no P1/P2 findings. Both P3 notes of the earlier review are addressed. - BrokenProcessPool ending --watch: tools/startup/gfx2hlsl.py now has watch_pass(), which catches BrokenProcessPool, reports "translation pass interrupted, retrying", and does not mark the pass as done, so the next pass retries; the watch check covers it. docs/startup-runtime.md describes it. - Windows coverage of the taskkill path: the Win2025 run below includes tests/startup_run_ps1_check.py and tests/startup_gfx2hlsl_watch_check.py on Windows. Read the PR diff against origin/main (8 files) in full for tools/startup/gfx2hlsl.py, tools/startup/run.ps1 and the two checks. The run.ps1 finally block runs taskkill.exe /T /F /PID on the watcher, and the check's stand-in watcher starts a child and requires both to be gone. Linux checks run locally in a clean worktree at this head: - git diff --check origin/main...HEAD: clean - tests/docs_links_check.py: passed (18 files, 378 links) - tests/bidi_controls_check.py: passed (1327 files) - tests/startup_gfx2hlsl_watch_check.py: passed - tests/startup_run_ps1_check.py --text-only: 0 failed - tests/startup_gfx2hlsl_capture_check.py: passed Mutations (local, each reverted; tree clean afterwards), run against tests/startup_gfx2hlsl_watch_check.py: 1. 'except BrokenProcessPool' replaced by 'except KeyError': exits 1 ("a broken process pool escaped watch_pass"). 2. watch_pass returning False after a successful pass: exits 1 (the check's subprocess hits its timeout, because the first-pass retry never ends). Killed, though by a timeout and not a named assertion. Win2025 (Windows Server 2025 build 26100, WARP, coordinator run, target startup_stream_consumer set): Debug dev and Release /O2 builds succeeded; startup_stubs and startup_stream_request_warp 2/2 passed in both (Debug 1.74 s, Release 1.57 s). Windows Python checks: tests/startup_gfx2hlsl_watch_check.py ok (2.6 s), tests/startup_run_ps1_check.py ok (126.9 s). AI-assisted; commands listed were executed locally.
NiiRoZz commented 2026-11-24 21:01:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-24T20:08:42Z.


Thanks for re-checking.

  • BrokenProcessPool: fixed in d4bfa263. A pass now goes through watch_pass(), which reports a broken pool on stderr and returns; the next pass retries those requests, and the watcher keeps running. Tested by injecting a BrokenProcessPool; a mutant that drops the catch is detected.
  • Windows coverage: agreed, the Win2025 phase you cite didn't run them. Locally on Windows 11 with Windows PowerShell 5.1 (no pwsh), both startup_run_ps1 (including the child-process and taskkill /T mutants) and startup_gfx2hlsl_watch pass on d4bfa263. The repository's own Windows job also runs both.
  • ead2227a merged current main: run.ps1 keeps both new switches (-Translate, -StartupBelow40), and the docs take upstream's X2W_D3D12_RENDER row. #1750 and this PR still merge into main in either order.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143102968 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#issuecomment-7143102968). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-24T20:08:42Z. --- Thanks for re-checking. - **`BrokenProcessPool`**: fixed in `d4bfa263`. A pass now goes through `watch_pass()`, which reports a broken pool on stderr and returns; the next pass retries those requests, and the watcher keeps running. Tested by injecting a `BrokenProcessPool`; a mutant that drops the catch is detected. - **Windows coverage**: agreed, the Win2025 phase you cite didn't run them. Locally on Windows 11 with Windows PowerShell 5.1 (no pwsh), both `startup_run_ps1` (including the child-process and `taskkill /T` mutants) and `startup_gfx2hlsl_watch` pass on `d4bfa263`. The repository's own Windows job also runs both. - `ead2227a` merged current `main`: `run.ps1` keeps both new switches (`-Translate`, `-StartupBelow40`), and the docs take upstream's `X2W_D3D12_RENDER` row. #1750 and this PR still merge into `main` in either order. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 02:01:22 +00:00
R0Y00 commented 2026-11-25 02:02:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:10:54Z.


Superseded by #2120 (6921dcfd), which rebased your watcher and launcher work onto current main while retaining the later bytecode-resume behavior. Thanks for the original implementation and controls. I reran the watcher, translator and PowerShell 5.1/7 process-tree checks at the merged candidate. The original review and contribution remain linked here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149287847 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1749#issuecomment-7149287847). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T01:10:54Z. --- Superseded by #2120 (6921dcfd), which rebased your watcher and launcher work onto current main while retaining the later bytecode-resume behavior. Thanks for the original implementation and controls. I reran the watcher, translator and PowerShell 5.1/7 process-tree checks at the merged candidate. The original review and contribution remain linked here.

Pull request closed

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!1742
No description provided.