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

Merged
Tyrannys merged 1 commit from upstream-pr/2510 into main 2026-11-29 01:05:56 +00:00
Tyrannys commented 2026-11-27 21:43:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T21:43:53Z.


Package TEST-COMPILE-POOL-LOAD-FLAKE. Claim: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7228654053. 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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5533461133 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T21:43:53Z. --- Package **TEST-COMPILE-POOL-LOAD-FLAKE**. Claim: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7228654053. 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](https://claude.com/claude-code)
timbot103 commented 2026-11-28 02:02:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:45Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232091357 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7232091357). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:02:45Z. --- 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 commented 2026-11-28 09:52:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T09:52:20Z.


#2510 | head db477857ff (merged cleanly with main 3ca0707dde) | 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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237521388 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7237521388). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T09:52:20Z. --- #2510 | head db477857fff5e3d188979755559641d0a2be5c96 (merged cleanly with main 3ca0707ddec7fd868ecd6df924d751901102fd9c) | `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
OreoFR commented 2026-11-28 22:03:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:03:31Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head db477857f; green run in a merge package of 11 PRs, no new ctest failure vs main
  • Test: ctest -R "^d3d12_compile_pool$"
  • Red on main: OK
  • Green with the PR: OK
  • Verdict: NO RED (test-only PR: fixes a rare race (1 in 50-60 per the author), not reproduced here)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246466211 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7246466211). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:03:31Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `db477857f`; green run in a merge package of 11 PRs, no new ctest failure vs main - Test: `ctest -R "^d3d12_compile_pool$"` - Red on main: OK - Green with the PR: OK - Verdict: NO RED (test-only PR: fixes a rare race (1 in 50-60 per the author), not reproduced here) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
enlight3d commented 2026-11-29 00:46:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:46:35Z.


Run of #2510 (d3d12_compile_pool): green at the PR head; the flake is only reproduced by a forced race (a temporary sleep), not by the plain test.

  • PR head: db477857ff (base 39f52f39c). Current main: 1bc055e6c2. git merge-tree --write-tree main <head> merges cleanly. The test file and runtime/shims/d3d12_pipeline_compile.h are identical on main and at the PR base, so "main's test" below is the base version.
  • GPU/driver: NVIDIA GeForce RTX 3090 24 GB, driver 621.40 (not used by this CPU-only test). OS: Windows 11 Pro 10.0.26300. MSVC 19.44, Ninja, RelWithDebInfo.
  • Only the test target was built, not the whole runtime. The PR is test-only: there is no non-test change to revert.

Commands (in a vcvars64 shell, build folder inside the worktree):

cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON -DSDL3_DIR=<installed SDL3 3.4.20 static>/cmake
cmake --build runtime/build --target d3d12_compile_pool_test -j 8
ctest -R "^d3d12_compile_pool$" --output-on-failure

Green (PR head): d3d12_compile_pool Passed (1.7 s); the executable run 20 times in a row: 0 failures. Main's test (base version) without any change: Passed, 20 runs: 0 failures (the race is rare; I did not try to catch it under load).

Red (forced race, as in the description): a temporary std::this_thread::sleep_for(200ms); right after log.start("checkpoint", false); in the test, never committed:

  • main's test (base version) with it: Failed at d3d12_compile_pool_test.cpp:380: !pool.has_compile_waiter() (the first-look check); 3 of 3 executable runs fail.
  • the PR's test with it: Passed; 3 of 3 executable runs pass.
    The red is therefore a simulated one (the sleep stands in for a preempted worker), on the test and not on the runtime.
    Link check: merged into main 1bc055e6c, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248342482 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7248342482). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T00:46:35Z. --- Run of #2510 (`d3d12_compile_pool`): green at the PR head; the flake is only reproduced by a forced race (a temporary sleep), not by the plain test. - PR head: db477857fff5e3d188979755559641d0a2be5c96 (base 39f52f39c). Current main: 1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3. `git merge-tree --write-tree main <head>` merges cleanly. The test file and `runtime/shims/d3d12_pipeline_compile.h` are identical on main and at the PR base, so "main's test" below is the base version. - GPU/driver: NVIDIA GeForce RTX 3090 24 GB, driver 621.40 (not used by this CPU-only test). OS: Windows 11 Pro 10.0.26300. MSVC 19.44, Ninja, RelWithDebInfo. - Only the test target was built, not the whole runtime. The PR is test-only: there is no non-test change to revert. Commands (in a vcvars64 shell, build folder inside the worktree): ``` cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON -DSDL3_DIR=<installed SDL3 3.4.20 static>/cmake cmake --build runtime/build --target d3d12_compile_pool_test -j 8 ctest -R "^d3d12_compile_pool$" --output-on-failure ``` Green (PR head): `d3d12_compile_pool` Passed (1.7 s); the executable run 20 times in a row: 0 failures. Main's test (base version) without any change: Passed, 20 runs: 0 failures (the race is rare; I did not try to catch it under load). Red (forced race, as in the description): a temporary `std::this_thread::sleep_for(200ms);` right after `log.start("checkpoint", false);` in the test, never committed: - main's test (base version) with it: Failed at `d3d12_compile_pool_test.cpp:380: !pool.has_compile_waiter()` (the first-look check); 3 of 3 executable runs fail. - the PR's test with it: Passed; 3 of 3 executable runs pass. The red is therefore a simulated one (the sleep stands in for a preempted worker), on the test and not on the runtime. Link check: merged into main 1bc055e6c, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.
MoonEyes commented 2026-11-29 01:05:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:05:59Z.


Merged after enlight3d (Thib)'s red/green run (RUN, RTX 3090, driver 621.40, Windows 11: green with this PR, red without it, and gta6rt.exe still links) and a re-check here: no conflict with main 7e06a026d, same head as run, no-game-data green, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on main or Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ).

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248558488 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7248558488). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T01:05:59Z. --- Merged after **enlight3d** (Thib)'s red/green run ([RUN](https://github.com/ProjectLeonida/mandy/pull/2510#issuecomment-7248342482), RTX 3090, driver 621.40, Windows 11: green with this PR, red without it, and `gta6rt.exe` still links) and a re-check here: no conflict with `main` 7e06a026d, same head as run, `no-game-data` green, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on `main` or Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ). _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2510
No description provided.