Commit Graph
4149 Commits
Author SHA1 Message Date
Anees Iqbal c19efa540d RUNTIME_VERSION 2075: records carry a compute state's dispatches, and the warm pass makes their pipelines
The two commits before this one. A compute state whose descriptor requires no threadgroup size
predicts no VkPipeline at its creation: the local size and the threadgroup memory lengths come
from the dispatch. So its creation's record warmed none of its dispatches' pipelines, and each
was a cold driver compile at the program's first dispatch of that shape. On the Iris Xe these are
the compute kernels FAST-PATHS names.

Now a compute state's direct dispatch (dispatchThreadgroups: or dispatchThreads:) whose regions'
pipelines weren't all made hands the record hook one more record. It holds the creation's
descriptor and the dispatch: the threadgroup size, a dispatchThreads: grid cut down to one whole
threadgroup plus its ragged edge per axis, and the encoder's threadgroup memory lengths. Each
dispatch shape is recorded once per state, at most 16 per state (pipeline/dispatch_record.rs).
The warm pass creates the state, plans each recorded dispatch with nothing bound and the recorded
lengths, settles its variant through compute::settle_direct as the program's direct dispatch
does, and makes each region's VkPipeline on the pass thread. The program's making is then handed
the driver cache the pass filled. WarmStatistics::dispatch_pipelines_warmed counts them. Indirect
dispatches, threadgroup-range dispatches and tile dispatches record nothing. The record format
goes from 6 to 7; a format-6 record reads as none. The codec caps a record at 16 dispatches and
31 lengths each, on write and on read. The warm budget is unchanged.

Not covered: the program's dispatch still calls vkCreateComputePipelines (warm states share no
live variant with the program), and a dispatch whose bindings specialize its regions still makes
its own pipelines at first dispatch.

Verified (potluck jobs, on the branch at 42d9d77e54):
- lavapipe (m3-max-18386): 50/50, the warm, warm_record, dispatch_pending, dispatch_making,
  deferred_calls, driver_pipeline_compile and creation_log tests. The new device test: on a device
  warmed with both records, records_warmed 2 and dispatch_pipelines_warmed 1, and the program's
  first dispatch gave [makings handed a cache the device held, pipelines made, functions
  translated] = [1, 1, 0]; on a control warmed with the creation's record alone, [0, 1, 0] and 0.
  lavapipe reported 0 driver hits and 1 miss on both devices; the cache sharing is the only
  structural check there.
- An earlier run (18374) caught the pass making 2 pipelines the program never asks for (settled
  through ComputePipelineState::settle alone); 42d9d77e54 fixes it.
- Lint (18388): fmt check, clippy in all three configurations, rustdoc, api_signatures and
  api_surface 15/15, fast_paths 27/27, warm_record 5/5.
Not yet run: a driver hit on a real GPU (the Iris run is queued).
2026-11-11 19:10:53 -08:00
Anees Iqbal 685af74380 Warm dispatch: plan a recorded dispatch as the program's direct dispatch does
The warm pass settled a recorded dispatch's variant through
ComputePipelineState::settle alone, while the program's direct dispatch
first takes a ragged dispatchThreads: grid's flat variant
(compute::flat_direct): one region on one VkPipeline. On lavapipe the
program's 1000-thread dispatch in groups of 64 made 1 pipeline and the
pass made 2 others (the split's interior and edge), so none of the pass's
makings was one the program's dispatch asks for (lavapipe job 18374,
a_warm_pass_makes_the_pipelines_of_the_dispatches_its_records_name:
dispatch_pipelines_warmed 2 against 1).

Both now settle through compute::settle_direct (the flat variant where
the dispatch takes one, else settle), so they ask for the same variant
and region keys. Verification: the lavapipe and lint jobs on this tip,
in the report to main.
2026-11-11 19:10:39 -08:00
Anees Iqbal b11e59ec86 Records carry a compute state's dispatches, and the warm pass makes their pipelines
A compute state whose descriptor requires no threadgroup size predicts no
VkPipeline at its creation: the local size and the threadgroup memory
lengths are the dispatch's own calls, so its creation's record made none of
its dispatches' pipelines on a later warm pass, and each was a cold driver
compile at the program's first dispatch of its shape (the 12.7.6 kernels'
case in FAST-PATHS).

Now, where the device hands records over, a compute state's direct dispatch
(dispatchThreadgroups: or dispatchThreads:) whose regions' pipelines were not
all made hands the hook one more record: the creation's descriptor, as its
own record holds it, and the dispatch (its threadgroup, a dispatchThreads:
grid reduced to one whole threadgroup and its ragged edge per axis, and the
encoder's threadgroup memory lengths). Each such dispatch once per state, at
most 16 a state (pipeline/dispatch_record.rs). A warm pass that creates such a
record's state then plans the dispatch as a creation's prediction plans its
first one (nothing bound but the default samplers), with the recorded
lengths, settles its variant as a dispatch does, and makes each region's
VkPipeline on the pass's thread, so their driver data lands in the records
under the names the program's dispatch of that shape asks for.
WarmStatistics::dispatch_pipelines_warmed counts them. Indirect dispatches,
dispatches of a threadgroup range and tile dispatches record nothing.

Records are immutable, one per dispatch shape, so a consumer keeps each once
and needs no rule for which supersedes which. The record format moves to 7:
a compute record's bytes now end in its dispatch list (count, then each
dispatch), so a format-6 record reads as none. The codec bounds the list at
16 dispatches and 31 lengths each, both when writing and when reading.

