Skip to content

d3d12_compile_pool_test: submit the demand after the checkpoint's first look (TEST-COMPILE-POOL-LOAD-FLAKE) - #2510

Open
Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:test-compile-pool-load-flake
Open

Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:test-compile-pool-load-flake

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Package TEST-COMPILE-POOL-LOAD-FLAKE. Claim: #1608 (comment). This is a test-only change to runtime/test/d3d12_compile_pool_test.cpp (the test from #2233).

The flake

test_a_checkpoint_sees_a_demand_that_started_during_it checks its first look, EXPECT(!pool.has_compile_waiter()) (line 379 on main), inside the checkpoint job, right after log.start("checkpoint"). The test thread waits on that same log.start (log.wait_started(1)) and then submits the demanded build. On a loaded machine the checkpoint's worker can be preempted between log.start and the look. The demanded build is then already queued or running when the look happens, and the check fails. This was found while verifying #2505: with 16 copies running at once, the check failed in 1 of 64 runs of main's test, and the same check failed in 1 of 48 runs with #2505.

The fix

The job stores its first look in an atomic and opens a gate. The test waits for that gate with Gate::wait_for(10s) (new; no fixed sleep), checks the stored look, and only then submits the demanded build. The rest of the test is unchanged.

Tested

Profile M: RTX 4070 SUPER, Windows 11, Ryzen 7 9800X3D, MSVC RelWithDebInfo. CPU only.

  • 16 copies of d3d12_compile_pool_test.exe at once, 13 rounds:
    • with the fix: 0 of 208 runs failed.
    • main's test: 0 of 208 also failed this time. The race is rare (about 1 in 50 to 60 before), so the run count alone does not prove the fix.
  • Forced race: a temporary sleep_for(200ms) after log.start("checkpoint") stands in for a preempted worker. It is not committed.
    • main's test with it: 3 of 3 runs fail at the first-look check.
    • the fixed test with it: 3 of 3 runs pass.
  • git diff --check and scripts/check_no_game_data.py are clean. No game files used.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…st look (TEST-COMPILE-POOL-LOAD-FLAKE)

test_a_checkpoint_sees_a_demand_that_started_during_it checked its first
look (!has_compile_waiter()) inside the checkpoint job, after log.start.
The test thread woke on that log.start and submitted the demanded build,
so on a loaded machine the build could be queued or running before the
checkpoint's thread reached its first look, and the check failed (seen
1 in 64 runs with 16 copies running at once).

The job now records the first look and opens a gate; the test waits for
that gate (10 s limit, no fixed sleep) before it submits the build, and
checks the recorded look.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timbot103

Copy link
Copy Markdown
Contributor

Reviewed at head db477857f on Windows 11 (MSVC 2022 19.44).

Verification

  • Built d3d12_compile_pool_test.
  • d3d12_compile_pool_test (5 consecutive runs): 5/5 passed.

Notes

  • Adding the looked gate after storing the first has_compile_waiter() result and waiting on it before submitting demand (d3d12_compile_pool_test.cpp:26-58, 372-399) cleanly eliminates the test scheduling race where demand could arrive before the checkpoint took its first look, while preserving the intended two-look production test semantics. (Also confirmed disjoint from #2505's hunks in the same file.)

Approve.

AI-assisted review + local MSVC verification.

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2510 | head db47785 (merged cleanly with main 3ca0707) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^d3d12_compile_pool$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: under worker preemption between log.start("checkpoint", false) and !pool.has_compile_waiter() (reproduced deterministically with a 20 ms delay), the demanded build arrives before the checkpoint's first look and fails d3d12_compile_pool_test.cpp (!pool.has_compile_waiter()) | green on PR+main: 1/1 CTest passes (1.74s) plus 20/20 consecutive stress runs on RTX 3090 with LEONIDA_VK_VALIDATION=1 (0 Khronos validation errors); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants