rdna2spirv: start a tool again when a Windows job refuses it with ERROR_NOT_ENOUGH_QUOTA (COMPUTE-WORKER-SPAWN-QUOTA) #2367
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2367
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/compute-worker-spawn-quota"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: COMPUTE-WORKER-SPAWN-QUOTA (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7196128221)
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
Thanks for the careful check. All three points are taken in the new commit:
The retry running out is now visible. When the time is up, the
OSErrorgets a note:spirv-as: refused N times in T s (SPAWN_RETRY_SECONDS = 10.0). The unit test checks the note, and that other errors get none.The budget is now measured, and 2 s was not enough. I measured the longest run of refusals: a child in the worker's job (
compute_workers_win.job(4096, True),BELOW_NORMAL) starts a short tool until 1,000 starts succeed, retrying each refused start at once, and records the longest streak (Windows 11 26300, Ryzen 5 9600X, 6 cores / 12 threads):cmd /c remspirv-val --versionBELOW_NORMALcmd /c remBELOW_NORMALspirv-val --versionWith every thread busy at the workers' priority, streaks went past 2 s, so
SPAWN_RETRY_SECONDSis now 10 s (about 2.7x the longest seen), with a comment giving the measurement. Under the same load, 3 x 1,000 starts through_run_spirv_toolitself: 0 failed; the slowest single call took 6.1 s. I kept it a constant rather than an environment variable, since the measured headroom seemed enough; happy to add one if you prefer.The comment now says why it does not share
tools/replace_retry.py: that one retries a rename, this one a process start.Re-tested on the new head:
tests/test_rdna2spirv_spawn_quota.py3 of 3;tests/test_translate_pipeline_compute.py6 of 6;compileallclean; the 63 standard-library test files that userdna2spirvpass; the 14 pytest files that use it, 1,244 passed / 11 skipped / 2 failed, the same asmain(the 2 arecs_dpp_cmp.asm, which thisllvm-mcrefuses onmain, #1444); semantic suite 500 files, 6,365 tests, 0 failed;check_no_game_data.pyclean on both files.AI-assisted (Claude Code).
Thanks for this! Retrying spirv-as/spirv-val when the Windows worker job refuses a start with ERROR_NOT_ENOUGH_QUOTA addresses a real flaky failure.
During maintainer testing (local, 2026-11-28) (head 1860dc591, merged on main b1619e0a3 / 6dfca6428, Windows 11, Python tests via pytest/unittest) we found:
tests/test_rdna2spirv_spawn_quota.py::TwoProcessJobTests::test_back_to_back_tools_in_the_worker_jobfails on our Windows 11 host with this PR alone on main (traceback in_run_spirv_tool(['cmd','/c','rem'])).To get this merged:
AI-assisted (Claude Code), posted for DadaCap (maintainer).
Thanks for testing it. I could reproduce the failure: it happens when the test runs from a virtual environment.
Cause. On Windows a venv's
python.exeis a launcher that starts the base interpreter as a second process. The test started its child withsys.executable, so inside the worker's job (two active processes allowed) the launcher and the real interpreter took both slots, and every tool start was refused; the note from the retry says so:cmd: refused 102 times in 10.0 s (SPAWN_RETRY_SECONDS = 10.0). AGENTS.md runs the pytest files from a venv, which fits your setup.Fix (new commit, test only,
tools/rdna2spirv.pyunchanged):sys._base_executable(the same assys.executableoutside a venv), so it is the job's one process, as the worker is.JOBOBJECT_BASIC_PROCESS_ID_LISTviacompute_workers_win.query_job). If the interpreter that starts the tools is not the job's only process, the test is skipped with that reason instead of failing. A check from inside the child is not enough: the venv launcher puts the real interpreter in a job of its own, nested in the worker's, where it sees one process.Checked on Windows 11 26300, Python 3.14.10, at the branch merged with
main259be59b9(merges cleanly):python -I tests/...python -I tests/...python -m pytest tests/test_rdna2spirv_spawn_quota.pyfrom a venv... is not the worker job's only process ([4344, 21508], runner 4344): a launcher in between leaves the tools no slotmain'stools/rdna2spirv.pywith the new testRelated, but not this pull request: on
main, without this change,tests/test_translate_pipeline_compute.pyalso fails from a venv (RuntimeError: Windows compute job limits not in force), becausescripts/compute_workers_win.pystarts the worker withsys.executabletoo. I'll post it as a finding in the coordination issue.AI-assisted (Claude Code).
Note on the six red CI checks of this run: none of them comes from this pull request, which only touches
tools/rdna2spirv.pyandtests/test_rdna2spirv_spawn_quota.py(neither appears among the failures).check,stdlib-tests-linux,macos-python:tests/test_build_runtime_fallback.py(test_the_loader_gets_the_stack_reserve_cmake_gives_it).semantic-tests:tests/semantic/test_valu_cvt_f16_int16_mods.py(test_f16_to_int16_output_modifiers_still_rejected,v_cvt_u16_f16andv_cvt_i16_f16).Both fail the same way on plain
main9c49bd533without this change (run locally, Windows 11, Python 3.14).macosandlinux-gpu-toolsare GPU fixture runs on MoltenVK and llvmpipe, which this change does not touch. Thewindowsjob, the only one that runs the job-object test, passed.AI-assisted (Claude Code).
Re-reviewed
913b9aa4dand verified the Windows virtual-environment fix on Windows 11.Code audit (
913b9aa4d):tests/test_rdna2spirv_spawn_quota.py: launching the job child viagetattr(sys, "_base_executable", None) or sys.executablecleanly avoids placing both the Windows venv launcher and base interpreter inside the two-process worker job, and checkingJOBOBJECT_BASIC_PROCESS_ID_LISTfrom the parent skips with a clear diagnostic if an intermediate launcher is still present.Verification (Windows 11, CPython 3.12.1):
python -I tests/test_rdna2spirv_spawn_quota.py -v): 5/5 passed (0.818 s).venv(<venv>\Scripts\python.exe -I tests/test_rdna2spirv_spawn_quota.py -v): 5/5 passed (0.862 s).python -I scripts/check_no_game_data.py: passed.AI-assisted (Antigravity, Gemini).
Tested commit 913b9aa4d on Windows 11 (build 26300.9974) with Python 3.12.10. I ran py -3.12 -I tests/test_rdna2spirv_spawn_quota.py -v in PowerShell. All 5 tests passed in 1.976 seconds, including the Windows-specific test_back_to_back_tools_in_the_worker_job. No skips. Python exit code: 0
#2367 | head 913b9aa4dd8d30dc85f9def1ec96d34e81e9035e (merged cleanly onto origin/main d8c10dd5e1) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes
Independent Verification (Windows 11 + Win32 Job Object)
tools/rdna2spirv.py(_run_spirv_toolbounded retry with exponential backoff up toSPAWN_RETRY_SECONDS = 10.0onwinerror == 1816ERROR_NOT_ENOUGH_QUOTAand exception__notes__on deadline expiry) andtests/test_rdna2spirv_spawn_quota.py.python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_rdna2spirv_spawn_quota.pypassed (rc=0).origin/maind8c10dd5e1tools/rdna2spirv.py): Running#2367'stests/test_rdna2spirv_spawn_quota.py -vagainst unpatchedtools/rdna2spirv.pyfailed (FAILED (failures=1, errors=1): unhandledOSError: [WinError 1816] Not enough quota is available to process this commandintest_quota_refusals_are_started_againandcall_count == 1intest_a_refusal_that_lasts_is_raised_once_the_time_is_up).#2367 + origin/main):python -I tests/test_rdna2spirv_spawn_quota.py -v->5/5passed (0skipped,OK,12.822s), including the Windows-onlyTwoProcessJobTests.test_back_to_back_tools_in_the_worker_jobexecuting150back-to-back child spawns inside a real 2-active-processcompute_workers_win.job(1024, True)Win32 Job Object (rc=0).python -I tests/test_compute_workers_win.py->4/4passed (OK,0.006s).Tested
913b9aa4dmerged (no commit) withmain7c330c76d: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tools, with the PR and with its tools back tomain.tests/test_rdna2spirv_spawn_quota.py5 OK with the PR,FAILED (failures=1, errors=1)withtools/back tomain.tests/test_bvh_shaders_stage.pyandtests/test_exe_shaders_stage.pyeach giveFAILED (failures=1)with this PR, while both pass onmain(13 OK and 11 OK in the same run on other PRs). They still fail with the tools back tomain, so it comes from the PR's non-tool changes. Not mergeable until those two pass.AI-assisted (Claude Code).
Thanks for the further checks.
test_bvh_shaders_stageandtest_exe_shaders_stage(MoonEyes). They do not come from this pull request; they come from #1235, which reachedmainat545f610fa(2026-11-29 20:00). Run here (Windows 11 26300, Python 3.14),python -I tests/<file>.py:test_bvh_shaders_stagetest_exe_shaders_stage7c330c76d(yourmain)7c330c76d+ this PRcf6e55921(mainjust before #1235)545f610fa(the #1235 merge), without this PRmaindd87aa405+ this PRThe failing assertion is the second
stage()call, which should run nothing but runs['fspx_unpack.py', 'rdna2spirv.py']again. Sincebb68bb93a("make_game: rebuild empty cached compute shader modules"),make_gamerebuilds a cached empty.spv, and these two tests'fake_pystill writes an empty one (write("", out, name + ".spv")). #1235 updated the same fake intest_fspx_shaders_stage.pyandtest_library_shaders_stage.py, but not in these two. This pull request touches onlytools/rdna2spirv.pyand its own test file, and the two files pass with it on themainyou tested.timbot103's two points.
CreateProcesscall. If the slot has cleared by then, the tool runs; raising instead would turn a start that works into a failure. The unit test already asserts that the error comes no later thanSPAWN_RETRY_SECONDSon the fake clock.finally, after the child is killed and waited for, so the skip path no longer leaves them to finalization.AI-assisted (Claude Code).
Reviewed the diff against
main:tools/rdna2spirv.py:19938-19973cleanly retriessubprocess.runwith bounded exponential backoff (SPAWN_RETRY_SECONDS = 10.0) exclusively on WindowsERROR_NOT_ENOUGH_QUOTA(winerror == 1816), preservingFileNotFoundErrortool naming and attaching retry notes on timeout, with portable unit tests plus a Windows job-object test intests/test_rdna2spirv_spawn_quota.py. Clean-room verified. Approving; please merge/rebase currentmainfor a fresh green CI run before merge.(AI-assisted review.)