Commit Graph
4101 Commits
Author SHA1 Message Date
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
Anees Iqbal 100ea7b465 RUNTIME_VERSION 2070: a texture in place over a no-copy buffer's dma-buf no longer pins the buffer's import
RADV lists every imported memory in every kernel submission, 0.43-0.44 us each on the 780M and
the XTX (raw probe: 512 dma-buf imports of 1 MiB cost 229-234 us per submission against 7-8 us
with none; 64 pointer imports of 1 MiB 191-200 us). A texture in place over a no-copy buffer's
dma-buf import kept the buffer's import live for good, so each such surface listed two dma-bufs
per submission, though its DRM_FORMAT_MOD_LINEAR image has its own dedicated import.

Now HostPages::dma_buf reads the pages the way a blit does (blit_pages: imported again if
released, still releasable), and the in-place watch and dma_buf_unplaced take the offset from
Buffer::offset_in_host_pages() instead of a pinning memory() read; heap images take the same
path. Sampling and rendering go through the image's own import. A blit that names such a
texture runs on the buffer's bytes and imports the buffer again, as any blit does. The image's
own import stays listed for its life (RADV requires a dedicated allocation for it). The
per-import cost and the remaining limits (second buffers and bindings keep imports for good;
separate submit calls list every import again; no documented switch takes an import off the
list) are a FAST-PATHS known gap.

Tests: lane runtime_lane::submit_per_surface (128 surfaces of 64 KiB, each a no-copy buffer and
an in-place texture, measured after a 4 s idle); device test
host_residency::a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable.

Verified (potluck jobs, on the branch):
- 780M PHOENIX, Mesa 26.2.6: before (17864) 256 dma-bufs listed per submission, 119 us in the
  ioctl, 128 buffer imports kept for a texture; after (17939, three runs) 128 listed, 58-67 us,
  0 kept. In use: 256 listed, 115-129 us.
- XTX NAVI31: before (17927, load ~20) 256 listed, 160 us; after (17999, three runs) 128 listed,
  59-70 us; in use 256 listed, 108-109 us.
- The device test passed on the XTX (17999) and the 780M (18002): "1 chunks released under a
  texture in place, rendered into, imported again by its blit and released again".
- lavapipe 164/164 (18007; the device test skips: lavapipe imports the pointer).
- clippy default, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings (17978, at the last
  code commit; later commits are docs).
In the consumer's 780M walk the saving is bounded: at most about 43 of 160 kept imports are kept
by a texture alone (about 18 us per submission, for surfaces idle past their window).
2026-11-11 17:14:40 -08:00
Anees Iqbal 515367b8f2 FAST-PATHS: the XTX's submission times beside surfaces over dma-bufs
submit_per_surface on the RX 7900 XTX, three runs at the tip: 128 surfaces list
256 dma-bufs (108 to 109 us in the ioctl) while in use and 128 after their idle
window (59 to 70 us). Text only.
2026-11-11 17:14:21 -08:00
Anees Iqbal e2c31d54e4 FAST-PATHS: what RADV lists in each submission, and what a texture in place over a dma-buf keeps
The idle-release bullet says a texture in place over a no-copy buffer leaves
the buffer's import to the release (its blit reads the buffer as any blit), with
the 780M lane's counts (submit_per_surface, three runs: 128 surfaces list 256
dma-bufs while in use, 128 after the idle window). A known-gap entry records the
per-entry cost the raw probe measured on the 780M and the XTX (0.43 to 0.44 us
per dma-buf import per kernel submission), what Vulkan offers that does not
change it (memory priority, no device address, no pageable extension listed),
that separate submission calls list every import again, and that each in-place
texture's own image import stays listed for its life (RADV requires a dedicated
allocation of such an image).
2026-11-11 17:14:21 -08:00
Anees Iqbal e70c878fed Test: a texture in place over a dma-buf renders through its own import; its blit reads the buffer
On the 780M the test's claim that the texture's blit imports nothing failed:
a blit that names a texture over a buffer runs on the buffer's bytes
(blit_texture.rs, the module's note), so it imports the released buffer again,
as any blit does, and leaves it releasable. The test now clears the texture in
a render pass while the buffer's import is released (written through the
image's own import, residency unchanged, the pages read back), then checks the
texture's blit imports the buffer again and that it is released again.
2026-11-11 17:14:21 -08:00
Anees Iqbal f2d9378edb Lane: submit_per_surface counts each phase's textures and releases, not the device's totals
dma_buf_textures_in_place and host_imports_released are running totals, so the
64-surface phase printed 96 textures in place (32 + 64). The lane now reads both
at the phase's start and prints the difference. Report-only lane; built and run
on the 780M with the next runtime change.
2026-11-11 17:14:20 -08:00
Anees Iqbal 2abe74f6f1 Docs: say what an in-place dma-buf texture lists now, without the history
The host_residency module doc and HOWTO section 6 told what a guest surface
listed before the in-place texture stopped pinning its buffer's import; docs
say what is true now. Text only.
2026-11-11 17:14:20 -08:00
Anees Iqbal a4a6497772 Heap textures over dma-buf pages read the heap's pages as the in-place ones do
HostPages::dma_buf now answers a Result (the pages read as a blit reads
them, imported again where released); the heap's dma-buf image maker
(texture/heap.rs) is its other caller and takes the change. A heap's import
is kept for good whatever reads it, so nothing of its residency changes.

Found by the lint job m3-max-17783 (E0271 at texture/heap.rs).
2026-11-11 17:14:20 -08:00
Anees Iqbal 9b2ef7c237 A texture in place over a dma-buf import leaves the buffer's import releasable
RADV lists every imported VkDeviceMemory in every kernel submission, about
0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch Vulkan
probe, Mesa 26.2.6, Linux 7.3.3: 64, 256 and 512 dma-bufs held cost 31.5,
111 and 229 us an empty vkQueueSubmit against 7.2 with none). A consumer's
guest surface is a no-copy buffer over its pages and a texture in place over
the buffer: on RADV the texture is a DRM_FORMAT_MOD_LINEAR image in a
dedicated import of a dma-buf of its own pages, and making it read the
buffer's import apart (ReadApart::Texture), which kept the buffer's import
for good. So each surface listed two imports in every kernel submission for
its whole life.

