From db477857fff5e3d188979755559641d0a2be5c96 Mon Sep 17 00:00:00 2001 From: Tyrannys <80750971+Tyrannys@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:43:37 -0600 Subject: [PATCH] d3d12_compile_pool_test: submit the demand after the checkpoint's first 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 --- runtime/test/d3d12_compile_pool_test.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/runtime/test/d3d12_compile_pool_test.cpp b/runtime/test/d3d12_compile_pool_test.cpp index 2bf1cdb61c..93efaa28f1 100644 --- a/runtime/test/d3d12_compile_pool_test.cpp +++ b/runtime/test/d3d12_compile_pool_test.cpp @@ -44,6 +44,11 @@ struct Gate { std::unique_lock lock(mutex); changed.wait(lock, [this] { return open; }); } + // Waits up to `limit`; false when the gate is still shut. + bool wait_for(std::chrono::milliseconds limit) { + std::unique_lock lock(mutex); + return changed.wait_for(lock, limit, [this] { return open; }); + } void release() { { std::lock_guard lock(mutex); @@ -367,17 +372,21 @@ void test_order() { void test_a_checkpoint_sees_a_demand_that_started_during_it() { auto& pool = make_pool(2, 1); Log log; - Gate query; + Gate looked, query; Owners owner; - std::atomic second_look{-1}; + std::atomic first_look{-1}, second_look{-1}; EXPECT(pool.submit(device, device, SIZE_MAX, [&] { log.start("checkpoint", false); - EXPECT(!pool.has_compile_waiter()); // the first look: nothing else queued or running - query.wait(); // the size query + first_look = pool.has_compile_waiter(); + looked.release(); + query.wait(); // the size query second_look = pool.has_compile_waiter(); log.finish("checkpoint", false); })); - EXPECT(log.wait_started(1)); + // The demanded build is submitted only after the first look: submitted once the checkpoint has started, a loaded + // machine could run it before the checkpoint's thread gets to its first look. + EXPECT(looked.wait_for(10s)); + EXPECT(first_look == 0); // the first look: nothing else queued or running Gate build; submit(pool, log, &build, owner[0], "demand"); EXPECT(log.wait_started(2)); // on the second worker, while the checkpoint runs