GPU tests: each test's prepare hook runs on its own thread #2585
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2585
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2585"
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?
@fyernald on GitHub · 2026-11-25 16:16 UTC · original
fyernald:fix/prepare-hook-per-thread→main· +15 −9 · 1 files · 1 commits · openTwo
victory-gputests added in42ea09ffail intermittently when the suite runs in parallel (the default forcargo test):descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record: "the slot views the record written last"descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait: "both made"Each passes when run alone.
Cause
Both tests install work in
WHILE_PREPARING, whichprepareruns once. It was one global for the whole test process. Every test that binds a view callsprepare, so with tests running in parallel:preparecan take the hook first, so the work runs inside that test instead, orprepareruns, so this test runs the other one's work.Either way, the concurrent write (or bind) the test checks for never happens, and its assertion fails.
Change
WHILE_PREPARINGis now thread-local.prepareruns on the thread that binds the view (HostHeap::mirror), so each test's hook runs in its ownprepareand nowhere else. The two tests set and check it viaset/with_borrow. This is test code only; nothing outside#[cfg(test)]changes.WHILE_MAKINGis left alone, because it already only runs for its own slot.Testing
Windows 10 Pro 22H2 (19045), RTX 3080 (driver 617.42), Rust 1.98.1 MSVC, base
67e8ae1. The fullvictory-gpulib test binary was run 200 times in a row with default parallelism:main67e8ae1a_slot_rewritten_…13,views_bound_…11)The other failures on this machine are unchanged in both builds and unrelated. They happen in every run:
dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views(NVIDIA's view heap cap,FIND-9), plusa_texture_written_in_one_format_reads_in_another_through_a_placed_view(Windows 10 has noID3D12Device10, #1999).cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean, also with--all-featurescargo xtask policy:184 files okClaim: #1633
@oni-swr on GitHub · 2026-11-25 16:33 UTC · original
oni-swr verification — head
19016aaf6f13fdc7d338ad15fb825453e8717739,origin/main67e8ae1401df112248aed36d0024483181b718b7Environment: Windows 11 Pro (26200), rustc 1.98.1, WARP only (
VICTORY_D3D12_WARP=1with--features diagnostics, which is what makes the host device the software adapter; Windows SDK 10.0.26100.0dxil.dllon PATH). No hardware GPU use in the reported runs, no game files, no retail data. Merge check:git merge-tree --write-tree origin/main <head>is clean.Commands / results
cargo test --locked -p victory-gpu --features diagnostics --lib -- descriptor::host::tests: 13 passed, 0 failed, 0 ignoredcargo test --locked -p victory-gpu --features diagnostics: 198 passed, 0 failed, 1 ignored (lib; 0 doctests)descriptor:: --test-threads=16:origin/main7/150 runs fail (views_bound_while_another_slot_gets_its_texture_do_not_wait4,a_slot_rewritten_while_its_view_is_prepared_views_the_new_record4); this PR 0/150.memory::tests::a_submission_that_missed_leaves_the_copies_at_onceon WARP: main 9/60, PR 14/60 (also seen once failing onbindless::tests::heap_views_are_currenton main). It is not touched by this diff, passes alone and with--test-threads=1; noting it so it is not blamed on this PR.Review: test-only change.
WHILE_PREPARINGbecomes athread_local!RefCell;prepareruns on the thread callingHostHeap::mirror, so the hook set by a test is consumed on that same thread, and the helper threads the tests spawn only perform the concurrent write/bind (they never need the hook).WHILE_MAKINGcorrectly left alone. I found no defects.Overlap: no open PR changes the same hunks. #2547, #2558, #2543, #2542, #2541, #2483 also touch
descriptor/host.rsand all merge with this branch cleanly (merge-tree); #2475 conflicts with it indescriptor/host.rs/draw.rs(an ordering matter for whichever lands second, not this PR's fault).AI disclosure: this review and verification were done by Claude Code (Claude Sonnet 5.5), not a human reviewer. Comment-only; no code changed.
@fyernald on GitHub · 2026-11-25 17:07 UTC · original
Thanks, @oni-swr. Your 7/150 → 0/150 on WARP matches what I saw on hardware.
On
memory::tests::a_submission_that_missed_leaves_the_copies_at_once: it never failed in any of my full-suite runs on an RTX 3080 (Windows 10, default parallelism). That's 0 of 550: 200 onmain67e8ae1, 200 with this PR and 150 more on other builds. So it looks specific to WARP (or to its timing), which fits your reading that it's unrelated here.@Marvisak on GitHub · 2026-11-25 22:19 UTC · original
Automated triage for the maintainers.
Merge candidate. This is a test-only fix for two flaky
descriptor::hosttests.WHILE_PREPARINGwas one process-wide hook, andprepareruns it for every view any parallel test binds, so another test could take or replace it first. It is now athread_local!RefCell.prepare(descriptor/host.rs) callstests::while_preparing()on the thread that callsHostHeap::mirror, which is the test's own thread, so each hook runs in its own test. The helper threads the tests spawn never need it. Nothing outside#[cfg(test)]changes.CI:
checkpassing. Merges cleanly into currentmain. A recommendation to look at it, not an approval.Generated by Claude Code
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.