The image asks the buffer's source for its own pages and binds none of the
buffer's memory, so its making now reads the buffer's dma-buf pages as a
blit does (HostImport::blit_pages: imported again where released, left
releasable), and the in-place watch a rebind reads takes the texels' offset
from the buffer's place in its host pages (Buffer::offset_in_host_pages),
not from their import. The buffer's import is then released after its idle
window like any blit-only one; the texture's image keeps its own import.
Pointer-imported pages, shadows and texel views still read the import apart:
they bind or read the buffer's memory.

Test: tests/host_residency.rs
a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable: the buffer
under an in-place texture is released (its chunks leave
dma_buf_memories_live, the image's import stays), the texture reads the
CPU's writes made meanwhile without importing anything, and the buffer's
next blit imports it again. Without the change the release never comes.
Docs: host_residency.rs, HostMemory::with_dma_buf, HOWTO.md.
2026-11-11 17:14:20 -08:00
Anees Iqbal eedd63e340 Lane: what each kernel submission costs beside surfaces over dma-buf pages
runtime_lane::submit_per_surface holds 0, 32, 64 and 128 surfaces, each a
no-copy buffer over a run of memfd pages imported as dma-bufs and a texture
in place over it (HostPageTexturePolicy::InPlace), reads each texture once,
then times 300 single-fill command buffers at once and again after the
surfaces sat idle past the device's first idle window. It prints the
textures in place over a dma-buf, the dma-buf memories live of buffers and
of images, the buffer imports released while idle and those a texture keeps,
and, under the kernel-submission counter, the dma-bufs each kernel
submission lists. A measurement, ignored by default, Linux only.

Why: RADV lists every imported VkDeviceMemory in every kernel submission,
about 0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch
Vulkan probe, Mesa 26.2.6, Linux 7.3.3), and a consumer's guest surface may
list two: its buffer's import and its in-place image's dedicated import.

Not run yet: built and run by potluck jobs on the 780M and the XTX.
2026-11-11 17:14:20 -08:00
Anees Iqbal d7b399c09c 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:10:36 -08:00
Anees Iqbal 975a78ce6b RUNTIME_VERSION 2069: a device made again on what stays loaded skips the exit guard's priming
A device is primed only when it will register the exit hook: the process's first device, the
first after a shared-object load, or a device of a new identity. A device made again on what stays
loaded registers nothing, and its calls are not the first ones (an earlier device's priming made
each), so it now skips priming. To answer that before priming, the device's functions and guard
identity are made earlier in the making. If a device registers without having been primed
(something changed between the check and the registration), the calls primed before are
forgotten, so each section's first call registers the hook again. ExitRegistrations (hidden)
gains a primings count.

Why: on the RTX 3090 (620.70.06) priming spends 112-144 ms in one call,
vkCreateIndirectCommandsLayoutEXT (m3-max-17899), and over 8 makings every device after the first
was made with no load (loads 67, at_devices 1; 17904): each re-made device paid priming for
nothing.

Tests: exit_guard::whether_a_device_registers_is_answered_before_its_priming,
exit_guard::a_device_registered_unprimed_forgets_the_primed_calls (fork test), primed_devices
(device cfgs); the two priming fork tests take the new signatures.

Verified (potluck jobs, on the branch at d36c330b67):
- lavapipe (m3-max-17994): clippy --cfg m2v_cpu_icd all targets and features clean; exit_guard
  and primed_devices 59/59 ("4 of 4 devices made again with no load; primings 1, at_devices 1").
