Shaders: bound direct sweep workers and report panics #1997
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!1997
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1997"
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?
@luckyteagirl on GitHub · 2026-11-25 00:32 UTC · original
luckyteagirl:codex/shader-sweep-workers→main· +102 −19 · 1 files · 1 commits · openAddresses item 3 of #1896.
xcl shaders --directcould accumulate detached translation workers after timeouts, each using a large translator stack. The sweep also conflated panics with timeouts. This rebases the fix onto currentmainafter #2285 changed the option parser.What is in it
--threads(maximum 32). A timed-out translation keeps its slot until it actually completes. If--threadsworkers remain active after their callers time out, the sweep stops early with exit 2 and marks its sample incomplete; it does not launch more detached workers.Tested
f053f279fe899f341cdfc9d0aa5e1de09cfbe116onmain6d12f58a229bc73889878a448c64dc3af25eeba0. Windows 11 build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (driver30.0.13002.13003), Rust 1.99.0 MSVC, debug targeted tests and release binary.XCL_ADAPTER=6800M cargo test --locked -p xcl --lib shaders::tests -- --test-threads=1 --show-output: 10 passed, 0 failed, 0 ignored, 1 explicitSKIPPED(pso_measurement_compiles_an_exact_synthetic_record: driver cache control unavailable without Windows Developer Mode). The three worker-bound regression tests passed.cargo build --locked --release -p xcl --bins -j 2: passed on the rebased head and on current main.f1331cd, the full GPU workspace run reported 996 passed, 161 failed, 46 ignored, with 9 explicit skips. The failures followed D3D12 device suspension0x887A0005on this RX 6800M; this is previous-head evidence, not a green current-head suite.git diff --check: clean.Regression run
The repository's
scripts/smoke.ps1ran each committed release binary for seven seconds on the same owned title, using separate fresh data and DXIL cache roots. Both exited normally with no crash or device removal. This short run reached intro frames only; it does not exercise the offline shader sweep.Current
main:This PR:
Not tested
AI use
OpenAI Codex (GPT-6; exact variant unavailable) implemented and rebased the worker bound, ran the focused checks and paired smoke, and drafted this description. The slot-order race was first reported by @JJAutoCompare and confirmed by @raylitebull.
@JJAutoCompare on GitHub · 2026-11-25 00:33 UTC · original
There is a completion race at
e6aeef4. The worker sends its result while itsActiveWorkerguard is still live. Once the receiver gets the result, it can start the next translation before the guard decrements the counter. With--threads 1, this can report a worker-limit failure and stop a sweep even though the previous translation has already returned. It can also happen between the direct and per-lane runs for one shader. Worker and receive pathRelease the slot after the translation returns and before publishing the result. A timed-out translation should retain its slot until the translation itself returns, as the existing cap test expects. Verified by code inspection. I did not run this PR’s binaries. Review assisted by Codex (
gpt-6.2-sol).@raylitebull on GitHub · 2026-11-25 01:25 UTC · original
Code review on
e6aeef4:CIworkflow approved.@JJAutoCompare's race catch inbounded_translation(crates/xcl/src/shaders.rs):let _active_worker = ActiveWorker(worker_active)drops aftertx.send(result), so a caller receivingresult(especially with--threads 1) can immediately re-enterbounded_translationbeforeActiveWorker::droprunsfetch_sub(1, Ordering::AcqRel)and trip"worker limit: ...". Dropping_active_workerright beforetx.send(result)(ordrop(_active_worker)oncecatch_unwindfinishes) avoids that race while still keeping the slot held until translation completes or times out.Remaining before merge: Fixing the
ActiveWorkerdrop order, fixingPR description, CI green, and dual-vendor verification on the updated head.@DavidM1911 on GitHub · 2026-11-25 03:42 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@raylitebull on GitHub · 2026-11-25 11:03 UTC · original
Updated review on
f1331cd(crates/xcl/src/shaders.rs):drop(active_worker_guard);ahead oftx.send(result)cleanly closes the slot-release race before the caller observes completion, andthreads.min(32)+worker_limit_hitreturning exit code2bounds leaked timed-out worker threads cleanly.Build and testandPR descriptionare green onf1331cd.Remaining before merge: Independent Windows verification (
shaders::testsincluding the three newbounded_translationtests) onf1331cd.@tiagonleal on GitHub · 2026-11-25 14:09 UTC · original
Verification on NVIDIA RTX 5070 Ti (Windows 11), head
f1331cd3ca80d0fc52be3b845c09fb5841285ee7Tested
f1331cd3ca80d0fc52be3b845c09fb5841285ee7(git rev-parse HEADof a clean detached worktree, no local changes, built as is). The PR was open and the head unchanged when I started and again before writing this.cargo testdefault).cargo test -p xcl --lib shaders::tests -- --test-threads=4 --nocapture: 10 passed, 0 failed, 0 ignored (0.31 s after the build). That includes the threedirect_workertests:completed_direct_worker_releases_slot_before_result,direct_worker_reports_panic_separately_from_timeout,timed_out_direct_worker_holds_its_slot_until_exit.SKIPPEDlines in the output.Not tested
cargo test --workspace, the rest of--lib, other test targets; release profile; an offlinexcl shaders --directsweep with real shaders; the retail game andxcl-smoke.Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).
@raylitebull on GitHub · 2026-11-25 18:28 UTC · original
Review update on
f1331cd: bothBuild and testandPR descriptionpassed, and independent verification onf1331cdnow covers both AMD (RX 6800Mdirect_worker3/3) and NVIDIA (RTX 5070 Tishaders::tests10/10 across 4 runs).After
#2285landed incrates/xcl/src/shaders.rs,#1997now shows a merge conflict. Once rebased ontoorigin/mainwith CI green and a quick re-verify on the rebased commit, this is ready to merge.@Oliwettoo on GitHub · 2026-11-25 22:15 UTC · original
Review on
f053f27(read from the diff, not built or run) – one behaviour change not raised above:After
threadstimeouts the sweep stops. A timed-out worker keeps its slot until its thread exits, and the limit passed tobounded_translationisthreads. So oncethreadstranslations have timed out and are still running (8 by default, 1 with--threads 1), every later call returnsworker limit:,worker_limit_hitis set and the sweep ends with exit 2 – the rest of the sample is never tried. Before this PR a timeout only left a thread behind and the sweep finished. With big programs timing out routinely, a full--sample 0run will likely stop early.Suggestion: give stuck workers their own budget (e.g. a limit of
threads + K, allowingKtimed-out stragglers), or have the caller wait for a free slot instead of aborting, and exit 2 only when that budget is exhausted. A test withlimit = 1and two consecutive timeouts would pin whichever behaviour is chosen.@luckyteagirl on GitHub · 2026-11-25 22:48 UTC · original
Thanks for flagging the full-sweep consequence. Yes:
--threadsis deliberately the maximum number of live translation workers, including ones whose caller timed out. If all of them remain active, the sweep stops with exit 2 and says it is incomplete; it does not report a successful full sample. Launching another worker at that point would restore the detached-thread accumulation this PR addresses.timed_out_direct_worker_holds_its_slot_until_exitpins thelimit = 1case: a timeout keeps the slot, the next translation is refused withworker limit:, and work resumes after that thread exits. Athreads + Kcap would let K additional timeouts through but would still need to stop if those workers also remain stuck; it also permits K more large translator stacks. I will keep the hard cap for this PR and make the early-stop limitation explicit in the description. A whole-pack sweep with persistent hangs was not validated on this head.AI use: OpenAI Codex (GPT-6; exact variant unavailable) traced the current worker/sweep code and drafted this response; no new test was run for this comment.
@DavidM1911 on GitHub · 2026-11-26 06:51 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
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.