Skip to content

d3d12_compile_pool_test: the graphics-only worker wakes the general one for a PSO's held-back job (TEST-COMPILE-POOL-GRAPHICS-WAKE) - #2505

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
qhukz13:cont/compile-pool-graphics-wake
Nov 29, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
qhukz13:cont/compile-pool-graphics-wake

Conversation

@qhukz13

@qhukz13 qhukz13 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as TEST-COMPILE-POOL-GRAPHICS-WAKE: #1608 (comment)

Follow-up to #2233, a test for the case named in its review: with LEONIDA_COMPILE_THREADS=1, a PSO's job that is not graphics waits while a graphics build of that PSO runs on the graphics-only worker, and must go when that build returns.

What

test_the_graphics_worker_wakes_the_general_one_for_its_psos_job in runtime/test/d3d12_compile_pool_test.cpp:

  1. a non-graphics job of another PSO occupies the general worker;
  2. a graphics job of PSO A runs on the graphics-only worker;
  3. a non-graphics job of PSO A is queued; it may not start while A's build runs;
  4. the general worker is freed, finds nothing it may take, and goes back to sleep;
  5. A's graphics build returns; the queued job must start within 3 s. The graphics-only worker that finished cannot take it, so only its wake gets it to the general worker.

Test only; no runtime change.

Tested

GPUs tested: NVIDIA GeForce GTX 1050 Ti 4 GB desktop (profile S), driver 582.66, Windows 10 19045. Every number below is MEASURED on that machine (n=1 per run unless given); no game files were used.

GTX 1050 Ti 4 GB, NVIDIA 582.66, Windows 10 19045, MSVC RelWithDebInfo:

  • ctest -R compile_pool: passes; the test executable 20 runs in a row: 0 failures.
  • Mutants in runtime/shims/d3d12_pipeline_compile.h, PipelineCompiler::run:
    • the wake after a job removed (wake_.notify_all()): fails at the new test and at test_a_finished_job_wakes_the_idle_workers;
    • only the graphics-only worker skips that wake (if (!graphics_only) wake_.notify_all();): fails at the new test only; every other test in the file passes.
  • check_no_game_data.py on the file, git diff --check: clean.

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

🤖 Generated with Claude Code

…ne for a PSO's held-back job

With LEONIDA_COMPILE_THREADS=1, a PSO's job that is not graphics waits while a graphics build of that PSO runs on
the graphics-only worker. The general worker has gone back to sleep by then, so only the graphics-only worker's
wake on return lets it go. Follow-up to ProjectLeonida#2233 (a test for the case its review named).

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

@Tyrannys Tyrannys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification of head a3452751d on profile M: RTX 4070 SUPER 12 GB, NVIDIA 621.01, Windows 11, Ryzen 7 9800X3D. Built on main 39f52f39c with this PR and #2507 merged; the two PRs touch different files. MSVC RelWithDebInfo.

  • build\RelWithDebInfo\d3d12_compile_pool_test.exe, 5 runs in a row: 5/5 PASS d3d12_compile_pool.
  • Under load: 16 copies at once, 3 rounds (48 runs). One run failed, at d3d12_compile_pool_test.cpp:407 !pool.has_compile_waiter(). That is in test_a_checkpoint_sees_a_demand_that_started_during_it, an existing test this PR does not change. The same check (:379) also failed once on main's copy of the test under the same load (1 of 64 runs). So it is an older flake, not this PR. The new test never failed.
  • Mutant, as claimed: PipelineCompiler::run with if (!graphics_only) wake_.notify_all(); fails only the new test, at :259 log.wait_finished(3, 3s), in 3 of 3 runs. Every other test in the file passes. With the source restored, all tests pass again.

Clean. Approving. No game files used.

AI-assisted (Claude Code).

@timbot103

Copy link
Copy Markdown
Contributor

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

Verification

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

Notes (non-blocking)

  • Pinning the busy job on the general worker, running the same owner's graphics job on the graphics-only worker, queuing a non-graphics job for that owner, and verifying completion once the graphics gate releases (d3d12_compile_pool_test.cpp:117-123, 236-261, 545-556) directly exercises the wake_.notify_all() liveness path in d3d12_pipeline_compile.h:651. (Disjoint from #2510's checkpoint fix.)
  • Minor timing note (d3d12_compile_pool_test.cpp:74-93, 253-260): Log::finish runs inside the busy callback before the general worker re-enters the pool loop, so if the general worker is delayed >100 ms before parking in wake_.wait, a mutant without notify_all() could still pass when the predicate sees the unlocked job immediately; also the 3 s wait timeout has tighter margin under heavy load than the file's usual 10 s. Non-blocking.

Approve.

AI-assisted review + local MSVC verification.

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2505 | head a345275 (merged cleanly with main 33db04a) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_compile_pool|d3d12_pipeline_workers)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red check: mutating d3d12_pipeline_compile.h so the graphics-only worker omits wake_.notify_all() fails d3d12_compile_pool_test (d3d12_compile_pool_test.cpp:259: log.wait_finished(3, 3s)), confirming the regression test is non-tautological | green on PR+main: 2/2 CTests pass (d3d12_compile_pool in 1.86s + 10/10 consecutive stress runs, and d3d12_pipeline_workers on RTX 3090 in 4.56s with LEONIDA_VK_VALIDATION=1 and 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

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR

  • Base: main c1ecf04ed + PR head a3452751d; green run in a merge package of 2 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: covers behaviour already on main)
  • 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

Copy link
Copy Markdown
Contributor

Run of #2505 (d3d12_compile_pool): green at the PR head, and a behavioural red with a mutant of the runtime (the PR is test-only, so there is no non-test change to revert).

  • PR head: a345275 (base 39f52f3). Current main: 1bc055e. git merge-tree --write-tree main <head> merges cleanly. runtime/shims/d3d12_pipeline_compile.h is identical on main and at the PR head, so the new test runs against main's runtime logic unchanged.
  • 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.

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.8 s). The test executable run 20 times in a row: 0 failures.

Red (behavioural, mutants of PipelineCompiler::run in runtime/shims/d3d12_pipeline_compile.h, each reverted afterwards; same ctest):

  • the wake after a job is removed only skipped for the graphics-only worker (if (!graphics_only) wake_.notify_all();): Failed at d3d12_compile_pool_test.cpp:259: log.wait_finished(3, 3s), which is the new test's last wait.
  • no wake at all: Failed at line 259 and at line 454 (log.wait_started(3, 3s), another test).
    This matches what the description says: the first mutant is caught by the new test only. Not a "header missing" red: the file builds in all cases.
    Link check: merged into main 1bc055e, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.

@MoonEyes
MoonEyes merged commit 7e06a02 into ProjectLeonida:main Nov 29, 2026
8 of 12 checks passed
@MoonEyes

Copy link
Copy Markdown
Collaborator

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 dcbcd42, 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 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.

7 participants