- default cfg (17995): clippy clean; exit_guard 58/58.
- RTX 3090 release A/B, 2 runs x 8 makings: the runtime's own share of a re-made device (making
  minus vkCreateDevice) median 226 ms (140-459, busy node; 18001) -> 13.9 ms (13.2-15.6; 18000);
  making median 831 -> 561 ms; primings per re-made device 3 -> 0. The first device in a process
  still primes (own share about 293-336 ms with instance setup).
Not measured: the 5080 A/B; a lane whose validation layer reloads per instance still primes.
2026-11-11 17:09:35 -08:00
Anees Iqbal eea814d11a Devices: name the exit guard's identity apart from the properties' identity
The properties read after priming bind `identity` again (a DeviceIdentity), which the
registration took instead of the guard's Vec<u64> (E0308 at 6ce451f452, m3-max-17990).
2026-11-11 17:09:19 -08:00
Anees Iqbal 45182b7aeb Devices: prime only a device that registers the exit hook
What. A device's making asks the exit guard, before priming it, whether it will register the
hook (`exit_guard::before_priming`, now given the device's identity, answers
`Devices::admits`: the process's first device, the first after a load of a shared object, or
one of an identity new since). Only such a device is primed. A device made again on what stays
loaded, after a device of its identity registered, registers nothing and is no longer primed:
its calls are not the first, an earlier device's priming made each. The device's functions and
identity are made before the priming for the question; nothing else moves. A device that
registers unprimed after all (a load or another device between the question and its
registration) forgets the calls primed before, so each section's first call registers the hook
again. `ExitRegistrations` (hidden, for the lanes) counts the primings.

Why. Bug 487/676: on NVIDIA a device's making spent 120-160 ms of its own beside
vkCreateDevice, nearly all in priming's vkCreateIndirectCommandsLayoutEXT (112-144 ms on the
RTX 3090, NVIDIA 620.70.06, scratch timers on steelbrain/triage2-scratch 2edaaa5afa; m3-max-17899).
On that GPU every device after the first was made on what stayed loaded (the loads count stayed
at 67 over 8 makings and at_devices at 1, e6e5c1a34b, m3-max-17904), so each re-made device
paid priming for nothing. Priming exists only so that a device's registration of the hook comes
after the statics its calls make.

Tests: tests::exit_guard::whether_a_device_registers_is_answered_before_its_priming (the
answer agrees with the registration and notes nothing),
a_device_registered_unprimed_forgets_the_primed_calls (fork: 42), the two priming fork tests on
the new signatures, and tests::primed_devices (device cfgs): the first device primes, each made
again with no load neither primes nor registers.
2026-11-11 17:09:19 -08:00
Anees Iqbal 7a22646091 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:04:38 -08:00
Anees Iqbal 402cb93322 RUNTIME_VERSION 2068: a driver cache record names its pass without the attachments' colour formats
On the Iris Xe (ANV 26.2.6) a cold guest login made three pipelines that differ only in their
colour attachments' formats, and each compiled its own fragment shader for 4.2-4.4 s inside
vkCreateGraphicsPipelines: the shader parts' driver cache records were named by the full pass,
formats included, so no creation found another's compile.

Now the two shader parts' VkPipelineCache records name the pass with PassShape::without_formats
(attachment presence, samples, fetch inputs, unread inputs, storage attachments, view mask and
locations kept). The library objects keep their full names: they link against VkRenderPasses
that must be compatible, so only the driver's cache record is shared. A format the translation
reads still names its own record through the stage's module words. Record-naming version 2 -> 3
(shader_cache/driver.rs). With METAL2VULKAN_LOG_PIPELINES on, each library's split says whether
its record loaded, missed or shared an earlier making's cache, and whether the driver found it
there. Docs: docs/API.md, env_vars.rs.

Tests: unit test record_pass_formats; device test
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records (RGBA8Unorm, then
BGRA8Unorm, then RGBA16Float: each later creation takes the first's caches and makes one fragment
shader library; RGBA16Float under NearestEven rounding, which the translation reads, keeps its
own record); creation_log text test.

Verified (potluck jobs, on the branch at 538c7e8eb4):
- Iris Xe ANV 26.2.6 (m3-max-17968): 2 of 2 makings took an earlier making's cache, 1 fragment
  shader library made, 2 driver hits and 0 misses, for BGRA8 and RGBA16F. lavapipe (17953): 2 of
  2 shared, 1 library each. M3 MoltenVK 1.4.2 (17956): 1 of 1 shared, 1 hit each.
- The 26.7.2 module, cold, Mesa cache off, harness (17871) on the Iris: own cache per format 3.65,
  3.53, 3.26 s; one shared cache 3.46 s, then 0.0 and 0.0 ms (APPLICATION_PIPELINE_CACHE_HIT).