Tests: warm_record round-trips a compute record with a dispatchThreadgroups:
and a ragged dispatchThreads: carrying two threadgroup lengths, and bounds the
list (more than 16 is unwritable; bytes claiming 17, resealed, are no record;
16 read back). The device test
a_warm_pass_makes_the_pipelines_of_the_dispatches_its_records_name records a
state's creation and first dispatch, checks that the same dispatch again and a
grid of the same edge make and record nothing, warms both records on a
device over the same directory (dispatch_pipelines_warmed equals the regions
the recording dispatch made), and checks that the program's first dispatch
there hands each of its makings the driver cache the pass filled
(caches_shared) and translates nothing. A control device warmed with the
creation's record alone makes no dispatch pipeline and shares no cache.
Verification is in the report to main (potluck lint and lavapipe jobs).

Docs: the runtime README, HOWTO and FAST-PATHS ("Made again before the
program asks") describe the dispatch records; api_signatures gains the
WarmStatistics field.
2026-11-11 19:10:38 -08:00
Anees Iqbal 0bcbca1ff7 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 19:10:12 -08:00
Anees Iqbal 1249910772 RUNTIME_VERSION 2074: a batch's fills of 1 MiB or more run on the copy engine's second queue
The branch before this commit adds the fill queue. On a device whose transfer-only queue family
has two queues or more (NVIDIA's copy engine), a batch's copies in (a Managed buffer's modified
range) and new buffers' fills, 1 MiB or more in all, run on that family's second queue. They go in
a submission of their own after the batches before it, and the batch waits for it on the GPU
(device/staging.rs, WorkCounts::fill_queue_submissions). Smaller fills, and every fill on other
devices, still run at the start of the batch's own work on its queue. A batch that finds all of its
command buffers already pending keeps its fills. Metal's order is kept: a copy in comes after the
work before it and before the commands that take it.

Numbers (managed_copies_bench, p50 ms per frame, fill queue / batch's start):
- Beside another queue's kernels, 1 MiB: RTX 3090 1.80 / 3.53, RTX 2080 1.84 / 3.60, RTX 5080
  Laptop 1.15 / 1.20. 64 MiB: 36.0 / 49.4, 37.8 / 48.2, 3.31 / 5.90.
- Alone, 1 MiB and up: at worst 1.04x as long (the 3090 at 1 MiB in two runs of three, the 2080
  at 64 MiB in one run of two). FAST-PATHS states the trade. Under 1 MiB, no gain past the bench's
  own spread, hence the 1 MiB least.
- Every other submission of the device waits on the GPU for the fill queue's last until the host
  sees it complete (FAST-PATHS records it).

Verified (potluck jobs, on the branch at 24d29ef09c; later commits are docs and comments):
- fill_queue and the bench, 49/49 each: RTX 3090 (m3-max-18358), RTX 2080 (18309), RTX 5080
  Laptop (18379, exclusive): fill queue family 1 (flags 0xc), 2 submissions, the second command
  buffer still running when the third committed; 0 fill-queue submissions in the check just under
  1 MiB. RX 7900 XTX (18310), 780M (18345), lavapipe (18286): no fill queue, 0 submissions.
- 0 NVRM intermapRegisterDmaMapping lines and no hung submit on the three NVIDIA GPUs.
- Lint (18317): clippy -D warnings in all three configurations on the runtime, conformance and
  validation; rustdoc; api_signatures/api_surface 15/15; cost tests 10/10; plan and first-move
  tests 52/52. At the tip: fmt, rustdoc -D warnings (18390), clippy under m2v_gpu and none (18401).
2026-11-11 19:09:14 -08:00
Anees Iqbal 0307da09ba Docs: the fill queue's numbers with the tip's runs on the RTX 3090, RTX 2080 and RX 7900 XTX
At the tip the RTX 3090's 1 MiB frame alone took 0.93 times as long through
the fill queue (18358), against 1.04 in the two runs before (17900, 18199),
and the RTX 2080's 64 MiB one 1.04 times (18309, against 1.00 in 18167): the
trade sentence names both, and the swept size from which the fill queue was
within 1% alone in every run is 256 MiB, not 64 MiB. The tip's runs, whose
two devices both copy at the batch's start under 1 MiB, put them 0.31 to
1.85 times apart there (RTX 2080 18309, RTX 3090 18358, RX 7900 XTX 18310);
64 MiB beside the kernels at the batch's start took up to 49.4 ms, and the
other queue's share moved -11 to +8 points on the RTX 3090 and RTX 2080.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 3a349c2419 Docs: the fill queue's numbers from the sweeps, with the bench's spread under 1 MiB
The ledger bullet and staging.rs's fill-queue docs take the ranges of all
the runs: 1 MiB beside another queue's kernels 1.80-1.84 against
3.53-3.60 ms on the RTX 3090 and RTX 2080 (18199, 18167, 18309), 64 MiB
35.9-37.8 against 40.6-48.9 ms, and on the RTX 5080 Laptop GPU 3.31-3.39
against 5.90-5.92 ms (18316, 18108). Under 1 MiB the fill queue's frames
took 0.51-2.03 times the batch's start's, but at the tip, where both of
the bench's devices copy at the batch's start under 1 MiB, the same bench
put them 0.31-1.39 times apart (18309): the sub-1 MiB differences are not
past the bench's spread, which the docs now say instead of a 2.0x loss.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 700b0fec07 FAST-PATHS: the fill queue's 1 MiB least trades 0.06 ms alone on the RTX 3090 for the halved frame beside other work
At 1 MiB alone the RTX 3090's frame took 1.04 times as long through the fill
queue (jobs 17900 and 18199), and beside another queue's kernels half as
long; the swept size from which it is within 1% alone on all three NVIDIA
GPUs is 64 MiB. The owner's coordinator kept 1 MiB; the bullet says the trade.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 421799152d Fill queue: a batch's fills go there only where they write 1 MiB or more
The fill queue's own submission and the batch's wait for it cost small
copies more than the copy engine saves them. The sweep of
managed_copies_bench (a Managed buffer's copy in each frame, the fill queue
against the batch's start, p50) placed the crossover:

- RTX 2080 (18167): 128 KiB 1.04x alone and 1.11x beside another queue's
  kernels; 256 KiB 2.03x alone (0.94 against 0.46 ms), 1.09x beside;
  512 KiB 1.31x alone; from 1 MiB up 0.98-1.00x alone and 0.51-0.91x
  beside (1 MiB 1.81 against 3.57 ms).
- RTX 3090 (18199): faster or within 4% everywhere; 1 MiB alone 1.04x
  (reproduced, 17900), beside 0.51x (1.80 against 3.53 ms).
- RTX 5080 Laptop GPU (18108, before the sweep): 64 KiB 1.44x alone and
  1.06x beside; from 1 MiB up 0.93-0.99x alone and 0.56-0.96x beside.

So FILL_QUEUE_LEAST is 1 MiB, the smallest swept size from which the fill
queue is no slower beside the kernels on any of the three and at most 1.04
times as long alone: Taken::take_fills takes the batch's fills only where
they write that many bytes in all (copies and zeros), and fewer stay at the
batch's start, as on a device without a fill queue. Decided from bytes, not
from the device.

The fill-queue test gains a last command buffer whose fills (a new Managed
buffer's zeros and its copy in, under half the least each) make no
fill-queue submission and read back exactly. The ledger's costs of
matching Metal gain the fill queue's bullet; the staging, create, bench and
README docs say the least and the measured numbers (the create.rs 82% came
from the raw example and is gone).

Verified: cargo fmt; device runs, lavapipe and lint follow.
2026-11-11 19:08:58 -08:00
Anees Iqbal 6f493dd027 Bench managed_copies_bench: sizes from 4 KiB, with 128, 256 and 512 KiB between 64 KiB and 1 MiB
On an RTX 5080 Laptop GPU a 64 KiB copy in a frame took 0.336 ms (p50)
through the fill queue and 0.234 ms at the start of the batch's work, and
1 MiB the same either way (job 18108): the sizes between them place the
crossover, and 4 KiB the smallest copies.

Verified: cargo fmt; device runs follow.
2026-11-11 19:08:58 -08:00
Anees Iqbal ba823cf01b Test fill_queue: the first copy in completes before the CPU writes the buffer again
The order leg wrote the Managed buffer's host copy again once the command
buffer that took the first copy in was only submitted. That copy reads the
host copy when the GPU runs it, so the write raced it: the leg failed on an
RTX 2080 with the fill queue and on an RX 7900 XTX without one (jobs 17974,
17975), the inline path too. Metal leaves the host copy to the CPU only once
the copy in ran, so the test now takes the first copy in with a command
buffer of its own that completes, then keeps a second one, whose blit reads
the device copy behind a long run of kernels, in flight while the CPU writes
again and a third takes that copy in, which must follow the blit.

Verified: cargo fmt; device runs follow.
2026-11-11 19:08:57 -08:00
Anees Iqbal a721ef347c README: where a device with a copy engine of two queues makes its copies in and fills 2026-11-11 19:08:57 -08:00
Anees Iqbal d3c42ec5b1 Test fill_queue: the second write waits until the first command buffer was submitted
A copy in noted before a committed command buffer's submission is that submission's, as the
runtime's contract says (the device's next submission takes it): on the RTX 3090 the first
command buffer's submission took both copies in, read the second bytes, and made the one
fill-queue submission.
2026-11-11 19:08:57 -08:00
Anees Iqbal 369f43cd06 Test fill_queue: on unified memory the first command buffer completes before the second write
A Managed buffer there is one copy, which the CPU's write races while a command buffer reads it,
as on Metal; lavapipe read the second pattern in the first command buffer.
2026-11-11 19:08:57 -08:00
Anees Iqbal 94180ee4e6 Fill queue: a batch that finds every one of its command buffers pending keeps its fills
A fill-queue submission waits for the batches before its batch, and one of those may wait for a
signal the caller reserved, so taking a command buffer by a wait on the host could hold the
scheduler's thread until the caller submits. The batch checks for room first (a command buffer
whose submission the host saw complete, or fewer than BUFFERS) and keeps its fills at its start
where there is none.
2026-11-11 19:08:57 -08:00
Anees Iqbal a8a1e9017a Fills and Taken give their work back straight from their drain
clippy: draining a Vec into a new Vec to pass it on.
2026-11-11 19:08:57 -08:00
Anees Iqbal 0e53ff56d5 Docs: the fill queue, where a batch's fills run, and what waits for it
device/staging.rs documents the fill queue: why (a copy through the graphics family runs on the
engine the kernels run on; the 3090 and 5080 numbers so far), why not the staging queue, what it
waits for, what waits for it (with the spec's semaphore and sharing text), what it holds, and what
stays where it was. first_move.rs and managed_copy.rs say where a batch's fills go. Queue counts:
the plan takes 18 queues on NVIDIA now, so the measured 17- and 2-queue devices are named by their
queues, and the least plan keeps the fill queue as it keeps the staging queue.
2026-11-11 19:08:57 -08:00
Anees Iqbal a9467e9b50 Fix the fill queue's first build: record with the device's Vk, print the place by hand
The bench runs both paths on one build: the default device, and one whose extra transfer queue
takes the copy engine's second queue, so its fills stay at each batch's start; and sizes from
64 KiB, for a size crossover.
2026-11-11 19:08:57 -08:00
Anees Iqbal 8c0aeddfd5 Runtime: a batch's new buffers' fills go to the fill queue, a copy engine's second queue
On a device with a family of transfers alone that has a second queue (NVIDIA's copy engine), a
batch's buffers' fills (zeros, staged bytes, Managed buffers' copies in) are recorded in a
submission of their own on that queue, which waits for the batches before it on the batch's
VkQueue, what the batch waits for and what completed, and which the batch waits for. Every other
submission waits for the fill queue's last until the host saw it complete, as for the staging
queue. Buffers are already concurrent with that family (sharing.rs), so no ownership transfer.

Not yet built: a build and the device tests follow.
2026-11-11 19:08:57 -08:00
Anees Iqbal 2c772554cd Bench managed_copies_bench: a Managed buffer's copy in a frame, alone and beside another queue's load
Each frame the CPU writes a Managed buffer of 64 or 256 MiB whole and tells it (did_modify_range,
which the runtime copies into its device copy by the next submission), and a command buffer runs
a kernel over its first floats into a Shared buffer, checked. Beside it, optionally, another
queue's command buffers of 24 dispatches over 64 MiB Private buffers, two in flight. Prints the
frame's wall time, the load's rate against the load alone and each phase's host time span, for
the copy-engine work's before and after on discrete GPUs.

Not yet built: the first build is a potluck job.
2026-11-11 19:08:56 -08:00
Anees Iqbal 3649b494dc Example copy_engine: print queue, memory and driver values raw (ash builds without Debug here) 2026-11-11 19:08:56 -08:00
Anees Iqbal 9c463dd892 Example copy_engine: host-device copies on the graphics queue and on a copy engine
A measurement of its own Vulkan device (no runtime): copies between host-visible memory and an
optimal image or a device buffer, 64 KiB to 256 MiB each way, on the graphics family's first
queue and on the first queue of a family of transfers alone (else another compute family), alone
and beside a compute load on the graphics family's second queue; and a copy the next dispatch
waits for, in one submission or across a timeline semaphore. Each phase prints its host time
span so nvidia-smi dmon samples can be placed in it.

Not yet built: the first build is a potluck job.
2026-11-11 19:08:56 -08:00
Anees Iqbal f3b6245ecb Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 19:03:19 -08:00
Anees Iqbal f4814eb381 RUNTIME_VERSION 2073: one page, one import; no guest RAM run imported alone by its pointer
The branch before this commit stops importing the same host addresses twice. A buffer or texture
over a guest RAM chunk that wasn't imported yet, or a copy over one, was bound in an import of
its own run, made from the run's host pointer, while the device's thread imported the whole chunk
from its pointer. That left two live imports of the same host addresses, and the run's was freed
while the chunk's lived. VK_EXT_external_memory_host leaves importing the same host allocation
twice undefined (issue 6). It is the lead for the NVIDIA present stall on the 3090 and the 2080
eGPU.

Now a run is imported alone only on a listed plan, whose chunks and runs are dma-bufs of the RAM's
source, and a run's import never falls back to its pointer. Everywhere else an object or a copy
over a chunk lies in that chunk's one import, made or waited for, as on MoltenVK and ANV. The cost:
a making waits for a chunk the import window hasn't reached yet. imports_inside_live now counts
every import made over host addresses a live import holds (heaps included, on the making and
rebind paths). A new evidence counter, ObjectChurn::imports_over_ram_chunk_pages, counts a view's
own import over guest RAM pages that a live chunk import holds. host_ab prints both, plus
buffers_bound_in_import. HOWTO and API.md describe the single import and its cost.

Verified (potluck jobs, on the branch):
- lavapipe, full runtime suite: 2200/2200 at the tip (m3-max-18365) and at c6f775cefe (18331).
- The one_import device tests' counts show their paths ran: [pointer imports, bound in import,
  copies over live, imports_inside_live] = heap first [1, 2, 1, 0], buffer first [2, 1, 1, 0].
- Lint (m3-max-18364): clippy workspace all targets all features; the runtime with --cfg m2v_gpu
  and with --cfg m2v_gpu --cfg m2v_gpu_hazards; rustdoc -D warnings; api_signatures/api_surface.
- metal2vulkan with no feature and with each alone (18340).
Not yet run: the NVIDIA device tests at the tip; the opt-in hazard test
(tests::import_overlap_hazard) on gem10's 3090, before and after; the consumer's NVIDIA walks.
2026-11-11 19:02:18 -08:00
Anees Iqbal 13358c902e Tests: an opt-in GPU hazard running the overlapping-import shapes at volume
Two tests under m2v_gpu with m2v_gpu_hazards, on Linux. One makes objects
over chunks of a fresh guest RAM the device's thread has not imported
(each a jump past its window), writes and reads them by blits, makes a
second buffer over the same pages, and drops the first: 6 RAMs of 24
chunks. The other maps 32 views of 512 scattered memfd pages, makes a
no-copy heap over each, a buffer over exactly its bytes and 32 buffers of
64 to 384 KiB inside it, each blitted and dropped while the heap lives.
A runtime that imports those runs or sub-ranges by their own pointer
frees each such import while the larger import of the same pages lives.
Each prints the import and placement counts that say which path ran;
the job reads the kernel log. Not yet run.
2026-11-11 19:02:04 -08:00
Anees Iqbal c290092aae Lint: a routed run's one range is a slice of one, not a one-element array
clippy's single_range_in_vec_init under --cfg m2v_gpu (potluck job
m3-max-18340 on gem10).
2026-11-11 19:01:50 -08:00
Anees Iqbal b3a9bda684 Docs: copied-host-pages names pages a live import holds some of; listed runs alone described where they stay
API.md's copied-host-pages entry gains the over-a-live-import cause
(copied_over_live_imports, announced once per device as the others are).
HOWTO's listed-plan paragraph described its runs alone "as above", text
the previous commit removed: it now says what a listed RAM's run import is
(a dma-buf), what it costs, how it orders, and that MoltenVK and ANV import
the chunk instead.
2026-11-11 19:01:50 -08:00
Anees Iqbal 2b0f90f453 Tests: guest RAM over pointer chunks imports no run alone; tests hold it to that
host_ram_device's window, down-the-RAM, margin and ordering tests expected
an object over a chunk not imported to lie in an import of its own run on
every device but MoltenVK and ANV. A RAM with no source of dma-bufs has
chunks imported by their pointer, and its runs are no longer imported
alone beside them (RamOnDevice::runs_alone): each test now asserts the
object imports its chunk and no run import lives. The two ordering tests
are renamed for what they order now (two buffers in one chunk's import, a
chunk-bound buffer and copies). runs_alone moves to the dma-buf tests,
whose listed RAMs still import runs alone, and kept_in_its_run goes with
the run imports it kept. The defect's evidence keeps its measurements
without the old test names.
2026-11-11 19:01:50 -08:00
Anees Iqbal d76f7f7ee7 One page, one import: no run of a guest RAM chunk imported alone by its pointer
An object over a chunk not imported yet, and a copy over one, was bound in
an import of its own run alone, made by the run's host pointer while the
device's thread imported the whole chunk by its pointer: two live imports
of the same host addresses, the run's freed while the chunk's lived.
VK_EXT_external_memory_host leaves the same host allocation imported twice
undefined (issue 6). Runs are now imported alone only on a listed plan,
whose chunks and runs are dma-bufs of the RAM's source, and a run's import
never falls back to its pointer. Elsewhere every object and copy over a
chunk lies in its one import, made or waited for, as on MoltenVK and ANV.
The price is a making that waits for a chunk the window has not reached.

imports_inside_live now counts every import made over host addresses a
live import holds: a no-copy object's own import over another's (heaps
included) or over a live chunk import at the same addresses, and a
chunk's import over a live no-copy import, on the making and rebind
paths. A new evidence counter, imports_over_ram_chunk_pages, counts a
view's own import whose guest RAM pages a live chunk import holds at the
RAM's addresses. host_ab prints both and buffers_bound_in_import.

Not yet verified: built and tested next on lavapipe.
2026-11-11 19:01:50 -08:00
Anees Iqbal 4f3bc2e7a3 One page, one import: compile fixes (a Pages placement accessor, raw handle bits in Debug, an unshadowed test heap)
The first build of ed11f23e9a failed: bind_in_import read Pages' private
memory field, InImport's Debug printed handle flags ash gives no Debug for,
and a test's heap binding shadowed its heap helper. Found by potluck job
m3-max-18250 (lavapipe build on ms01).
2026-11-11 19:01:50 -08:00
Anees Iqbal cfd7bc829e One page, one import: a buffer over a live import's pages lies inside it, else a copy
VK_EXT_external_memory_host leaves a host allocation imported twice into one device
undefined (issue 6: "Some platforms do not allow locking the same physical pages for device
access multiple times, so attempting to do it may result in undefined behavior"). The runtime
imported the same pages twice in several ways: a heap's own import was never noted in
HostAliases, so a no-copy buffer over exactly a heap's bytes, or over part of them, imported
them again (the consumer's guest heaps over 2 MiB page-block views, and the block's view as a
buffer); a buffer over part of a live buffer's bytes imported its own (counted,
object_churn.imports_inside_live: 34 in one 3090 walk); and a heap over a live buffer's bytes
imported its own.

Now:
- a heap's own import is noted (HostAliases::hold), joining no key;
- a buffer or heap over exactly a live import's bytes lies in that import (a heap keeps its
  heap identity);
- a buffer whose window a live import holds all of is bound inside that import's memory at
  its offset, with a VkBuffer of its own and no import (Device::bind_in_import,
  Placement::in_import, which holds the import; the import is exposed, so never released
  while idle); counted object_churn.buffers_bound_in_import;
- a buffer or heap whose window a live import holds some of and not all, and a heap a live
  import holds more than, is a copy (CopiedBecause::OverImport, copied_over_live_imports,
  announced copied-host-pages);
- rebinds take the same rule;
- imports_inside_live now counts only imports made where a live one held some of the pages
  all the same (two buffers made at once).

Tests: host_aliases unit test a_page_a_live_import_holds_is_never_imported_again; device
tests one_import (heap first, buffer first). Not yet run: this commit is for the build.
2026-11-11 19:01:50 -08:00
Anees Iqbal 269d7066c4 FAST-PATHS: what is built around a cold making's driver time, and the compute kernels' case
The known gap on the cold making of a 200,000-word compositing module ended "Nothing is built
around it", which was not true. It now names what is:

- the driver records across boots (`shader_cache/driver.rs`), named by the driver's identity, so a
  driver update, another device or a removed content directory makes every making cold again, and
  no machine's records serve another's;
- pipeline records and `Device::warm`, which remake a previous process's creations on a thread of
  their own below every other making, and what they do not cover today (a compute state that
  states no required threadgroup size predicts nothing, so its dispatches' pipelines are made at
  their first dispatch);
- `PipelineWaitPolicy::Bounded` at creation and at commit, and dispatches that hand their making
  to the pool;
- the consumer's creation of guest states on a compile thread off the guest's command path.

It adds the compute case: a convolution kernel's 12 variants at a macOS 12.7.6 login, one SIMD8
program each of 6,222 to 8,925 instructions with 70 to 221 spills, and the host-load
sensitivity that made the same login's makings 2 to 13 times slower than alone.

Measured on the Iris Xe (Mesa 26.2.6), the dumped modules made by a scratch harness with
the logged specialization, one module of its own per making, the driver's disk cache off:
- the 23,108-word variant alone 0.27 to 0.34 s (jobs 18284, 18292); 11 at once 0.31 to 0.53 s
  each, 0.50 to 0.53 s for all (18293); device robustness on or off alike (18292);
- the 138,047-word fragment module alone 2.03 to 2.42 s, two at once 2.42 to 2.53 s each, four
  at once 2.69 to 3.33 s each (18284);
- under 20 and 30 busy threads on the 20-CPU host, that fragment making 6.27 and 7.94 s, and 11
  kernel makings at once under 20 busy threads 0.78 to 1.44 s each (18293);
- the program counts from INTEL_DEBUG=cs (18226).
The login's own numbers (4.87 s; 1.5 to 4.2 s, 10 or 11 at once; the guest's 1 to 197 command
buffers a second during the making) are the consumer's cold-login log at the 12.7.6 capture; the
3.1 ms warm making is the consumer's warm boot.

Docs only.
2026-11-11 18:36:17 -08:00
Anees Iqbal 61bb2acf30 RUNTIME_VERSION 2072, SEMANTICS_VERSION 2039: a call only quad helpers reach through a select is fenced on Apple GPUs
On the M3 through MoltenVK, a 27.0.1 guest's widget glass drew white strips or a comb in 8x4
blocks at its vertical edges, in every saved screen. The widget's gradient draw writes colour 0 in
the storage form and ends in an OpSelect whose one value operand is a NoContraction add, picked
where coverage is below a bound. SPIRV-Cross inlines that single-use operand into the ?: arm, so
the [[clang::optnone]] add runs only in lanes past the gradient's vertical edges: the quad
helpers. That is Apple's recorded store-drop shape (DriverWorkaround::DiscardDropsSimdgroupStores):
a call only helpers make, then a storage write, and the simdgroups at the edge lose the draw's
writes. spirv::helper_branches looked only at branches, so the select was neither guarded nor
fenced, and no note was recorded.

Now the helper guard treats a non-branch path to a call as a branch: a scalar OpSelect value
operand, a scalar OpLogicalAnd/OpLogicalOr right side, or a reader inside a non-uniform
selection arm, reached through single readers. Such a call gets the fence the branch form gets
(an identity OpGroupNonUniformShuffle after it, which SPIRV-Cross writes inside the arm). Where
the fragment stage can't shuffle, the pipeline records PrecisionNote::HelperBranchDropsSimdgroupStores.
The guard runs only on a profile with DriverWorkaround::DiscardDropsSimdgroupStores (MoltenVK on an
Apple GPU), so no other device's module changes. It is exact and takes no switch. Docs: API.md's
degrade-notice catalogue and artifact.rs name the new case.

Tests: fixture rch_helper_select (our own MSL: a NoContraction sum picked where coverage != 1,
with no branch), lane runtime_lane::helper_select, unit tests on modules built in the test (an
arm-read call fenced; loop-read and uniform-arm calls not).

Verified (potluck jobs, on the branch):
- M3 MoltenVK 1.4.2 (m3-max-18169), helper_select: without the fix rch_select_arm and
  rch_select_and lost 174 covered pixels' writes each, in whole groups, fences 0, no note; with
  it fences 1, 0 lost, 0 extra, no note. The two controls (the pick an implicit-LOD sample reads
  after it; the pick on a constant-buffer flag) unchanged at fences 0, 0 lost. helper_tangle and
  discard_fetch_groups unchanged.
- GPU time on the M3, worst case (every fragment of a 1024x1024 pass takes the arm): 32 draws
  2.874 -> 3.125 ms, least of 5 command buffers (+0.25 ms per 33.5M fragments).
- Golden tables on the M3 (18216): exactly 4 rows move, rch_select_arm and rch_select_and in
  both spellings, in the moltenvk-m3 cell alone; no other fixture's cell on any profile.
- clippy plain, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings (18210).
Expected, not yet run: the consumer's 27.0.1 boots at the fix against its base.
2026-11-11 18:22:48 -08:00
Anees Iqbal 9efdb88630 Bless rch_helper_select's expectation rows and golden printout
On the M3 at 86884548c8 (m3-max-18216): bless_engine_inventory took 0 moved cells and 10 new rows, all rch_helper_select's; bless_engine_goldens wrote tests/air_input/rch_helper_select.txt under the pinned LLVM 21.
2026-11-11 18:16:57 -08:00
Anees Iqbal e97d5da60c Docs: HelperBranchDropsSimdgroupStores also covers a call in no branch that SPIRV-Cross writes in one
The catalogue entry and the variant's rustdoc name the new case: a ?: arm, the right side of a && or ||, or a selection's arm, where the call's value is read once (spirv::helper_branches).
2026-11-11 18:13:09 -08:00
Anees Iqbal 86884548c8 Test: a call read once in a helper arm is fenced where SPIRV-Cross writes it, not where a loop reads it
tests::engine_helper_picks builds fragment modules that sample at LOD 0, add 1 to the red with NoContraction in the entry block and store the sum once: in the arm of a selection on the coordinate (fenced on moltenvk-m3), in a loop body, or in the arm of a selection on a specialization constant (neither fenced); intel-arl-anv fences nothing. SPIRV-Cross writes the first call inside the arm and keeps the loop's at its definition (checked with Homebrew's spirv-cross on synthetic modules).
2026-11-11 18:11:14 -08:00
Anees Iqbal dd2723f57a Lane helper_select and unit test: a pick only quad helpers make, with no branch
The fixture rch_helper_select's companions (scripts/regen-air-fixtures,
m3-max-18157): every pick is an AIR select, which the translator writes as an
OpSelect and SPIRV-Cross as a ?: whose arm calls spvFAdd.

