Commit Graph

7 Commits

Author SHA1 Message Date
5d0a501229 Merge pull request #2510 from Tyrannys/test-compile-pool-load-flake
d3d12_compile_pool_test: submit the demand after the checkpoint's first look (TEST-COMPILE-POOL-LOAD-FLAKE)
2026-11-29 02:05:56 +01:00
db477857ff 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 <noreply@anthropic.com>
2026-11-27 15:43:37 -06:00
a3452751de d3d12_compile_pool_test: the graphics-only worker wakes the general one 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 #2233 (a test for the case its review named).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 23:21:11 +02:00
03ec559ac1 d3d12_compile_pool_test: wait for an idle pool before the checkpoint test's last check
The demanded job leaves the running list only after its function returns,
so has_compile_waiter() could still see it right after the log said it had
finished (1 failure in 10 runs). Found while merging this into #2275.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 04:54:43 -06:00
9b8760d328 d3d12: one build of a PSO at a time with one worker plus the graphics worker
With LEONIDA_COMPILE_THREADS=1 (the layout of main: one general worker and
the graphics-only one) next_locked did not look at the owner, so two variants
of one graphics PSO could build at once, one on each worker. A last Release
meanwhile hands the PSO's deletion to the running build it finds first
(after_running), and that worker deleted the PSO while the other was still
in build() on it. The single-worker selection now skips a job whose PSO has
a build running, as the pool already did.

New test in d3d12_compile_pool_test: two graphics variants of one PSO with
one worker plus the graphics worker; the second must not start while the
first runs, another PSO's build still uses the free worker, and a last
Release runs after the first build with the second dropped. It fails
without the fix.

Docs: the heavy count also bounds LEONIDA_SERIAL_BIG_COMPILES=0 on the
workers; only compute creates pass the compile gate.

Found by qhukz13 in review of #2233.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 04:19:53 -06:00
2d56b685ac d3d12: the checkpoint's second look also sees a running demanded build
The startup cache checkpoint starts only when no compile worker is busy, but a
demanded build can start on another worker while the checkpoint queries the
cache size. has_compile_waiter() only looked at the queue, so the check after
the size query went on to read the cache blob while that build ran.
has_compile_waiter() now also answers true while a demanded build runs.

New gated test in d3d12_compile_pool_test: the checkpoint waits at a gate
standing in for the size query, a demanded build starts on the second worker,
and the second look must see it. It fails without the fix.

Reported by lixonik in review of #2233.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 04:53:26 -06:00
a83f38508f d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL)
With LEONIDA_ASYNC_PIPELINES=1 every demanded build, the compute warm-up and
the cache checkpoint ran on one general worker (plus a graphics-only one), so
one long driver compile held every pipeline a submission asked for behind it,
and their draws and dispatches were skipped meanwhile.

PipelineCompiler now runs LEONIDA_COMPILE_THREADS workers (half the logical
processors, 2 to 8). A worker takes the most urgent job it may:
- demanded builds first, in the order they came, then warm-ups by size, then
  the checkpoint, which waits until no worker compiles;
- large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups
  together take at most threads-1 workers, so one stays free for a small
  demanded build; at most LEONIDA_COMPILE_HEAVY_MAX large builds at once
  (default threads-1, 1 with LEONIDA_SERIAL_BIG_COMPILES=1), compute and
  graphics alike, each still within the memory gate;
- warm-ups run one at a time, and none starts while a demanded build runs:
  each holds the compile gate for its whole create, and a submission waits
  for every create in flight;
- one build of a PSO at a time, so after_running and the teardown rules hold.

LEONIDA_COMPILE_THREADS=1 keeps the layout before the pool. The design is
MoonEyes' (#2077), ported onto #2098's scheduler.

Tests: d3d12_compile_pool (CPU, jobs held at gates: settings, a long build
does not hold up a small demanded one, heavy count, free worker, warm-ups one
at a time and after demanded builds, order, one job per PSO, release/cancel/
stop_for_exit with jobs in flight), and d3d12_compile_teardown also with one
worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 03:10:28 -06:00