- fmt, clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc -D warnings (17965).
Expected, not yet run: the device test on the 3090 and the 780M, and the consumer's cold boots.
2026-11-11 17:03:37 -08:00
Anees Iqbal f1c100d87c Tests: the rounding creation's pre-rasterization library is the earlier creation's own
creations_over_colour_formats_take_the_first_s_records expected the
RGBA16Float creation under NearestEven rounding to hand one making the
first's cache where the device links (its pre-rasterization part). That
creation makes no pre-rasterization library at all: the RGBA16Float
creation before it made that library against the same pass, under the
same library name, and the runtime reuses it. Its one making is the
fragment shader library of the rounding module, under a record of its
own, so no making takes an earlier making's cache on any device.

Verified on lavapipe before this fix (job m3-max-17929, um870): the
first two creations printed 2 of 2 makings handed the first's cache and
1 fragment shader library made each; the third printed 0 makings shared
and 1 miss, which the old expectation (1) failed. The test now expects
0, one fragment shader library made where the device links, and one
answer per making from a reporting driver.
2026-11-11 17:03:24 -08:00
Anees Iqbal 26e6fa6fc0 Tests: the format-sharing test's doc names the module's size in round words
The test's doc gave the measured module's exact word count; round it.
Also, to correct the previous commit's body: the third creation there is
an RGBA16Float pass under NearestEven rounding, a format the translation
reads (the fragment function rounds the half channel itself), so its
fragment part keeps a record of its own and only its pre-rasterization
part, where the device links, takes the first's. Doc only.
2026-11-11 17:03:23 -08:00
Anees Iqbal 5a1e043784 A driver cache record names its pass without the attachments' formats
A render making's record of the driver's data, and the libraries of its
pre-rasterization and fragment shader parts, were named by the pass
shape whole, formats included. A program that makes one state against
passes that differ only in a colour attachment's format (RGBA8Unorm,
RGBA16Float, BGRA8Unorm) so got one VkPipelineCache per format, and the
driver compiled the same fragment module once in each: on the Iris Xe
(ANV, Mesa 26.2.6) 3.3 to 3.7 s per compile for one large module, three
times over at a cold start.

No stage's conversion reads an attachment's format through the pass: a
format the translation reads is in the stage's own words and constants,
which name the part's record too. So a part's record now names the pass
by PassShape::without_formats (which attachments it has, its samples,
fetch inputs, unread inputs, storage attachments, view mask and
locations), and the depth bias is left out of it as before. The library
names the runtime keys its own library objects by keep the formats (the
libraries are made against VkRenderPasses, which must be compatible);
only the driver cache record is shared. A driver that does key a stage
by format keys that entry apart in the one cache: a compile, never a
wrong pipeline.

The record-naming version (shader_cache/driver.rs VERSION) goes to 3.
METAL2VULKAN_LOG_PIPELINES now says, per library, whether its record
was loaded, missed or its cache shared with an earlier making, and
whether the driver found it in that cache or compiled it (from
VK_EXT_pipeline_creation_feedback).

Measured before the change (a harness making the module's fragment
library against three passes on the Iris Xe, MESA_SHADER_CACHE_DISABLE):
a cache per format, 3.5 s, 3.7 s, 3.3 s; one shared cache, 3.5 s then
0.0 ms and 0.0 ms, the second and third APPLICATION_PIPELINE_CACHE_HIT.

Tests: record_pass_formats (a pass's record name drops formats, keeps
presence, samples, fetch inputs and view mask);
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records
(two makings over BGRA8Unorm and RGBA16Float share the first's record,
caches_shared grows by the makings, one fragment library compiled,
while a constant that changes the module keeps its own record);
creation_log's text test.
2026-11-11 17:03:23 -08:00
Anees Iqbal 1aa0a93702 Re-bless the authored compile census at 892e4b230b
Its product fingerprint follows the runtime-sources pin at 892e4b230b (dv-m3).
2026-11-11 16:45:51 -08:00
Anees Iqbal db66fb2672 Re-bless the golden tables at 892e4b230b
What moved since ebc5a68a67's bless. Blessed on the M3 (dv-m3).
2026-11-11 16:45:51 -08:00
Anees Iqbal dbf27c4a5a 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 16:41:21 -08:00
Anees Iqbal 0c3c605d9e RUNTIME_VERSION 2067: a device check's allocations and frees step aside for the device's submissions
The queue-sharing isolation tests failed on the RTX 3090 (620.70.06) at development and at the
2059 fix alike (m3-max-17458): the unshared compositor stalled 2-47 times over 10 ms, and the
shared case's p99 reached 5.4-7.6 ms. The cause is the device's submission-check thread: a test
device starts with a fresh shader cache and no check record, so the checks run in the measured
window, and the import tax frees its 32 host-pointer imports back to back. On that driver each
vkFreeMemory of a host-pointer import holds every other thread's vkQueueSubmit for 0.5-0.9 ms, so
the scheduler's one thread got one submission in between two frees and the compositor's batches
backed up for the burst (commit to submission 21-23 ms). A raw Vulkan probe shows the driver's
behaviour alone: 32 imports of 512 KiB made and freed in turn beside 4,800 fills a second move the
fills' p50 from 0.12 ms to 3.9-8.3 ms, and from 0.74 to 11.4-12.7 ms beside 30 ms work on another
queue. Ruled out: timestamps, calibration, semaphore waits, submit infos, queue count, pageable
memory, device addresses, recording, kept barriers, one submitting thread, a fence-waited checker.