runtime_lane::helper_select draws the 32x16 triangle of guarded_effects with
each function and checks every covered pixel's write against Metal's answer:
no write may be lost where the fragment records no
HelperBranchDropsSimdgroupStores, on a device with the defect the ?: arm and the
&& right side are fenced (or noted without a fragment shuffle), and the pick a
sample reads after it and the pick on a constant block's flag are left alone.
a_fenced_pick_s_gpu_time prints the GPU time of 32 draws of a 1024x1024 pass
whose every fragment picks the sum, and checks every texel.

tests::engine_fragment::a_helper_call_a_select_picks_is_fenced holds the same
forms on moltenvk-m3, on it without the fragment SHUFFLE (the note instead),
and on intel-arl-anv (nothing), each module through L3.

Verified so far: nothing; the M3 runs before and after the fix follow.
2026-11-11 18:11:13 -08:00
Anees Iqbal 4e803f6641 Fixture rch_helper_select: rch_select_sampled picks one coordinate, so the compiler writes a select 2026-11-11 18:11:13 -08:00
Anees Iqbal 790c0a1dc9 Fixture rch_helper_select: pick sums of values every invocation has, so the compiler writes selects, not branches
With a buffer load in the picked arm, the compiler kept a branch (the load is not speculated), which the branch analysis already covers. Summing components of the sampled colour lets it speculate the addition into a select.
2026-11-11 18:11:13 -08:00
Anees Iqbal fbc5374a07 Fixture rch_helper_select: picks a sum only quad helpers make, with no branch
Fragment functions, without fast math so every float operation is
NoContraction (SPIRV-Cross's optnone spvFAdd), that read a coverage texture,
sample at LOD 0 and pick, where the coverage is not 1, a value an addition
makes: as a component (rch_select_arm), on the right of a && after the
coverage test (rch_select_and), as a coordinate an implicit-LOD sample then
reads (rch_select_sampled), and on a constant block's flag
(rch_select_uniform). Each writes a texture after it. The compiler writes each
pick as a select, and SPIRV-Cross writes that as a ?: whose arm holds the call.

The .ll and .air.ll companions follow from scripts/regen-air-fixtures.
2026-11-11 18:11:13 -08:00
Anees Iqbal d7a2d20011 helper_branches: a call SPIRV-Cross writes in a ?: arm, a && or || right side, or a selection's arm counts as a helper-path call
SPIRV-Cross moves an expression read once into what reads it. An optnone call
(a NoContraction FAdd/FSub/FMul, QuantizeToF16, MulExtended, Reflect) outside
every selection and loop, whose value reaches through single readers a value
operand of an OpSelect on a scalar condition, the second operand of a scalar
OpLogicalAnd/OpLogicalOr, or an instruction inside a selection's arm, is
written in that arm: `cov < t ? spvFAdd(a, b) : c`. Where the condition is
not draw-uniform, only the quad helpers past a primitive's edges may take it,
and on MoltenVK on an Apple GPU (DriverWorkaround::DiscardDropsSimdgroupStores)
Apple's compiler then loses the simdgroup's texture writes after it. The
analysis looked only at branches, so such a call was neither fenced nor noted.

Facts::conditional follows the chain (a value read more than once, a phi or
terminator operand, an instruction without a result, or a reader inside a loop
the call is outside ends it: SPIRV-Cross keeps that value where it is defined,
checked with Homebrew's spirv-cross on synthetic modules). Such a call is
counted as one inside a construct: fenced by the identity shuffle where the
fragment stage shuffles, else PrecisionNote::HelperBranchDropsSimdgroupStores.
The per-instruction write test of the open blocks is now linear in the block.

SEMANTICS_VERSION 2039: modules with such a call get fences on profiles with
the workaround.

Verified so far: nothing; the lane and unit tests follow.
2026-11-11 18:11:13 -08:00
Anees Iqbal a3ff35c1a0 Re-bless the authored compile census at d0f800ddd0
Its product fingerprint follows the runtime-sources pin at d0f800ddd0 (dv-m3).
2026-11-11 18:09:52 -08:00
Anees Iqbal e8558ff364 Re-bless the golden tables at d0f800ddd0
What moved since 892e4b230b's bless. Blessed on the M3 (dv-m3).
2026-11-11 18:09:52 -08:00
Anees Iqbal bb113bd5eb Tests: the texture-over-dma-buf residency test waits for the in-place checks as their own tests do
host_residency::a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable waited for the
device's in-place checks within SETTLE (20 s), the bound for an import's release. On ms01's Iris
Xe in the round at d0f800ddd0 (m3-max-18134) the checks took longer and the test failed with "the
in-place checks never answered" at 27 s, while the in-place check's own tests in the same run
passed at 47-56 s. It now waits CHECKS (120 s), the bound in_place_check.rs and copied_device.rs
use. Test-only.
2026-11-11 18:00:28 -08:00
Anees Iqbal b0f40ec5e2 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 17:58:32 -08:00
Anees Iqbal 5175cca5b4 Pipeline creation log: a compute line names its kernel's descriptor, and the dump writes compute modules
A compute pipeline's line in METAL2VULKAN_LOG_PIPELINES named the kernel's function, its SPIR-V
hash and length, its specialization constants and notes, but not what the kernel was made from:
a cold boot's slow compute creations could not be made again off the device, because the
function's Metal constant values were nowhere in the log, and METAL2VULKAN_DUMP_PIPELINES wrote
render modules only.

The compute line now ends with `; descriptor: ` and the same naming a render state's first line
gives each function (its name, the SHA-256 of its bitcode, the constant values by index and by
name with their types and bytes), from one helper both share (`render::logged_function`). With
the dump directory set, the line's module is written there as `<hash>.spv` (`dump_modules`, the
render dump's writer, now over any modules), and a failed write is named in the line as a render
line names it. Nothing is kept or measured while the variables are unset: the descriptor's text
is made only where the log is on (`compute_kernel`).

The creation log's module doc also names the record words the split prints since the record
naming change (`record's cache shared`, `found in cache`, `compiled`).

Test: `opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes` now runs
its child with the dump directory set, and asserts the line's descriptor (the kernel's name,
`air`, `constants {`), no dump failure, and a SPIR-V module (its magic) at the hash the line
names. It and the creation_log unit tests, and lint, run on this commit as jobs after it is made
(the report names them); a failure is fixed forward.
2026-11-11 17:57:53 -08:00
Anees Iqbal a58070d630 Docs: a cold making of the 200,000-word compositing fragment module is the driver's own cost
Records, as a known gap, what is left of the Iris Xe's cold login
creations after the records stopped naming attachment formats: the one
compile of the compositing fragment module (203,016 words, macOS
26.7.2) that every state over another format then finds in its record.

Measured with a scratch harness making the module's fragment shader
library cold, the driver's disk cache off:
- ANV, Iris Xe, Mesa 26.2.6: 3.3 to 3.7 s at load ~16 (m3-max-17871);
  its program is 29,101 SIMD8 instructions, 34 spills, 10,585 non-SSA
  registers.
- RADV, Radeon 780M: 1.3 to 3.0 s (m3-max-17958, -18098).
- RTX 3090, 620.70.06: 4.5 to 7.4 s (m3-max-17957, -18097).

Why no translator change: spirv-opt -O (186,314 words) and -O with
frozen specialization constants (180,402) leave ANV's NIR within 0.2%
(27,347 to 27,393 instructions) and its program within 9 instructions,
and their creations are no faster than the original's within the
run's noise (m3-max-18022, -18034, -18127). Holding half values in 16
bits across moves, phis and selects (a scratch pass on the -O module)
makes it 29,719 instructions with 103 spills. So the words the
translator emits do not drive ANV's time; the shader's own work does
(NIR: 4,163 fmul, 2,868 fadd, 1,689 ffma, 1,835 csel, ~290 samples,
30 loops).

VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT: ANV builds the same
program in the same time and the 3090 the same time; RADV takes 0.9
to 1.0 s (m3-max-18098), at a draw cost not measured. Nothing is
built around it. Doc only.
2026-11-11 17:57:53 -08:00
Anees Iqbal 55e664e122 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 17:55:35 -08:00
Anees Iqbal 8db2f6f5c8 RUNTIME_VERSION 2071: the runtime's own runs of memory frees step aside for the device's submissions
On NVIDIA (620.70.06) each vkFreeMemory holds the device's other submissions while it runs, and
not only for imports: plain host-visible frees hold too. RV 2067 paced the device checks' own
allocations and frees; the runtime's other threads still freed in bursts.

Now step_aside gains a paced-thread mark and pace(): a runtime thread that frees memory in a run
waits before each free until as long as its frees before it took has passed since the last one
ended (the checks' OwnCall rule; the checks' step now counts from the calls' end too). Paced: the
free thread before each block (fresh-pages imports included); the residency thread's idle
releases (its sweep holds imports weakly while it waits, so a program's release meanwhile still
frees its import inside that release); a guest RAM's give-back of untaken chunks and its listed
thread's idle chunk and list releases. Never paced while a caller waits for the frees: an
allocation at the limit (free-thread waiters, Allocations::give_back_awaited), the device's
teardown, a guest RAM use's end. A program's own release of a no-copy buffer still frees its
import in the release, unpaced (Metal's contract). Handler threads are not paced (a wait there
would delay the completed handlers behind it). WorkCounts gains memory_frees_paced and
memory_frees_paced_nanos. FAST-PATHS known gap: NVIDIA's vkFreeMemory holds other submissions.

Tests: tests::import_free_hold_bench (ignored bench: five kinds freed in turn and paced, beside a
fill every 250 us); a posted-frees burst runs paced; the at-limit test asserts no free is paced
while the allocation waits; step_aside units.

Verified (potluck jobs, on the branch):
- RTX 3090 (18052, quiet host, two runs), fill p50 beside frees in turn -> paced: 512 KiB pointer
  imports 0.46-0.50 -> 0.29-0.32 ms; 512 KiB dma-buf imports 0.47-0.54 -> 0.23-0.25 ms; 64 MiB
  pointer imports 2.6-2.9 -> 0.10-0.13 ms; 512 KiB plain 1.2-1.6 -> 0.17-0.22 ms; 64 MiB plain
  70-79 -> 0.15-0.19 ms (baseline 0.13-0.14 ms). Paced runs take 1.2-2.2 times as long. posted_frees
  5/5 (each in its own process), burst 2 of 2 frees paced, step_aside 7/7.
- RTX 2080 (18054): the same results.
- lavapipe touched suites 130/130 (18094); clippy all features, --cfg m2v_gpu, --cfg m2v_cpu_icd
  and rustdoc -D warnings (18103, 18094).
2026-11-11 17:54:36 -08:00
Anees Iqbal b7d06c3820 Docs: a check's step waits until its own calls' length has passed since they ended 2026-11-11 17:54:27 -08:00