Repository navigation
rdna2spirv: start a tool again when a Windows job refuses it with ERROR_NOT_ENOUGH_QUOTA (COMPUTE-WORKER-SPAWN-QUOTA) - #2367
Conversation
…OR_NOT_ENOUGH_QUOTA (COMPUTE-WORKER-SPAWN-QUOTA) The Windows compute worker runs in a job that allows two active processes, itself and one tool. The job can still count a tool that has just exited, so CreateProcess refuses the next one with winerror 1816 and the worker fails (test_translate_pipeline_compute: 9 of 12 runs on a busy Windows 11 host). _run_spirv_tool now starts a refused tool again with a doubling delay for at most 2 s, then raises as before; other errors are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lixonik
left a comment
There was a problem hiding this comment.
Windows 11: all 5 quota tests passed, including the native restricted worker's back-to-back tools, bounded retries and unrelated OSError handling. No findings from these checks.
AI-assisted.
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 check of #2367 (COMPUTE-WORKER-SPAWN-QUOTA). The behaviour is Windows-only, so what runs here is the retry control flow and the rest of the tree; I say below what this machine cannot prove.
Tested head 80930f0d1 merged onto main bd6ba97ab as merge 9661baf6b (clean merge). main has moved two commits since (bdbc7e923, the precompile skip-list work); neither touches tools/rdna2spirv.py or tests/.
Environment: Apple M3 Pro, arm64 (subgroups 4..32), macOS 27.2.1, CPython 3.15.2, Apple clang 21.0.0, SPIRV-Tools v2026.4, llvm-mc 23.1.5, MoltenVK 1.4.0; KosmicKrisp and lavapipe = Mesa 26.3.0.
The new test bites
- At the head:
python -I tests/test_rdna2spirv_spawn_quota.py->Ran 5 tests ... OK (skipped=1). The skip is the nt-only job-object test. - Negative control (new test file kept,
tools/rdna2spirv.pyput back tomain's version):FAILED (failures=1, errors=1, skipped=1)- ERRORtest_quota_refusals_are_started_again(noSPAWN_RETRY_SECONDS), FAILtest_a_refusal_that_lasts_is_raised_once_the_time_is_up. So the two behaviour tests are not vacuous. - What this run cannot show: the OS half. Off Windows
OSErrorhas no.winerror, so the fake inwin_error()is the only 1816 the code ever sees here, and the 150-spawn job test is skipped. I did not run it.
No regressions
- Semantic suite: 500 files / 6,367 tests / 0 files failed at
mainbd6ba97ab, and the same at9661baf6b. Delta 0. (The new file lives intests/, nottests/semantic/, so the suite does not count it; it was run on its own above.) - GPU fixtures (268): MoltenVK 195 PASS / 3 FAIL / 70 SKIP at both
mainand the merge; KosmicKrisp 190 / 5 / 73 at both. A line diff of the PASS/FAIL/SKIP output differs only in the per-run temp directory quoted in SKIP reasons. The failures are the pre-existing ones atmain(MV:cs_fma_fused,cs_imgatomic_ext,ps_ssharp; KK:cs_bvh,cs_bvh32,cs_imgatomic_ext,ps_cndmask_sign_mods,ps_valu16_mad_sel).
Static
_run_spirv_toolis the onlysubprocess.runintools/rdna2spirv.py(line 19949 at the head), andspirv-as,spirv-optandspirv-valall go through it, so the shard path is covered. Nothing else inscripts/translate_pipeline_compute.pystarts a process; the worker imports the translator.- The limit being worked around is
info.basic.processes = (2 if worker else 0)inscripts/compute_workers_win.py(job()/verify()), and only CreateProcess can produce 1816 here. A refusedCreateProcessleaves no child behind, so re-running does not repeat work, andFileNotFoundErroris still caught before the genericOSError. check_no_game_data.pyon both changed files: clean.compileall: clean.
Findings (none blocks)
tools/rdna2spirv.py:19941-19958: when the budget runs out the originalOSErroris re-raised unchanged, so the traceback is the same[WinError 1816]a first refusal gives. Nothing says ~28 starts were attempted over 2 s; on a loaded host the user has no clue the retry ran out rather than never existing. Anexc.add_note(...)(3.11+) with the attempt count and elapsed time would cost nothing.SPAWN_RETRY_SECONDS = 2.0is a guess at how long the job counts a tool that has exited. The PR measures refusal rates (5-9%), not the longest refusal streak, and the Windows test shows 150 back-to-back starts passing on one host. If a slower machine holds the slot longer than 2 s, the same failure returns with no way to raise the budget. Measuring the lag (loop until 1,000 starts pass and record the longest run of refusals) or taking the seconds from the environment would make the number defensible.- Minor: this is the second bounded doubling retry in
tools/(tools/replace_retry.pyhas one with 5 s); keeping them separate is fine, but a line saying why it is not shared would help the next reader.
The cause in the description matches the code: the job counts the worker plus one tool, the exited tool can be counted for a moment, and 1816 is CreateProcess refusing before the child exists.
No game files. AI-assisted.
…t (COMPUTE-WORKER-SPAWN-QUOTA) Review follow-up. With every hardware thread busy at the workers' priority, the longest run of ERROR_NOT_ENOUGH_QUOTA refusals in the worker's job was 3.76 s, past the 2 s budget, so SPAWN_RETRY_SECONDS is now 10 s, with the measurement in a comment. When the budget runs out, the OSError gets a note with how many times the tool was refused and for how long, so the traceback shows that the retry ran and ran out. The comment says why the backoff is not shared with tools/replace_retry.py. The unit test checks the note, and that other errors get none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the careful check. All three points are taken in the new commit:
Re-tested on the new head: AI-assisted (Claude Code). |
lixonik
left a comment
There was a problem hiding this comment.
Retested the updated retry budget and error note on Windows 11 with CPython 3.12.1, merged with fac8b4bb9. All five quota tests passed. For an additional check, I occupied the second slot in a real two-process Windows job for the whole retry window. _run_spirv_tool raised WinError 1816 with the note cmd: refused 103 times in 10.0 s (SPAWN_RETRY_SECONDS = 10.0). After releasing the second slot, the next command completed successfully in the same worker.
AI-assisted.
Claimed in the coordination issue as: COMPUTE-WORKER-SPAWN-QUOTA (#1608 (comment))
What and why
scripts/translate_pipeline_compute.py --jobs Non native Windows fails now and then withand
tests/test_translate_pipeline_compute.py(WorkerParity) fails the same way.Cause: each Windows worker runs in a job that allows two active processes, itself and one tool (
TWO_ACTIVEinscripts/compute_workers_win.py). The worker runs spirv-as, then spirv-opt or spirv-val, one after another through_run_spirv_toolintools/rdna2spirv.py.subprocess.runreturns once the previous tool has exited, but the job can still count that process for a moment, soCreateProcessrefuses the next tool with ERROR_NOT_ENOUGH_QUOTA (1816).Measured with a minimal script that makes the job with
compute_workers_win.job(mib, True), puts a Python child in it and has the child start a short tool back to back (Windows 11 26300, Python 3.14.10, the machine busy with other work):spirv-val --version, in the jobcmd /c rem, in the jobspirv-val --version, no jobChange:
_run_spirv_toolstarts a tool again whenCreateProcessrefuses it with winerror 1816, with a doubling delay from 5 ms up to 100 ms, for at mostSPAWN_RETRY_SECONDS(10 s); then the error is raised as before, with a note saying how many times the tool was refused and for how long. The refused tool never started, so starting it again repeats nothing. It is the backofftools/replace_retry.pyuses for renames.New test,
tests/test_rdna2spirv_spawn_quota.py(standard library):cmd /c remthrough_run_spirv_toolinside a job made bycompute_workers_win.job(), as the worker does.On
mainthe new file fails (2 failures, 1 error, including the job test with WinError 1816); with the change it passes.Tested
On
fbf100b1b, Windows 11 Home 26300.9974, Python 3.14.10, SPIRV-Tools v2026.4 (Vulkan SDK 1.4.363.0), with the machine busy translating shaders in the background, as in the table:python -I tests/test_translate_pipeline_compute.py, 12 runs each:main3 passed, 9 failed (all WinError 1816); this branch 12 passed.python -I tests/test_rdna2spirv_spawn_quota.py: fails onmain; passes 7 of 7 runs here.python -m compileall -q make_game.py tools tests: clean.rdna2spirv: all pass. (test_make_game_argparse.pyfailed once under the load and passed 3 of 3 reruns, onmainas well.)python -I scripts/run_semantic_tests.py tests/semantic: 500 files, 6365 tests, 0 files failed.python -I scripts/check_no_game_data.pyon both files: passes.GPUs tested: n/a (no GPU involved)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator rule; this changes how the tools are started)🤖 Generated with Claude Code