Now a check's own allocation or free, at the two doors that already count it (allocations::Busy),
owes its length to the thread's next step: step_aside waits that long first, then steps aside as
before, so the device's submissions go between the check's calls and the check holds the driver
at most half the time its calls run. A call of microseconds owes microseconds; a step a waiter
tells to go on pays nothing. Docs: step_aside.rs, submit_check.rs, the steps_aside doc comment.

Also measured: the unshared compositor's channel waits for NVIDIA's time-slicing only 0.62 ms at
p50 and 1.24 ms at p99 on the 3090 (0.64/1.27 on the 2080), never a stall; the driver documents no
time slice or global priority lever, and none is needed.

Tests: two unit tests in step_aside.

Verified (potluck jobs): lint three ways and rustdoc (17831); lavapipe step_aside, submit_check,
queue_share_device, in_place_check and host_ram 127/127 (17880); 3090 A/B of the three tests,
not exclusive, gem10 load 19-21 (17858): round 1 development 1/3, fix 3/3 (p99 about 2 ms, 0
stalls); rounds 2-3 starved by host load for both builds. The exclusive 3090 A/B (17886) and the
2080 A/B (17859) follow the merge.
2026-11-11 16:40:22 -08:00
Anees Iqbal bc2bda79d7 A check's own allocations and frees are owed to its next step
On an RTX 3090 (NVIDIA 620.70.06), a vkFreeMemory of a host-pointer import holds back every
other thread's vkQueueSubmit while it runs. The submission checks' import tax freed its 32
imports back to back, so the scheduler's one thread got a submission in only between two
frees. A device made without a check record (every test device: a fresh shader cache) ran
that beside the queue-sharing isolation tests, and the compositor's command buffers beside
long work waited up to 21 ms from commit to submission. Those were the three isolation
failures of the 3090's GPU-time leg.

Now a check's own allocation or free of memory, at the two doors (allocations::Busy), owes
its length to the thread's next step: step_aside waits that long first, then steps aside as
before. The device's other threads' submissions go between the check's calls, and the check's
allocations and frees hold the driver at most half the time they run. A call of microseconds
is owed microseconds. A step told to go on (a caller waits for the verdicts, or the check
stops) pays nothing. Counted among the checks' steps aside.

How it was found (3090, gem10; diagnosis on a scratch branch):
- Traced runtime runs: each compositor vkQueueSubmit returned only after the GPU ran the batch,
  in episodes. Traced with the check, an episode was exactly the import tax's frees: each
  0.5 to 0.7 ms, the scheduler's submit returning between two of them.
- With the checks settled before measuring: 0 stalls in 4 of 4 runs (p99 1.7 to 2.4 ms), against
  12 to 71 stalls over 10 ms with them running.
- A raw Vulkan probe: 32 imports of 512 KiB made and freed in turn beside 4,800 fills a second
  put the fills' latency at p50 3.9 to 8.3 ms alone (0.12 without it) and 11.4 to 12.7 ms beside
  30 ms work on another queue (0.74 without it). These did not block it: timestamps,
  calibration, waits in vkWaitSemaphores, two submit infos, 16 queues, pageable memory,
  device addresses, fresh recording, kept barrier command buffers, one submitting thread, or
  a fence-waited checker on the same queue.

Tests: step_aside's a_check_s_own_call_is_owed_to_its_next_step and
a_call_on_another_thread_is_owed_nothing.
2026-11-11 16:15:33 -08:00
Anees Iqbal bfdb61204b 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 15:47:18 -08:00
Anees Iqbal 9b915ecd68 Tests: this_thread's test lives in src/tests, where the runtime's thread checks leave tests
The unit test of this_thread.rs started its second thread with std::thread::spawn inside the
module's own #[cfg(test)] block, under src/. exit_guard's
threads_and_the_program_s_code_go_through_the_guard reads every runtime source under src/ but
src/tests/ for thread starts outside exit_guard.rs, so it failed on that test's spawn (reported
by the halfnative worker's translator-suite run on msi at b8bb54e69f).

The test moves, unchanged, to src/tests/this_thread.rs, beside the runtime's other tests, which
that check leaves out by their directory; this_thread.rs keeps only id and runs. No allowlist.

