[pr-tests] gpu_owned: the test of eight faults on one block no longer fails by chance (199 of 200 runs of its module on main) #261
Loading…
Reference in a new issue
No description provided.
Delete branch "blazecoding2009/Darner:pr/test-readback-count"
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?
Contributor role (optional)
What it changes
The problem on main:
gpu_owned::tests::concurrent_faults_on_same_block_serialize_single_readbackfails by chance: in 199 of 200 runs of its module alone here, and now and then in a whole run ofdarner-gpu's tests (1 of 8 here). Most often with:There are two causes, both in the test.
TEST_READBACKSto zero, lets eight threads fault on one trapped block and asserts that the count is one. The count is one static for every trapped block.veh_read_fault_and_partial_write_zero_clobber, the other test that traps blocks, traps two and so makes two readbacks, and it runs beside this one on another test thread. When the two meet, the count is two or three (192 of the 200 runs). Both tests now hold one lock,ONE_TRAP_TEST, for their whole length.read_backdoes. A thread that comes to the block between the two reads it with no fault, and not the pattern:left: 7, right: 8, "all eight threads read the card's bytes" (7 of the 200 runs, and 18 of 200 with the lock of 1 alone). The test now holds the handler's turn (TEST_SERIAL) until all eight threads have faulted, which is what its name says it is about, and asserts that they did.Test code only:
mod testsofgpu_owned.rs.read_backitself is not changed: withDARNER_GPU_OWNED=1a second thread of the title that first touches a block in that window reads the bytes of before the readback. I read that from the code only and did not look for it in the game.How it was tested
Tested revision:
224cbec(this one commit onmainf3840d7).Commands and results:
cargo test --locked -p darner-gpu --lib --no-runon each revision, then that test binary run by itself with the filtergpu_owned::tests(the module's 6 tests, the two with trapped blocks among them), 200 and 300 times.f3840d7)224cbec)gpu_owned::testsconcurrent_faults_on_same_block_serialize_single_readbackfailedAll of the crate's tests on
224cbec, 4 runs with a 150 s limit: this test passed in all four. One run passed whole; in the other three one other test failed (watch::tests::ask_once_by_res_splits_reservations_without_refusals, which #150 is about,host::refresh_tests::chunked_nothing_new_with_matches_individualandhost::watch_pipe::tests::ask_once_delta_runs_on_collector_and_preserves_ahead).Changes a default: no.
Gates run on that revision (the three in AGENTS.md; there is no CI):
cargo clippy --workspace --all-targets --locked -- -D warnings: passed. The same with--all-features: passed.cargo xtask policy: 555 files ok.cargo test --workspace --locked: not run as one command on this revision. Of it, I randarner-gpu's tests as above. Onmainthat gate fails or stands still by chance in this crate (#224 has the counts), and indarner-shaderone test fails, which #227 is about.Gameplay: not run in the game. The change is in test code only.
Shader wave sizes tested, when relevant: not relevant.
Hardware dependence: likely general. How often the two tests meet depends on timing and on the number of test threads: 16 here (Ryzen 7 8845HS, Windows 11 build 26300).
Coverage gaps: one PC. Other tests of the crate still fail by chance, as the four whole runs show.
Checklist
main.docs/asset-policy.md.Checked for overlap
TEST_READBACKS,concurrent_faults_on_same_blockandflakyfound no report. I searched the diff of every open pull request (100): #57 changesgpu_owned.rsoutside its tests, none changes these two tests. #224 and #150 are about other tests of the crate that fail or stand still by chance.This change was made with AI assistance (Claude Code).
🤖 Generated with Claude Code
Independent Windows build, gate, and code-read review of
224cbec12(based onmainf3840d73d). Test-only change; not run in-game.Environment
x86_64-pc-windows-msvc), MSVC 19.44.35230.Measured results
cargo clippy --workspace --all-targets --locked -- -D warnings): PASScargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASScargo xtask policy: PASS (asset policy: 555 files ok)cargo test --locked -p darner-gpu --lib gpu_owned(10 passed; 0 failedper run): 20/20 PASSCode-read audit
crates/darner-gpu/src/gpu_owned.rs(mod tests):ONE_TRAP_TESTserializesveh_read_fault_and_partial_write_zero_clobberandconcurrent_faults_on_same_block_serialize_single_readbackso their sharedTEST_READBACKScounter no longer observes the other test's 2 readbacks.TEST_SERIALuntilTEST_FAULTS == 8(with a 30 s timeout) guarantees all 8 worker threads fault concurrently before the first readback restoresPAGE_READWRITEand copies the pattern bytes, closing theVirtualProtect->copy_nonoverlappingrace intest_fault.TEST_FAULTS.fetch_addexecutes beforeTEST_SERIAL.lock(), stack-growth guard-page exceptions are ignored atgpu_owned.rs:950, andstd::thread::scopeestablishes happens-before forTEST_WAITED/TEST_FAULTS.read_back(gpu_owned.rs:550-560, opt-inDARNER_GPU_OWNED=1) has an analogousunreserve->copy_nonoverlappingwindow, which this test never exercised in the first place.Verdict: PASS.
AI-assisted: yes (Gemini 4 Neon).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.