xcl run: coordinate worker claims via OS locks and recover incomplete builds #2712
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2712
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2712"
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?
@ZekkJJ on GitHub · 2026-11-26 07:59 UTC · original
ZekkJJ:fix/safe-claim-ownership→nvidia-dev· +728 −122 · 1 files · 1 commits · draftHardens multi-worker offline compute pipeline preparation (
crates/xcl/src/shaders.rs) against missing cache directories, corrupt cached blobs, timeout claim theft, orphaned.claimdeadlocks, and silent incomplete worker termination.Part of #2688 (Workstream 7). Based on
nvidia-dev(af2cecc4).What is in it
crates/xcl/src/shaders.rs:.claimacquisition and separate lock contention (HeldElsewhere) from filesystem errors (Unavailable).try_cached_pso+Claim::acquire+ post-claim cache reload recheck), holdingID3DBlobalive across atomicdriver_cache::writereplacement and warning/counting failed writes..claimownership with Windowsshare_mode(0) | FILE_FLAG_DELETE_ON_CLOSE(withDELETEaccess and boundedERROR_ACCESS_DENIEDretry for transientSTATUS_DELETE_PENDING) so active builds are never stolen after 30 minutes, crashed/killed workers release locks immediately, and unlocked orphaned.claimfiles from older builds are adopted and deleted on drop.PipelineCacheIdentityand panic-safeInflightGuard/RunningPermitdrop guards.compute pipelines:worker summaries on stderr underXCL_PRECOMPILE_PARENT, run automatic single-worker recovery on worker failure/missing summary, and returnErrwhenever incomplete pipelines remain.Tested
32.0.16.1656),rustc 1.98.1(48a229cea).cargo test --locked -j 2 -p xcl --lib shaders:: -- --test-threads=1:25 passed; 0 failed; 0 ignored(1.09s;SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)andretail_pack_sampleskipped withoutXCL_SAMPLE_RPF). Covers OS subprocess tests forTerminateProcessclaim release, 4-worker simultaneous races over missing and corrupt blobs, orphaned.claimadoption,>2hactive claim preservation, failed writes,InflightGuardpanic unwinding, and worker recovery policy.cargo test --locked -j 2 -p xcl --test e2e -- --test-threads=1:4 passed; 0 failed; 0 ignored(18.85s).cargo build --locked --release -j 2 -p xcl: passed (0errors).8b113eebrelease binary, isolated caches, captured compute shader corpus with 69 pipeline entries / 43 unique native driver blobs):fresh_w4: 4/4 workers exited0in72,195.44 ms(65 made, 22 from_disk, 4 elsewhere, 0 errors, 0 write_errors,43/43blobs present,0leftover.claim/.tmp, peak aggregate commit1,516.23 MiB); warm 1-worker verification hit69/69 from_diskin5,340.57 ms.corrupt_w4(pre-corrupted driver blobs): 4/4 workers exited0in76,181.68 ms(66 made, 23 from_disk, 3 elsewhere,0leftover corrupt blobs/claims/tmps,43/43valid); warm verification hit69/69 from_diskin4,325.83 ms.orphan_claims_w4(pre-seeded unlocked.claimfiles): 4/4 workers exited0in61,108.44 ms(65 made, 22 from_disk, 4 elsewhere,43/43blobs,0leftover.claimfiles).kill_recovery_w2: terminating 1 of 2 workers (exit -1, 0) left10missing blobs and0orphaned.claimlocks; single-worker recovery finishedexit 0in104,600.68 ms(69 made, 59 from_disk,43/43blobs,0claims/tmps); warm verification hit69/69 from_diskin5,103.05 ms.nvidia-dev(af2cecc4) baseline comparison on this host (--test-threads=1):shaders::tests11 passed, 0 failed,e2e4 passed, 0 failed; pre-existing baseline failures on unmodifiedaf2cecc4intexture_upload::tests(6 passed, 2 failed),d3d12_mesh_stream(2 passed, 1 failed),gpu_compute_e2e(6 passed, 1 failed), andgpu_two_pass_cache_e2e(0 passed, 1 failed).Regression run
scripts/smoke.ps1execution on an unpacked retail build before marking ready for review.Not tested
cargo test --workspaceafter the final commit (unmodifiedaf2cecc4baseline already fails intexture_upload::tests,d3d12_mesh_stream,gpu_compute_e2e, andgpu_two_pass_cache_e2e), pairedscripts/smoke.ps1(no retail title directory on this machine), AMD / Intel GPUs, Linux / Wine.AI use
Gemini); assisted with implementation, subprocess/unit/GPU tests, multi-worker release verification, and PR preparation under author direction.@gsucristo on GitHub · 2026-11-26 08:10 UTC · original · reviewed
Nice hardening overall — replacing the timeout-based
.claimheuristic withshare_mode(0) | FILE_FLAG_DELETE_ON_CLOSE+DELETEaccess is the right primitive on Windows (and maps cleanly towineserverhandle teardown on Wine/Proton),ID3DBlobstays alive acrossdriver_cache::write, theInflightGuard/RunningPermit/DescGuarddrop guards have clean lock ordering (inflightbeforerunning) and panic safety, and the OS subprocess tests cover the tricky failure modes well.A few concrete issues and nits I noticed while reading through
crates/xcl/src/shaders.rs:1. Deterministic worker failures trigger a redundant recovery pass and lose the error breakdown
In
precompile, a worker running underXCL_PRECOMPILE_PARENTprints thecompute pipelines: ...summary to stderr and then returnsErr(...)wheneverfailed + refused + capped + write_failures > 0, causing the worker process to exit non-zero (worker_failures > 0).In
evaluate_compute_workers,worker_failures > 0is checked before inspectingtotals:Because of that ordering:
capped,refused, orrecord_errorscount causesevaluate_compute_workersto returnNeedsRecoveryinstead ofIncomplete, re-running the entire pack in a single-worker recovery pass.evaluate_compute_workers(1, 1, &rec_summaries)hitsNeedsRecoveryagain and returns"Shader preparation incomplete after worker failure: 1 of 1 workers failed (1/1 reported completion)", hiding the actualrefused/capped/record_errors/write_errorscounts.compute_summary_and_worker_policy_enforce_recovery_and_completenessdidn't catch this because it passesworker_failures = 0for theIncompletecases.)Checking
if parsed == workers && refused + capped + record_errors + write_errors > 0 { return ComputeWorkersOutcome::Incomplete(...); }before theworker_failures > 0branch (or letting workers exit 0 after emitting their summary and letting the parent fail ontotals) would fix both issues.2. Double
driver_cache::loadon the hot pathIn
make_one:let initial_cached = path.as_deref().and_then(driver_cache::load);reads the entire.psofile even when!over_cap, then discards it and reads the file again after acquiringInflightGuardandRunningPermit.if over_cap(e.g.if over_cap && path.as_deref().and_then(driver_cache::load).is_none()) avoids doubling file reads/allocations for normal cached pipelines.3. Windows
renamecontention when replacing a corrupt blobConcurrent workers call
driver_cache::load(path)beforeClaim::acquire(path). When the claim owner replaces a corrupt blob viadriver_cache::write(std::fs::rename(&tmp, p)), a concurrent reader still insidestd::fs::read(path)can transiently causerenameto fail withERROR_ACCESS_DENIEDon Windows (Rust'sstd::fs::renamedoes not useFILE_RENAME_FLAG_POSIX_SEMANTICS). Right now that incrementswrite_failuresand removespath. A short bounded retry onrenameindriver_cache::write(similar to theSTATUS_DELETE_PENDINGretry inClaim::acquire) would avoid spurious write failures under multi-worker contention on corrupt blobs.4. Minor nits
try_cached_psoleaves a dangling pointer indesc.CachedPSO: Whentry_cached_psoreturnsNone,desc.CachedPSO.pCachedBlobstill points to the droppedbytesslice. Line 1729 currently resetsdesc.0.CachedPSO = Default::default()before the uncached compile so there is no UB today, but clearingdesc.CachedPSOinsidetry_cached_psobefore returning keeps the helper self-contained.XCL_PRECOMPILE_SLICEin recovery:worker_commandstripsXCL_HOST,XCL_PREPARATION_PARENT, etc., but notXCL_PRECOMPILE_SLICE. ClearingXCL_PRECOMPILE_SLICEinworker_command(or in the recovery pass) ensures an inherited env var can't restrict the single-worker recovery pass to a single slice.Claim::acquirebackoff &Unavailablecleanup:3 × 2ms(6 ms) for transientSTATUS_DELETE_PENDINGis usually plenty, though under antivirus/filter-driver load on Windows a slightly longer stepped backoff (e.g.2, 5, 10, 20 ms) is cheap and reduces spuriousUnavailablefallbacks. Also, ifclaim.is_none()(Unavailable), consider skippingstd::fs::remove_file(path)onhad_corruptso an uncoordinated worker can't delete a blob another worker just published.over_cap: The comment aboveif initial_cached.is_none() && over_capstill says "the pass finishes without it, and the runtime builds it when a title needs the pipeline", whereaspipelines_in_workersnow fails closed withErrwhencapped > 0(matching single-workerprecompile). Worth confirming whethercapped > 0should fail multi-worker launch preparation or if the comment should be updated.@luckyteagirl on GitHub · 2026-11-26 08:12 UTC · original · reviewed
At head
8b113eeb3e306ba85aefcd3d146bbcbb25f07199, the fourrace_and_publishsubprocesses only wait for thegofile. The winner holds the.claimfor a fixed 40 ms (shaders.rs:2018), then releases it; the parent later requires exactly oneOUTCOME=ACQUIRED(shaders.rs:2181). A child delayed by process startup or scheduling for more than 40 ms can first tryClaim::acquireafter the winner has released it, legitimately acquire a second time, and fail this test despite correct exclusive ownership. Could the winner wait, with a bounded timeout, until the other children acknowledge their acquisition attempts before releasing, or could the assertion test non-overlap without assuming all attempts fit inside 40 ms? This would make the subprocess test robust on loaded CI hosts.This is a source-derived test-race review of the exact head; I did not run a delayed-child reproduction. AI use: OpenAI Codex (GPT-6.2 Sol) identified the interleaving, and I checked the child role and parent assertion before posting.
@KDenKC on GitHub · 2026-11-26 08:12 UTC · original
Source review of
8b113eeb, no run. A refused or capped pipeline seems to take the recovery path instead ofIncomplete:XCL_PRECOMPILE_PARENTset, soprecompilereturnsErrwhenfailed + refused + capped + write_failures > 0(shaders.rs:2847). The worker then exits non-zero, andin_workerscounts it infailed(:2449-2451).evaluate_compute_workerschecksworker_failures > 0first (:2316), so the result isNeedsRecovery, neverIncomplete. The refused/capped counts from the summaries are not reported.:2359). Its worker meets the same refusal, exits non-zero, and the pass ends inErr("… incomplete after worker failure …"). That reachesprepare_for_launchthrough?(:1843), andxcl runstops before the title.So one pipeline the driver refuses, or one over
XCL_PIPELINE_MAX_KB, costs a full single-worker pass and then the launch. IfIncompleteis meant for that case, the worker could exit 0 after printing its summary when only refusals, caps or write failures occurred (keeping a non-zero exit for crashes and record failures).evaluate_compute_workerswould then see the counts.Not tested: no build or run of this head on our side. We are running
nvidia-devaf2cecc4cold on an RTX 5090 tonight, and will say here if a refusal shows up there.AI use: Gemini (Antigravity) flagged it in a review; Claude Code (Claude Opus 5.5) traced it through the source at
8b113eeband wrote this.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.