Verified: the fail-first run at f3c9f748ce and the run at this commit follow (runtime crate,
threads_and_the_program_s_code_go_through_the_guard and a_thread_tells_itself_from_another).
2026-11-11 15:46:08 -08:00
Anees Iqbal 9c766f63d0 Docs: an RTX 3090 saturates logicOp's out-of-range integer outputs too
The logic-operation lane on an RTX 3090 (driver 620.70.06, job
m3-max-17707, at bdb59d55de): every out-of-range integer channel
(RGBA8Uint, RGBA8Sint, R16Uint, RG16Sint under xor and and) stores Metal's
saturated code through Vulkan's logicOp and through the fragment
function's operation, as on lavapipe. The FAST-PATHS known-gap row and
the private_state docs name both measured devices. No note: the spec
leaves the value undefined, and neither device differs from Metal.
2026-11-11 15:44:59 -08:00
Anees Iqbal 9714fc9cf0 Probe: read the sparse buffer back, and a plain-buffer control over one more imported chunk 2026-11-11 15:44:59 -08:00
Anees Iqbal aaf18907a5 Probe: print Vulkan flags as raw words (ash's Debug is feature-gated) 2026-11-11 15:44:59 -08:00
Anees Iqbal 0b94ecbf17 Probe: a sparse buffer over memory imported from host pointers
A measurement for the consumer, no product path: can a SPARSE_BINDING
buffer be bound to memory imported with VK_EXT_external_memory_host?
sparse_host_pages.rs (runtime src/tests, Linux, the GPU safety cfgs)
prints, on a VkDevice of its own made beside the runtime's device:

- sparseBinding, sparseResidencyBuffer and sparseResidencyAliased, the
  sparse properties, sparseAddressSpaceSize and
  minImportedHostPointerAlignment;
- for SPARSE_BINDING (and with SPARSE_RESIDENCY where offered) buffers of
  transfer, storage, uniform, vertex and all four uses:
  vkGetPhysicalDeviceExternalBufferProperties for the host-allocation
  handle type, and memoryTypeBits, alignment and size without and with
  that handle type;
- vkGetMemoryHostPointerPropertiesEXT's types for a page of a memfd mapped
  shared and of anonymous memory, and the intersection;
- where the device imports into such a buffer and the intersection is not
  empty: four separate memfd chunks (64 KiB or more, multiples of the
  buffer's alignment, of minImportedHostPointerAlignment and of the page)
  imported, bound in reverse order with vkQueueBindSparse, a GPU copy in
  read back through each chunk's own mapping, and host writes through
  the mappings copied out.

Every call follows the spec's valid usage (the buffer names the handle
type, VUID-VkSparseMemoryBind-memory-02731 and
VUID-VkBufferCreateInfo-pNext-00920; the type is in both answers,
VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744; offsets and sizes per
VUID-VkSparseMemoryBind-resourceOffset-09491 and
VUID-VkMemoryAllocateInfo-allocationSize-01745). It asserts nothing a
device may answer either way: refusals, a failed bind and the round
trip's outcome are printed (SPARSE-HOST lines).
2026-11-11 15:44:59 -08:00
Anees Iqbal 15c50356d9 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 15:38:36 -08:00
Anees Iqbal f3c9f748ce RUNTIME_VERSION 2066, SEMANTICS_VERSION 2038: half + - * on the device's 16-bit arithmetic take the AIR's own contraction
Half arithmetic followed float's rule but for contraction: every half + - * was lowered
NoContraction, and a half fma-shaped pair as Fma(a, b, -0), whatever the AIR's fast-math flags
said. Now a half + - * whose flags allow contraction is left contractable, as float's is, so the
device may fuse it (rule 1: the device's native arithmetic).

Notes: on the float-controls basis (Iris, 780M) half's notes are float's. On the measured basis
(MoltenVK) a contractable half + - * records FastMathRewrites whatever its neighbours: Metal's fast
compile folds an undecorated 16-bit op's conversions away, so even a lone op can answer the
unrounded float result (M3, fast_half_chain: (1 + 2^-11) + 2^-11 with every sum fast stores
1 + 2^-11 on all 4096 threads, neither Metal's rounded 1 nor the held 1 + 2^-10). The exported
float_binop_notes predicts the same.

Holding half in 16 bits instead of widening was measured and not taken: on top of the
contraction it is no faster on the 780M and gives the gain back on the Iris.

Fixture hnq_half_layer_composite (a half layer-compositing fragment function: 16-tap filters, a
colour-op switch, a 40-case blend, its taps unrolled and live across two passes) and lane tests.

Verified (potluck jobs, on the branch):
- performance, hnq proxy, median ms per draw, two states x 16 draws twice interleaved: Iris base
  25.49/25.15, contraction 23.52/23.16 (-7.5%; SIMD8 instructions 7652 -> 7091, 0 spills); 780M
  base 7.39/7.19, contraction 6.71/6.52 (-9%).
- half lanes 24/24 on the M3 (c66c73c1ce), Iris, 780M and lavapipe (cce43e469c).
- fresh translation census on the M3, base 5cad27af52 against the tip, 17,057 rows over
  moltenvk-m3, intel-irisxe-rplp-anv and amd-780m-radv: 0 rows changed outcome, 0 defects; 181 s
  base, 204 s tip (the 8 slowest rows re-timed alternately: base 434/432/448 ms, tip 440/436/428
  ms: host contention); slowest row 429-446 ms; peak worker resident memory about 216 MiB. Proxy
  translation 0.04-0.17 s and about 46 MiB, base and tip alike.
- translator suite: 5464 passed; the golden tables and the air_input printouts are re-blessed on
  development at the batch. Clippy three ways and rustdoc clean.
2026-11-11 15:37:37 -08:00
Anees Iqbal c68397654d Tests: a fast half chain MoltenVK folds may skip a rounding; the half reads still require the fact
The M3 lanes at the contraction change failed twice:

- kept_apart::half_chains_without_float16_round_at_their_exits: fast_half_chain ((1 + 2^-11) +
  2^-11, every sum fast) stored 0x3F801000 (1 + 2^-11) on every thread, under both chain
  policies: neither the rounded sum (1) nor the held one (1 + 2^-10). Its 16-bit sums are now left
  to Metal's fast compile, which folded one's conversions away. The stage records
  PrecisionNote::FastMathRewrites, whose bound is the roundings skipped; the test now takes a sum
  between the two where the stage records it, and prints how many.
- driver_deviations::half_arithmetic_answers_as_metal: the previous commit expected the fast-math
  case to stop requiring VkProperty::MetalHalfArithmetic, but its half reads take the device's
  widening and still require it (the M3 compile says so). The requirement is again the profile's
  deviation for every case; the FastMathRewrites check for the fast-math case stays.

Checked by the M3 lanes run at this commit; results go with the branch's hand-off.
2026-11-11 15:37:34 -08:00
Anees Iqbal 5ade26e7c7 float_binop_notes: a half + - * MoltenVK folds records FastMathRewrites, as a compile does
On a profile that takes DriverDeviation::MetalHalfArithmetic, a half fadd, fsub or fmul whose
flags allow contraction is now the device's 16-bit instruction left undecorated, and Metal's fast
compile folds its conversions away (the deviation's own measurement: billions of operand pairs
differ from the kept instruction). The lowering records PrecisionNote::FastMathRewrites for it, but
the exported float_binop_notes, which validation reads to tell which operations a compile answers
as a near-equivalent, did not predict it, so engine_float_call_notes'
exported_float_notes_are_the_ones_a_compile_records failed (fadd_f16_flagged on moltenvk-m3:
compile {FastMathRewrites}, exported {}). The exported notes now record it under the same
condition the lowering does (f16_arithmetic on the measured basis and contraction allowed). Float's
own contraction notes are unchanged; this note is for the fold, which a lone operation also takes.

Checked by the translator suite run at this commit; its result goes with the branch's hand-off.
2026-11-11 15:37:34 -08:00
Anees Iqbal 384aa6af43 Tests: the device's 16-bit half arithmetic is required kept apart only where the AIR forbids contraction
half_arithmetic_answers_as_metal held every half arithmetic case to require
VkProperty::MetalHalfArithmetic where the profile takes DriverDeviation::MetalHalfArithmetic. Since
half + - * take the AIR's own contraction, the fast-math case's kernel (fadd fast / fmul fast half)
emits them undecorated and records PrecisionNote::FastMathRewrites instead, so it no longer requires
the property. The case table now says which kernels carry fast math's flags; the test requires the
property where the profile takes the deviation and the AIR forbids contraction, and checks the note
where it allows it. Every word is still held to Metal's on that basis.

Checked by the half lanes run at this commit on the M3, the Iris, the 780M and lavapipe; their
results go with the branch's hand-off, not here.
2026-11-11 15:37:34 -08:00
Anees Iqbal e393b10cb7 Half + - * on the device's 16-bit arithmetic take the AIR's own contraction
A half fadd, fsub or fmul on the device's 16-bit arithmetic (ArithStrategy::F16:
MoltenVK, measured, and the float-controls profiles) was always kept apart: a
sum or difference decorated NoContraction and a product as Fma(a, b, -0.0)
decorated NoContraction, whatever the AIR's flags allowed. That holds Metal's
exact half bits at the cost of every fusion the flags allow (AGENTS.md rule 1:
the device's native arithmetic). It now decides as float does (contraction()):
an operation whose flags carry both contract and reassoc is undecorated, its
product a plain OpFMul, and the device's compiler groups and fuses it; any
other keeps today's form.

Notes mirror float's: note_rewrites already records FastMathRewrites where a
neighbour can be rewritten. On MoltenVK, Metal's fast compile folds an
undecorated 16-bit operation's conversions away and answers the float result
unrounded (the MetalHalfArithmetic measurement), so there a fast operation
records FastMathRewrites, whose doc (and docs/API.md's catalogue entry and the
FAST-PATHS device-gap row) now says so, and requires no MetalHalfArithmetic,
which the kept form still requires.

On an owned proxy (hnq_half_layer_composite) on the Iris Xe, the step-1
prototype of this form cut the SIMD8 cycle estimate from 58584 to 33092.

Tests: f16_binary's rounded-result and one-instruction tests under both
contractions; half_arithmetic_on_the_device_takes_the_airs_contraction
compiles fast, contract-only and flagless half + - * on every profile that
computes them in 16 bits and checks the instruction, its decoration, the note,
the requirement and the interpreted answers.
2026-11-11 15:37:33 -08:00
Anees Iqbal 2f6c6195ff Fixture hnq_half_layer_composite: an edge-aware 16-tap filter, its taps unrolled and live across two passes
The first proxy compiled SIMD8 and SIMD16 on the Iris Xe with no spills (max
72 live registers), unlike the shader it stands for. Each source is now the
taps' mean, then each tap weighed by its buffer weight and its distance from
the mean, normalized: all 16 half4 taps stay live across the passes, the
register pressure a 16-bit hold would halve. Companions regenerated.

Parked again before translating it; next: translate (Linux build job), retype
(scratch retype16.py), one Iris job of iris/a16/a16n.
2026-11-11 15:37:33 -08:00
Anees Iqbal 5107e5d8fd Fixture: a half layer-compositing fragment function (16-tap filters, a colour-op switch, a 40-case blend)
Owned MSL of the shape of a fixed-function compositing shader that holds its
colours in half: two layers of three 16-tap half filters, a 17-case colour-op
interpreter run twice a layer, a half tint and a 40-case blend switch. A
measurement proxy for how half values are held on a device with shaderFloat16.
Companions from scripts/regen-air-fixtures.
2026-11-11 15:37:33 -08:00
Anees Iqbal 842fd73b71 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 15:33:47 -08:00
Anees Iqbal ef158b652c RUNTIME_VERSION 2065: a copied host buffer keeps a per-block base, in VRAM where a staging queue reads it back
A copied host buffer (pages the driver can't import, so the GPU uses a copy in its own memory) kept
a whole host snapshot of the copy, 256 MiB of host RAM per 256 MiB buffer, and compared and merged
through it on every commit and completion: 14.4-15.8 ms each way at rest on gem10 for 256 MiB,
270-289 ms back when the GPU rewrote every float, 403-439 ms on the 5080's host.

Now:
- the base is tagged per 1 KiB block; a buffer the GPU only reads keeps none. A written buffer's
  base lies in device memory on a device with a staging queue (5080, XTX), with 4 MiB of host tags
  plus 1 KiB of host block per block both sides changed; elsewhere (2080, 3090, unified memory) on
  the host, 260 MiB.
- the merge is exact and masked per 16 bytes (gpu = copy != agreed, cpu = pages == agreed): a
  full store only where every byte qualifies, else the masked bytes (VMOVDQU8 with AVX-512BW),
  on 4 threads.
- comparisons run in two passes. Host reads of a VRAM base run at the uncached BAR's speed (14-16
  us a 1 KiB block awake, 170-206 us after 3 s idle on the 5080: a whole-written 256 MiB merge
  took 175.6 s). So the first pass defers the blocks it would read from the device base; at 32 or
  more (READ_BACK_BLOCKS, measured on the 5080 and XTX: copied_read_back_bench) one copy on the
  staging queue reads them into a host-visible buffer, waited for; below that, or if the copy fails,
  the host reads them, exactly. The staging queue waits only for work the host saw complete, so the
  completion thread never waits on the program's queue.
Counters and gauges: copied_base_blocks_read_back, copied_base_host_bytes,
copied_base_device_bytes, copied_base_host_blocks. Docs: FAST-PATHS (base, cost and kernel
bullets with the bench numbers), HOWTO, API.md, copied.rs.

Test a_whole_written_device_base_is_read_back_by_the_gpu: a 256 MiB base both sides wrote whole,
merged after 3 s idle, every block read back and the merge exact, bound 2 s (the 5080 woke from
power-down in 0.94-1.28 s in 3 of 12 bench readbacks): 5080 187/213/267 ms, XTX 176/292 ms.

Verified (potluck jobs, on the branch): device tests 81/81 on the 5080, XTX, 2080 and lavapipe at
9cf5a01c34; unit tests 33/33 and runtime rustdoc at f768cd86d5; api_signatures at a3707a71a7;
clippy three ways at 974d19bb5e. tests::fast_paths runs after the merge.
2026-11-11 15:32:40 -08:00