Commit Graph
4140 Commits
Author SHA1 Message Date
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
Anees Iqbal d729b77438 FAST-PATHS: on NVIDIA each vkFreeMemory holds the device's other submissions, measured
The known gap the frees' pacing answers in part: tests::import_free_hold_bench on an RTX 3090
(NVIDIA 620.70.06, quiet host, two runs) put a fill's commit to completion at 0.13-0.14 ms beside
no free, 0.46-0.54 ms beside runs of 512 KiB pointer or dma-buf imports freed one after another
(each free 0.26-0.39 ms), 2.6-2.9 ms beside 64 MiB imports (2.2-2.4 ms each), 1.2-1.6 ms beside
512 KiB plain host-visible allocations (1.1-1.2 ms) and 70-79 ms beside 64 MiB ones (28-30 ms);
paced, 0.10-0.32 ms beside every kind. An RTX 2080 on a loaded host showed pacing lower the median
beside every kind too. What stays open: a program's own release of a no-copy buffer frees its
import there (Metal's contract), unpaced, as does a completed command buffer's handler that frees
the imports its blits held last; one free still holds a submission that meets it.
2026-11-11 17:54:27 -08:00
Anees Iqbal f225901063 import_free_hold_bench: four plain host-visible allocations of 64 MiB beside the fresh pages' imports 2026-11-11 17:54:27 -08:00
Anees Iqbal 2bc93939b1 import_free_hold_bench: dma-bufs imported as a no-copy buffer's are, for a buffer made for them 2026-11-11 17:54:27 -08:00
Anees Iqbal 17264bcfbe import_free_hold_bench: two expressions in the forms clippy asks for 2026-11-11 17:54:27 -08:00
Anees Iqbal 92b5394ed4 step_aside tests: an owed wait is at least half the call, whatever the host's scheduling between them 2026-11-11 17:54:27 -08:00
Anees Iqbal 2106a7f65f Tests: the import free hold bench, and the posted frees run paced
tests::import_free_hold_bench measures what a vkFreeMemory of an import of host pages holds of
another thread's submissions: a pinger commits a one-word fill every 250 us while the bench's
thread makes and frees, through the runtime's doors, 32 pointer imports of 512 KiB, four of 64
MiB, 32 dma-buf imports of 512 KiB (udmabuf) and 32 plain host-visible allocations, each kind's
frees in turn and paced (step_aside::pace), printing the frees, the runs and the pings beside
them. tests::posted_frees gains a burst of posted frees that runs paced, and the allocation at the
limit now checks that the frees it waits for are not paced. api_signatures re-blessed for the two
new WorkCounts fields.
2026-11-11 17:54:27 -08:00
Anees Iqbal c9b96ccdb0 Pace the runtime's own runs of memory frees after the frees before them
NVIDIA's driver holds every other thread's vkQueueSubmit while it frees memory, a host-pointer
import's for 0.5 to 0.9 ms on an RTX 3090. The submission checks already pay their own
allocations and frees back before their next step (step_aside::OwnCall); this applies the same
owed time to the device's own threads that free in runs: the free thread before each block, the
residency thread before each idle import it releases, and a guest RAM's threads before each chunk
or list they give back or release. Each waits until as long as its frees before took has passed
since the last ended (now also the checks' rule), never while a caller waits for those frees (an
allocation at the limit, the device's teardown, a guest RAM use's end). The residency sweep holds
its imports weakly while it waits, so a program's release meanwhile frees its import in that
release, as before. Counted: WorkCounts::memory_frees_paced, memory_frees_paced_nanos.

Not yet built: the bench that measures the hold and the paced frees follows.
2026-11-11 17:54:27 -08:00
Anees Iqbal 5beb5ee031 Tests: the submission checks' recall test counts copies besides priming's
tests::submit_check_device::the_checks_answer_once_and_a_second_device_recalls_them held the
device that ran the checks to the cmd_copy_buffer count of the one that recalled them, which
held while every device was primed. Since 6ce451f452 a device made again on what stays loaded is
not, so the first (primed: priming's one copy within its buffer) counted 1 and the second 0
(lavapipe, gem10, m3-max-18039 and 18111, 3 of 3). Each count now leaves out the copies the
device's priming recorded, where ExitRegistrations::primings shows it was primed.
2026-11-11 17:45:41 -08:00
Anees Iqbal d0f800ddd0 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:15:40 -08:00