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>
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>
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>
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>