Commit Graph
6209 Commits
Author SHA1 Message Date
Anees Iqbal d3389d7cbb 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-16 10:04:35 -08:00
Anees Iqbal 49b25c189c RUNTIME 2464: Parked dma-buf images released at the next pass where held imports tax submissions; each whole guest RAM import said with its time
A parked image (an in-place image over a no-copy buffer's dma-buf pages, kept for the next
texture over the same pages) is one more imported memory on every kernel submission's list on
RADV and ANV on i915. On the Radeon 780M that costs about 0.46 us a submission (m3-max-36970:
167 against 6 listed memories, 86.8 against 13.7 us a submission), 0.53 ms a second at the 1,150
submissions a second of a guest's desktop. Held 2 s (released by the first pass at least 2 s after
the park, passes every 0.5 s), an untaken park cost 1.06 to 1.32 ms of vkQueueSubmit time, while a
take saves its texture's making: on the 780M 0.13 ms (7.9 MiB) to 2.6 ms (84 MiB) over 2 MiB
pages, 0.73 to 24.3 ms over 4 KiB pages (texture_shadow_bench, m3-max-37048, medians). In a
guest's desktop walk on the 780M, 443 of 2,098 parks were taken; at 2 s the parks cost about 2.0
to 2.5 s of submit time, which pays only where a take saves 4.5 ms or more on average.

Where Device::pointer_imports_tax_submissions holds, the residency thread now releases a parked
image at its first pass after the park (held 0 to 0.5 s, 0.25 s on average); elsewhere, where a
held import costs no submission, the 2 s window stays. The cap of 64 parked images stays.

Expected, not measured: takes come soon after their park (a guest wrapping the same surface again
a frame or two later), so most still hit; an untaken park then costs about 0.13 ms instead of
1.2 ms, and a desktop walk at the cap holds about 10 parked images instead of 64. The proof is a
guest's desktop walk on the 780M before and after: dma_buf_images_taken against
dma_buf_images_missed, dma_buf_images_parked_released, and batch_submit_nanos per submission.

Tests: dma_buf_parked_images now forces the import tax: with Fails, a pass right after the park
keeps the image; with Holds, the next pass releases it (fails without the change: the 2 s window
keeps it). texture_shadow_bench's in-place arm parks its image in a warm-up within its own cycle,
outside its times and counts, so its texture still takes one: the other arms between two of its
cycles run longer than a pass.

Documented in host_residency.rs, dma_buf/parked.rs and docs/HOWTO.md. No new Degradation kind; not
an accuracy choice, so no FAST-PATHS row.

Also folded:

Guest RAM: say each whole import, with its time; bench it at 2, 4 and 8 GiB and across a recovery

A device that imports a resident guest RAM whole as its use begins now says so once on its
message sink (id name metal2vulkan-host-ram, Info): the bytes and chunks imported, those left to
the copies, the imports' time and the first listing's (the submission of no work it waits for).
A consumer then sees the one-time wait at setup in its log, and at each recovery of the device,
whose carry makes the use again on the new device before it serves, so the new device imports the
RAM whole in turn on the recovering thread.

Tests (host_ram_whole.rs): the resident RAM says the line once, naming its bytes and its one
chunk; the RAM with a hole says nothing; a recovery imports the resident RAM whole again before
recover_for_test returns, and says so again. The ignored whole_ram_bench runs 2, 4 and 8 GiB RAMs,
each on a device of its own, each with a hole and then resident, the resident one recovered,
printing the device's lines.

Documented in host_ram.rs (the module docs and use_host_ram) and docs/HOWTO.md.

Guest RAM recovery test: read the chunks of the generation that serves

a_recovery_imports_a_resident_ram_whole_again_before_the_new_device_serves read the RAMs through
the root handle, whose own generation the recovery lost, so it found none and passed without
asserting (m3-max-37099: "the new device does not import the RAM whole ([])", while the same run
counted one chunk imported ahead in the recovery and heard the second line). It reads them through
Device::current now, the generation that serves.

The docs give the 780M's measured whole-import times at 2, 4 and 8 GiB (m3-max-37099): the
imports 0.05, 0.08 and 0.1 s, the first listing 0.43, 0.63 and 0.51 s.

And: whole_ram_bench times the first commit after the chunks' imports apart (dbc707372d); one
doc line rewrapped (0d19c052f8).

Verified: at ae6ae7876a clippy x3 (m3-max-37116 CLIPPY_GPU=0; m3-max-37117 CLIPPY=0, CLIPPY_CPU=0,
DOC=0, 20 host_ram unit tests, lavapipe host_ram_whole/dma_buf_parked_images/host_residency 13
passed: the parked check kept with the tax forced Fails, released with Holds). PHOENIX
(m3-max-37099, at c894bbdb13): whole import 2/4/8 GiB: imports 56/77/102 ms, first listing
441/633/511 ms, use_host_ram 532/759/690 ms; recoveries 507/768/716 ms; the lazy first commit
today 429/639/510 ms.
2026-11-16 10:03:48 -08:00
Anees Iqbal 3f9cf43310 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-16 09:54:16 -08:00
Anees Iqbal 2921fb24da draw_costs: one thread run's answer is a named type
Clippy's type_complexity refused thread_run's return type and its callers' Vec of them (job
m3-max-37074, all three configurations). A ThreadRun alias names the tuple.

Verified: in the landing's check job.
2026-11-16 09:50:55 -08:00
Anees Iqbal df87983bb7 RUNTIME 2463: Render draws: the restarted list and the error and notice makers out of line, cold
What: draw_resident's restarted-list arm (the index rewrite and gather requests, 205 source lines)
is its own #[cold] #[inline(never)] method, restarted_list; Device::degrade, degrade_copied_pages,
degrade_host_step, degrade_where and tell, and error.rs's vulkan, invalid, nil and internal are
#[cold]. Same commands, barriers and answers; only where the code lies changes (draw_resident 130.7
-> 127.4 KB of machine code). Also folded: draw_costs gains a guest shape of a few render encoders
with set_bytes and each thread's CPU a draw (17126bfe04), the encoding thread's own CPU apart from
unnamed threads (afa24f4074), and --calls counting each call's cycles and cache misses (7249f6930b).

Why: on a Zen 4 host a one-draw render pass ran at IPC 0.79 against 1.7 inside a long pass, the
same on RADV and lavapipe (gem10, m3-max-36911/36975). The misses are instruction fetches: per pass
about 8.3k L2 instruction misses against 1.2k data, over 806 distinct 4 KiB code pages (more than
the L2 iTLB's 512), no function above 7.5% of them (m3-max-37017, -37041). This change is
measured neutral (m3-max-37061, lavapipe, release: pass1 instructions 112,257 -> 112,123, L2
misses 10,590 -> 10,577; cycles within the node's noise) and kept as correct and neutral; the
lever left is the layout of the path's code across pages, a build setting of the program.

Verified: see the landing's check jobs.
2026-11-16 09:43:35 -08:00
Anees Iqbal be905fd899 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-16 09:33:15 -08:00
Anees Iqbal 0da1b0a342 RUNTIME 2462: Guest RAM: a resident, kept RAM takes chunks past 512 MiB, all imported as its use begins
On a device whose every held import costs each kernel submission (RADV, ANV on i915), a listed
guest RAM's chunks stopped at LONGEST_LISTED_CHUNK (512 MiB), our own constant: an 8 GiB guest
listed up to 16 chunk imports in every submission (the consumer's Iris Xe desktop: 15 live, about
4.7 ms/s at 0.35 us each and 1114 submissions/s). The cap bounds memory alone: a chunk's import
pins every page of it, and udmabuf allocates the pages of the guest's memfd that the guest never
touched. A RAM the VMM preallocated has every page allocated already, so there the cap bounds
nothing.

ram_plan now asks listed_chunks_of: where the cap would cut a range into more chunks than the
source's and the device's limits do, the chunks are kept (releases_idle_chunks false), and every
page of the RAM is resident as the use begins (every_page_resident: mincore over the ranges, a
chunk at a time, stopping at the first page missing), the chunks run to those limits (4032 MiB on
RADV and on ANV, whose maxStorageBufferRange is 4 GiB less one byte: an 8 GiB RAM in 3 chunks) and
the plan is whole. A whole plan's chunks are all imported on the calling thread before
Device::use_host_ram returns (Device::import_whole, counted as chunks imported ahead), then one
internal submission of no work is made and waited for: the first kernel submission that lists a
chunk just imported waits while the kernel writes its page tables, and every other submission of
the device waits with it (the VM's page-table lock), so that wait falls in the use's start, before
the guest's work, never inside a later submission. Vulkan used: the chunk import as before
(vkAllocateMemory with VkImportMemoryFdInfoKHR) and vkQueueSubmit with a fence, waited for. A RAM
with a hole, or one too long to keep, keeps the cap and its lazy imports as before.

listed_chunk_bytes now gives the limits' length alone; the cap moved into listed_chunks_of. The
module docs, use_host_ram's, Plan's, the imported-ahead count's, HOWTO section 6 and the
FAST-PATHS "Idle dma-buf imports are released" row say so.

Tests: listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib (the limits' length);
a_resident_kept_ram_takes_chunks_past_the_cap_imported_whole (the rule, residency asked only where
the cap cuts the RAM; fails without the change, which answered the cap); and
a_ram_is_resident_once_every_page_of_its_file_is (mincore, a memfd with a hole then written). The
device tests tests::host_ram_whole (a 640 MiB resident RAM: one chunk imported as the use began;
one with a hole: 512 + 128 MiB, none imported) and the ignored whole_ram_bench (a consumer's
8 GiB RAM in 16 chunks of 512 MiB each imported against 3 imported whole: the use's time and a
submission's vkQueueSubmit time).

Also folded: the probe tests::listed_memories with the test-only census Memory::blocks_by_kind
(7120ba7212), and the unit tests' clippy fix (9efafb7742).

Verified: clippy x3 at 9efafb7742 (m3-max-37010 CLIPPY_GPU=0, m3-max-37011 CLIPPY=0 + 20 host_ram
unit tests, m3-max-37012 CLIPPY_CPU=0); rustdoc m3-max-36994 DOC=0; lavapipe host_ram 120 passed
(m3-max-36995). PHOENIX (m3-max-37009): a touched 640 MiB memfd took one 640 MiB chunk imported
ahead (use 126.2 ms); with a one-page hole [512, 128] MiB, none ahead. 8 GiB bench: 16 chunks
listed -> 3, vkQueueSubmit 11.6 us a submission resident against 971.7 us averaged over 300 with
the lazy chunks (first-listing stall included); use_host_ram 459.7 ms (89.0 ms imports).
2026-11-16 09:32:09 -08:00
Anees Iqbal 8167cc60de commit_and_submit: the order test drains its queue every 50th commit, as the checked one does
What: submission_handlers_keep_commit_order_across_commit_and_commit_and_submit now makes
every 50th commit a commit_and_submit that first waits for the commit before it to complete,
as checked_command_buffers_keep_commit_order_across_commit_and_commit_and_submit does.

Why: the test asserts some submission handlers ran on a committing thread. Each commit()
wakes the scheduler's thread, whose pass is often still under way at the other thread's next
commit_and_submit, which then makes no pass; and on a driver whose batches group, a committing
thread submits only where its VkQueue runs at most one earlier submission not seen complete,
which the two threads' backlog may never leave it. On the Radeon 780M (RADV) inside the touched
suites' run it failed: 0 of 1000 handlers on a committing thread, 1 pass at commit, 0 batches
(m3-max-36934, debug, 76 tests in parallel). Run alone in release it passed 10 of 10 with
12-17 of 1000 on a committing thread, with RUNTIME 2461's fix and without it alike
(m3-max-36983): the margin, not that fix. After a drain the scheduler's thread is idle and the
VkQueue runs nothing, so the commit_and_submit makes its pass and submits alone.

Verified: in the jobs named in the lane's report.
2026-11-16 09:28:07 -08:00
Anees Iqbal 2ccc3e9c38 Re-bless the golden hashes and the authored compile census at 9ae7edf748
What: SEMANTICS 2137 (ba311896eb, the undo of 2136) changes the SPIR-V of the rows 2136 changed
back: golden_hashes.tsv 6 rows (bless job m3-max-36987, inventory=0 golden=0) and
authored-compile.tsv 26 rows (census job m3-max-36988, census-exit=0), the same row counts the
re-bless after 2136 moved (0b674f2c1e).

Verified: both jobs on the M3 at 9ae7edf748, exit 0.
2026-11-16 09:24:12 -08:00
Anees Iqbal 9ae7edf748 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-16 09:18:48 -08:00
Anees Iqbal ba311896eb SEMANTICS 2137: Iris: a loop-uniform read-only slot stays a storage view (undo SEMANTICS 2136)
What: reverts a552a55d1f. The Iris Xe RPL-P profile no longer declares
DriverWorkaround::UniformAddressStorageReadsSlow, and a kernel's read-only slot read in a loop at
a per-instance uniform offset is read through its storage view again, as on every other device.
Deleted with it: SlotPlan::uniform_loop_reads, the lowering's uniform-view arm, its plan and
engine tests, the profile test's entry, API.md's paragraph and the variant's signature row.
SEMANTICS moves forward to 2137 (not back to 2135): artifacts made under 2136 carry the uniform
views and must not be reused.

Why: the first guest walk with 2136 in (reims's Iris walk at 0b674f2c1e, m3-max-36915) ran every
kernel whose SPIR-V 2136 changed 3 to 10% slower than six walks without it: per encoder, at the
same maximum clock (act 1482-1496 MHz), one workload's two 15- and 33-tap weight-loop
convolutions took 5.84-5.89 ms against 5.47-5.63 ms in every other walk (1,805 encoders each),
and two kernels of another workload 4.05 against 3.70-3.78 ms and 10.75 against 10.42-10.61 ms;
about +0.5 s of GPU time against the walk before it. Kernels 2136 did not change ran as before
in the same windows. The probe behind 2136 (m3-max-36137, 36775: 0.80-0.91 of the storage form)
measured a synthetic shape; the guest's kernels answer the other way. One walk, so expected,
not verified: the next walk at a tip with this commit is the check (those encoders back at
about 5.5-5.6 ms).

Verified: cargo fmt; refusal surface regenerated (unchanged); api signatures --check. Build,
clippy and tests in the jobs named at landing.
2026-11-16 09:11:00 -08:00
Anees Iqbal 4f081c3490 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-16 09:07:16 -08:00
Anees Iqbal e6900ca020 Iris constant twin doc: state the per-encoder evidence, not one walk's totals
What: DriverWorkaround::PushReadsLengthenThreadPayload's doc (device/profile.rs) said a
storage twin of a kernel's uniform view took 145.8 to 150.2 s of GPU time over a walk of guest
compute workloads that took 137.4 s without it. It now gives the mean GPU time an encoder from
the runtime's encoder times in two walks without the twin against four with it. Comment only;
no code, version or answer changes.

Why: the 137.4 s total came from one walk (m3-max-35702, scratch 68e39640e9). The second walk
without twins, m3-max-36778 at c3d5b3e05e (8933378831 landed), took 146.0 s, inside the
twin walks' range. Its excess over the first sits in workload openings where the Iris
governor requested 300 to 1,200 MHz at 55 to 85% busy. Two walks of one sha (C0 and C02)
differ there as much. The totals do not separate the twin from the clock. Per encoder the
twin's effect is the same in both walks without it. 8933378831's message cites the totals
and one workload's 4.93 s as evidence. The message stays as it is, and this commit corrects
the record: that workload's difference was the first walk's opening, and the second walk
without twins took 6.42 s there. The twin's removal holds on the per-encoder figures below.

Evidence (mean ms an encoder; without twin: m3-max-35702, m3-max-36778; with: m3-max-35628
at bd3c1a8c37, walk T at 45d2a94af9, m3-max-36202 and walk C02 at 8d57656475; Mesa 26.2.6,
Iris Xe RPL-P; every window listed these rows, so the counts are whole):
- one workload's two heaviest convolution encoders, 200 each: 22.4 / 23.0 against 41.9,
  46.0, 28.1, 41.2; and 17.8 / 18.9 against 32.3, 32.8, 35.5, 32.5
- another workload's convolution encoder, 3,920: 6.27 / 6.30 against 6.79, 6.79, 6.77, 6.78
- a third workload's eight heaviest encoders, 439 to 480 each: six faster with the twin, e.g.
  3.67 / 3.74 against 2.86, 2.87, 2.84, 2.85, and 6.71 / 6.77 against 5.76, 5.75, 5.77, 5.77;
  one slower (4.82 / 4.92 against 5.56 to 5.63); one mixed
Read from each walk's qemu.log encoder-times lines (the walks' files on this Mac, read in
place).

Verified: cargo fmt --all only (comment change).
2026-11-16 09:06:19 -08:00
Anees Iqbal 24ccfe58db 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-16 08:49:42 -08:00
Anees Iqbal d6152c3247 RUNTIME 2461: Scheduler: a pass at commit asks whether a batch's host step is due, not whether it holds segments
What: scheduler::plain(), which decides what the pass of a committing thread
(commit_and_submit) and of a thread about to block may submit, left every batch that holds
segments to the scheduler's thread as a host step (LeftAtCommit::HostStep). It now asks the
command buffer whether a step is due (needs_host_step), as the thread's own look does
(holds_back, check_heads, gate_heads, place_of).

Why: BatchSync::segments is a gate alone: since a730cf1e96 it is also true for every batch one
of whose encoders kept its log for a rebind, which an encoder does whenever a command of it names
a no-copy buffer over host pages (replay.rs). A guest on a host of unified memory keeps all its
memory in place as such buffers, so on the Radeon 780M every one of the consumer's batches was
left to the scheduler's thread: its passes at commit ran (about 7.5k a window) and submitted
none, where on the RX 7900 XTX, whose guest resources lie in VRAM, they submitted about 4k a
window. An unshared head so left made the committing pass leave every other queue's batch on
its VkQueue too (first_for_the_thread). The thread's own pass submitted those batches with no
step, after a wake and a pass. A head whose step was recorded now goes from such a pass too.

How they meet the joined completions (RUNTIME 2459): the segments test comes first in plain(),
the group test after it. A batch of a command buffer marked to join the next, naming host
pages, now reaches that group test as any marked batch does: a committing thread sends it alone
where its VkQueue runs at most one earlier submission (goes_alone_at_commit) and leaves it to the
scheduler's thread to hold in the group otherwise; a waiting thread leaves it. No pass of a
thread other than the scheduler's runs while the group holds a batch, so none closes a group.

Docs: plain_ready's first condition; first_for_the_thread and unshared_hold.rs (Passes of other
threads) no longer name a recorded host step among what such a pass leaves.

Tests: commit_and_submit::a_command_buffer_naming_host_pages_is_submitted_at_its_commit, now in
a plain leg (a Private buffer) and a host-pages leg, 200 rounds each, printing the share at
commit and commit -> submission returned p50/p99; at the parent it failed on lavapipe with 40 of
40 left for a host step (m3-max-36852). queue_share_device's committing-pass test is renamed
a_committing_thread_s_pass_sends_an_unshared_head_with_its_step_recorded_first: under Exact the
committing pass now submits both command buffers, the unshared head first.

Verified: in the jobs named in the lane's report.

With it, the check and the bench legs (folded):

commit_and_submit: a command buffer naming host pages is submitted at its commit

What: a device test that fills a no-copy buffer over host pages with commit_and_submit, 40 rounds
on an idle device, and asserts every encoder kept its log for a rebind (replay_logs_kept, so each
batch holds segments), no host step was recorded, no pass at commit left a batch for a host step
(scheduler_at_commit_left_host_steps) and at least half the batches went at commit.

Why: scheduler::plain() leaves any batch that holds segments to the scheduler's thread as a host
step, though segments are a gate alone and an encoder that names a buffer over host pages holds
them with no step due. A guest's command buffers on a host of unified memory all name its memory
so, and the 780M's passes at commit submitted none of them.

Verified: run in the job named in the lane's report; it fails at this commit, before the fix.

completion_latency: a guest-shaped leg naming host pages, and why passes at commit left their command buffers

What: guest_shaped_completion_latency gains a HostPages leg: as Plain, each command buffer's blit
also fills 64 KiB of a no-copy buffer over host pages of its queue's own, as a guest's command
buffers name its memory over the guest's pages on a host of unified memory. Every leg now prints
a second line: the passes and batches at commit a frame, why those passes left their command
buffers to the scheduler's thread (WorkCounts::scheduler_at_commit_left_*), the host steps
recorded, the batches waiting threads submitted, the device's unified memory, its VkQueues, the
VkQueue each queue is on and which of them hold other queues' work back for the unshared
compositor.

Why: on the 780M a consumer's guest commits every command buffer with commit_and_submit, its
passes at commit run, and they submit nothing, where on the RX 7900 XTX they submit about 4k
batches a window. This leg puts the 780M guest's memory shape beside the plain one on the same
device, so one run on each GPU shows which condition leaves the batches.

Verified: built and run in the jobs named in the lane's report (a measurement, ignored by
default).

completion_latency: the guest-shaped bench times each commit call to its submission's return

What: each leg's at-commit line now opens with the time from each command buffer's
commit_and_submit call to the return of the driver's submission of its batch (p50, p99, max,
whichever thread submitted it), and counts the encoders' logs kept for a rebind a frame.

Why: the fix for batches over host pages left at commit is judged by that time on the 780M,
before and after, beside the share of batches submitted at commit.

Verified: in the build and bench jobs named in the lane's report.

Verified: m3-max-36888 (msi) at 3fbf10d3e1: clippy -p metal2vulkan-runtime --all-targets --all-features 0; lavapipe scheduler|commit_and_submit|queue_share_device|joined_completions|grouped_submissions 84/84. At the parent (m3-max-36852) 40 commit_and_submit fills of a no-copy buffer gave 0 batches at commit, all left for a host step with none recorded; at the fix 200/200 at commit (commit to submission returned p50 97.9 us, p99 104.1). The PHOENIX before/after, clippy --cfg m2v_gpu and m2v_cpu_icd and rustdoc run after the merge.
2026-11-16 08:48:53 -08:00
Anees Iqbal 3bc091f20a 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-16 08:41:11 -08:00
Anees Iqbal c9bad0206e Joined completions: the order test off its own queue; a private doc link to a test-only constant
Fix forward of RUNTIME 2459 (3de483d86f), and of the runtime private-doc pass red since RUNTIME 2437/2441.

Joined completions lane: the order test's first work on a queue of its own

an_unmarked_command_buffer_is_seen_complete_at_its_own_end failed once in
a release lavapipe run (debug runs passed): grouped 0 and 3 kernel
submissions where the device groups, so M went alone and U closed no
group. The first command buffer, which does the buffers' first work, filled
the 64 MiB buffer on the test's own queue. A queue's expected run is raised
at once by a longer command buffer (command_buffer/group.rs, "Bounded by its
expected run"), and a batch whose queue's expected run is past GROUP_RUN
(16 ms) goes alone (batches_alone_run_long). On a loaded host lavapipe's
64 MiB fill can take longer than that. The first work now runs on a second
command queue of the same device, so the test queue's expected run is the
warm-up's short fills'.

The lane's report also counts batches_alone_run_long, so a run that goes
alone for its expected run says so.

Verified: the release lavapipe run follows on this commit.

contexts: device_limit's doc names TEST_LIMIT without a link

TEST_LIMIT exists only in device test builds, so the private-items
Rustdoc pass (CI's "Private intra-doc links", ceiling 0 for the runtime)
found an unresolved link at contexts/mod.rs:102:
`cargo doc -p metal2vulkan-runtime --all-features --no-deps
--document-private-items` under RUSTDOCFLAGS=-Dwarnings exited 101 in msi job
m3-max-36795. The doc now names it as code.

Joined completions lane: the order test requires M not alone for its queue's expected run

The run-past-bound count the lane's report gained was read only by Debug,
which dead-code analysis ignores: clippy under --cfg m2v_gpu and
--cfg m2v_cpu_icd failed on 'field `long` is never read' (msi job
m3-max-36836; plain clippy, runtime-alone clippy, Rustdoc and the private-doc
pass of all six crates passed there). The order test now asserts it is 0
where the device groups: a batch alone for its queue's expected run is the
precondition the test's first work moved to a queue of its own, and the
assertion names it if it fails again.

Verified: m3-max-36867 at 9dd95c628d clippy plain, --cfg m2v_gpu, --cfg m2v_cpu_icd 0, joined_completions on lavapipe 5/5; m3-max-36836 at fa3b876cb5 rustdoc 0 and the private-doc pass 0 for all six crates; m3-max-36835 (release, lavapipe) joined_completions 5/5 with the counters moving (marked: 7 batches in 2 submissions; unmarked: 7 submissions; order test grouped 1, long 0).
2026-11-16 08:40:23 -08:00
Anees Iqbal 5dcb87e2e2 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-16 08:38:37 -08:00
Anees Iqbal 8bed9e05e4 RUNTIME 2460: A completed command buffer lets go of its kept footprints and its parts' sparse updates
Footprints: a completed command buffer lets go of its batches' kept footprints

A batch's kept footprint (CommandBufferShared::footprints) holds a probe of
each of its segments (SegmentProbe), and each probe holds a clone of the
segment's work (Deferred) and of a Rerecord step input. The command buffer
moves every segment's work into what it retained at its batch's submission
(State::place) or at its completion (State::unplaced) and lets go of that as it
completes, but the kept footprints stayed until the CommandBuffer was dropped.
So a program that keeps a completed command buffer, as Metal programs keep a
completed MTLCommandBuffer to read its status, error and GPU times, kept the
work of every segment whose batch's footprint the scheduler had kept: a staged
scatter's (its staging region of the arena and the RAM's use), a splice's
(its arena regions and its merges' scratch), an execution's, a render pass's
and a loop's check's among them. Nothing asks for a footprint once the command
buffer completed: the scheduler asks only of the batches it holds.

The release lets go of them now (Footprints::let_go), after its completed
handlers and before what it retained, each popped under the leaf lock and
dropped without it, as retained is.

Verified: the device test
tests::host_ram_copy_device::a_kept_completed_command_buffer_holds_nothing_of_its_staged_scatter
failed without this on lavapipe (msi job m3-max-36825: alive after its
completion 2, kept footprints' probes 1, after its drop 0; a staging of 163840
bytes). It now also asserts no kept probe after the completion; the run with
this change is reported with the tip.

Sparse updates: a completed command buffer lets go of its resource state encoders' updates

A resource state encoder's part keeps its updates (SparseUpdate: the textures
a mapping or a move names, and an indirect update's buffer) after its batch's
submission bound them: that submission clones them for the bind, and the
part held them until the CommandBuffer was dropped, so a program that keeps a
completed command buffer kept those textures and that buffer, where Metal lets
go of what a command buffer used as it completes. Nothing reads a part's
updates after its batch's submission (the steps, the footprint, the fold and
storage-form checks and an encoding again all come before it).

The release takes them out of the parts under the state's lock and drops them
without it, after the completed handlers, beside the kept footprints.

Verified: see the tip report (the device test
tests::kept_sparse_updates::a_kept_completed_command_buffer_holds_no_texture_its_mapping_update_names
run at the commit before this one and at this one).

Runtime tests: a kept completed command buffer's staged scatter, measured

A device test of the case: a program keeps a completed command buffer (as a
Metal program keeps a completed MTLCommandBuffer to read its status, error and
GPU times) whose blit encoder staged a scatter into a guest RAM through the CPU
(host_ram/copy.rs's StagedScatter: its staging region of the arena, as long as
the copy's bytes, and the RAM's use). It holds a weak reference to each
segment's work, taken before the commit (CommandBuffer::segment_works, a device
test's view, through Deferred::weak), and asserts none is alive once the
command buffer completed, while the program still holds it; it prints how many
are, how many segments the batches' kept footprints probe
(CommandBuffer::kept_footprint_probes), and how many are alive once it is
dropped.

Verified: not yet run; this commit is the measurement.

Runtime tests: name the work's type in Deferred::weak's downgrade

Verified: the measurement job m3-max-36816 failed to compile without it (E0308).

Runtime tests: a kept completed command buffer's mapping update, measured

A device test of a resource state encoder's update: a mapping of every tile of
a sparse texture the program let go of once it encoded the mapping, its
command buffer kept after it completed. It asserts the texture's handles'
retain is gone once the command buffer completed, while the program still
holds it, and prints the retain's and the texture object's holds after the
completion and after the drop.

Verified: not run at this commit alone; the job that runs it here and with the
fix after it is reported with that fix.

Verified: m3-max-36850 (msi, lavapipe) at 006565aff9: clippy --cfg m2v_cpu_icd 0; the scatter test (alive after completion 0, kept probes 0) and the sparse test ((0, 0) after completion) pass; footprint families 177/177; the sparse control at 02b1234c4d fails ((1, 1) after completion); the scatter control m3-max-36825 fails (alive 2, probes 1). Clippy plain and --cfg m2v_gpu and rustdoc run after the merge.
2026-11-16 08:37:37 -08:00
Anees Iqbal 0b674f2c1e Re-bless the golden hashes and the authored compile census at 884da5680a
SEMANTICS 2136 (a552a55d1f) views a kernel's loop-uniform read-only slot as a uniform view on
the Iris profile: golden_hashes.tsv 6 rows, authored-compile.tsv 26 rows. The engine inventory
and the air_input printouts did not change.

Verified: bless m3-max-36806 (inventory 0, golden 0, printouts 0) and census m3-max-36807
(census-exit 0) on the M3 at 884da5680a.
2026-11-16 08:25:27 -08:00
Anees Iqbal 884da5680a 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-16 08:18:59 -08:00
Anees Iqbal 3de483d86f RUNTIME 2459: Joined completions: a command buffer marked to join the next groups under Exact
CommandBuffer::set_completion_joins_next marks a command buffer, before its
commit, as one whose completion may be seen with the next one's. Under
CompletionPolicy::Exact, on a device whose merge check holds and whose
queues are not relayed, a marked command buffer's batches wait in the
scheduler's group as every batch does under Grouped. The first batch of the
VkQueue behind them that is not marked goes last in that group, which then
goes at once (GroupEnd::Closed, WorkCounts::group_ends_closed), so it is
seen complete at its own end and never held back. Its submission check runs
with the marked ones' (check_heads), so they are found ready together. No
group is kept past its pass under Exact (Alone::Unkept,
WorkCounts::batches_held_alone_unkept): a kept group can reach the GPU after
the work ahead of it ended, which would delay the unmarked one behind it.
Everywhere else (Grouped, no merge, relayed queues, the encoder trail,
batches that never group) the mark changes nothing.

Why: on the Iris Xe, ANV on i915 lists every VkDeviceMemory in each
execbuffer, about 170-190 us of driver time a vkQueueSubmit at the
consumer's import count, and the consumer cuts each guest command buffer
into about 12 parts committed under Exact, one kernel submission each.
In its walk the GPU sat idle about 1.5 ms per waited guest buffer between
parts already committed, behind a backlog of those calls. The consumer will
mark every part but the last of a cut whose completion nothing observes.

Grouped-completion's notice, docs/API.md's catalogue, FAST-PATHS row 38, the
runtime README, CompletionPolicy::Exact's doc, api_signatures and REFUSALS
say so. Tests: runtime_lane::joined_completions (marked parts group and a
group is closed by the last; checked parts too; a no-op where the device's
own check finds no merge; unmarked parts go alone; an unmarked command
buffer is seen complete while the long one behind it still runs, the marked
one before it complete by then), on lavapipe with the merge assumed.

Joined completions: the cost table's length, and the order test's first work done before

The conformance cost table's SHARED list holds 36 rows with
batches_held_alone_unkept. In the order test the marked command buffer took
the new buffers' first work, which no batch in a group takes, so it went
alone and nothing grouped: the buffers' first work now runs before it.

Verified: clippy and lavapipe lane job m3-max-36769 showed the failure
(grouped 0 with grouping true); the rerun is the next job.

Verified at 8e6c37c263: m3-max-36784 (msi) clippy --workspace --all-targets --all-features 0; m3-max-36785 (msi, lavapipe, --cfg m2v_cpu_icd) joined_completions + grouped_submissions + alone_batches 21/21 (marked parts under Exact with the merge: 7 command buffers in 2 submissions; unmarked: 7 submissions, 0 grouped; lavapipe's own merge check, not Holds: 0 grouped; an unmarked buffer is seen complete at its own end). The Iris merge check answers Holds (m3-max-36725: 9.6 us in one call of 4 against 26.4 us apart). Release-mode lavapipe, clippy --cfg m2v_gpu and m2v_cpu_icd and rustdoc run after the merge.
2026-11-16 08:18:12 -08:00
Anees Iqbal 03e5c2fd24 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-16 08:17:16 -08:00
Anees Iqbal a552a55d1f SEMANTICS 2136: Iris: a kernel's loop-uniform read-only slot is a uniform view
What: a new cost fact, DriverWorkaround::UniformAddressStorageReadsSlow, derived for ANV on
the Iris Xe RPL-P alone. On a profile that takes it, with robust descriptors:
- the memory plan finds a kernel's read-only slots read in a loop at a per-instance uniform
  offset (SlotPlan::uniform_loop_reads); the loop forest and the per-instance uniformity run
  only there (memory::plan::marks_uniform_loop_reads), nowhere else;
- lowering (lower::access::loop_uniform_views) reads such a slot through a uniform view in
  place of its storage view when the slot is also one unwritten_slots admits: an argument
  the AIR declares unaliased (air-buffer-no-alias) that no store, atomic, volatile or coherent
  access reaches, so no write of the dispatch lands on it and the view reads the bytes the
  storage view would. No aliasing fact, no bind-time check, no runtime change;
- the view is sized as Profile F's fallback sizes its views (fallback_view): its window's
  range, or maxUniformBufferRange where the window does not bound it. Then the slot states
  RuntimeFact::UniformViewRange as Viewed and no BufferRangeLimit, so a plan whose shape binds
  a buffer whose length class does not fit asks for the existing storage_view_slots variant,
  whose compile keeps the slot a storage view and states it Kept (a fixed point). That variant
  is made only for such a shape.
Every other profile and stage is unchanged.

Why: Iris job m3-max-36137 measured a convolution's weights, read in its tap loop at the loop
counter, at 316.3 us per tap through the storage view and 249.0 us per tap through a uniform
view of the same bytes (4896.8 and 4042.4 us a dispatch at 15 taps, 10589.8 and 8523.5 at 33).
The uniform view is the one form A's walk and that arm measured fast; ftreg's twin removal
(8933378831) left this slot a storage view, since its window is unbounded.

Docs: the workaround's doc, RuntimeFact::UniformViewRange, finish_slots and loop_uniform_views,
the memory plan's slot docs, docs/API.md section 5. api_signatures.tsv adds the variant;
docs/REFUSALS.md regenerated with no change.

Tests (each fails without the change):
- tests::engine_loop_uniform_views::
  - a_loop_uniform_slot_is_a_uniform_view_where_the_profile_takes_the_workaround: on
    intel-irisxe-rplp-anv the weights are UniformWords, set 0 writes UNIFORM_BUFFER there,
    the range fact is Viewed and no BufferRangeLimit; on intel-uhd770-rpls-anv (same driver and
    capabilities, no workaround) a storage view and STORAGE_BUFFER;
  - a_loop_uniform_view_needs_an_unaliased_argument_nothing_writes: without
    air-buffer-no-alias, or written by the kernel, the weights stay a storage view;
  - a_large_buffer_at_a_loop_uniform_view_asks_for_its_storage_variant: a 2 GiB binding asks
    for storage_view_slots {weights}, whose compile is a storage view stated Kept, the same key
    for the same shape;
  - a_loop_uniform_view_reads_the_bytes_the_storage_view_does: on the CPU interpreter the base
    module and the storage variant write the same output, the convolution's own.
- memory::plan::tests::uniform_reads: planned on the Iris profile; on moltenvk-m3 the tap
  loop's weights are not marked.

The Iris A/B (horizontal and vertical at the guest's shapes, B's output bytes equal to A's)
runs before landing; no landing before it shows the gain.

With it, the two facts it uses (folded from a3088b6722 and 42dfede633):

Memory plan: read-only slots read in a loop at a per-instance uniform offset

lower::simd::uniform gains a per-instance mode (Uniformity::per_instance): values
among the threads of a workgroup that execute one dynamic instance of an
instruction. A header phi is divergent only through a divergent incoming value,
so a counter with a uniform start and step stays uniform inside a loop whose
exit is divergent. Two rules replace the phi's divergent incoming block: a phi at
a join of a divergent branch (labels from the branch's successors, up to its
immediate post-dominator) is divergent, and a value defined in a loop holding a
divergent branch and used outside it is divergent.

The memory plan adds MemoryPlan::read_only (access READ, no atomic, declared
air.read, a buffer parameter's own slot, no dynamic buffer root) and
SlotPlan::uniform_loop_reads: a read-only slot loaded in a loop at an offset that
is not one constant through a per-instance uniform pointer. The loop forest and
the analysis run only where such a load exists.

Step 1 of the uniform-view work for same-address reads on ANV; nothing reads the
fact yet, so this stays on its branch until the view choice is wired.

Uniformity per instance: bound a walk's stack by the body's edges

Cfg::edge_count is test-only; count the body's successor edges instead.
Verified by the next check job.

Verified on the Iris Xe (m3-max-36775, ANV Mesa 26.2.6), A = development 19f8fb7588, B = this change, guest-shaped separable convolution kernels bound as the guest binds them, settled GPU medians per dispatch of 20 x 5: horizontal 15 taps 4908 -> 4037 us (0.823), 33 taps 10601 -> 8522 (0.804); vertical 15 taps 4409 -> 3993 (0.906), 33 taps 9561 -> 8437 (0.882). Output digests equal A and B for every shape; the weights slot is StorageBuffer in A and Uniform in B; B made one module (no storage variant). m3-max-36746 tests 155/155, clippy 0, three negative controls fail; m3-max-36765 clippy --cfg m2v_gpu and m2v_cpu_icd 0, rustdoc 0. Release translation of the library's 10 kernels: slowest 7.7 ms median (8.9 max), peak RSS 16.4 MiB. Golden tables and the compile census are re-blessed on development.
2026-11-16 08:16:28 -08:00
Anees Iqbal 47dd49ebe4 dispatch_chain: describe the textured form as a guest's compute encoders, naming no benchmark
A comment wording only.
2026-11-16 08:01:46 -08:00
Anees Iqbal c3d5b3e05e Re-bless the golden hashes and the authored compile census at 19f8fb7588
SEMANTICS 2135 (8933378831) removed the Iris storage twins, so the Iris profile's cells
moved: golden_hashes.tsv 347 rows, authored-compile.tsv 991 rows. The engine inventory and
the air_input printouts did not change.

Verified: bless m3-max-36720 (inventory 0, golden 0, printouts 0) and census m3-max-36721
(census-exit 0) on the M3 at 19f8fb7588.
2026-11-16 07:57:19 -08:00
Anees Iqbal 19f8fb7588 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-16 07:52:25 -08:00
Anees Iqbal 8933378831 SEMANTICS 2135 / RUNTIME 2458: No storage twins: a kernel's constant buffer on the Iris reads its uniform view alone
What: the Iris Xe RPL-P profile (DriverWorkaround::PushReadsLengthenThreadPayload) declares no
storage twin. A kernel's constant slot keeps its plain uniform view, read at its residual as on
every device without ConstantOffsetUniformReadsPreloaded; its set-0 layout binds the uniform view
alone. Deleted with it, everything only the twin used:
- translator: DescriptorView::UniformWithStorageTwin, BufferForm::storage_twin,
  ResourceKind::StorageTwin, BindingSource::StorageTwin, AccessPlan/Declared twins and the
  census's twin count, storage_twins, views::declare_twin/twin_symbol, emit's TwinMem, the twin's
  NonWritable statement (unwritten_buffer keeps its unaliased-argument use), PlannedBuffer::twin,
  the second DescriptorRange, buffer_uses back to buffer_use, range_at_bind_offset's unbound twin
  arm, planned_range's twin exclusion, rebinds_into's twin arm, the interpreter's twin binding,
  the codec's variants, and BindingPlan::read_only_buffer (its only reason was the twin);
- runtime: uniform_residual_form_of and reads_other_words (keyed_regions takes no flat_grid),
  the neutral zero buffer's STORAGE_BUFFER usage and plan-based read-only check (back to the
  descriptor type alone, binding::read_only_buffer);
- validation: out_of_bounds's twin arms;
- docs: API.md section 5's twin bullet, the workaround's profile doc, residual.rs, views.rs,
  ModuleBuilder::unwritten_buffer, non_writable.rs, neutral.rs, neutral_zeros_shared's docs;
  api_signatures.tsv drops the five items.
Kept: storage views' RangeAtBindOffset at offset 0 on that profile and its creation of both forms
(RUNTIME 2410), set-0 counting tests, the dispatch_chain example's arms.

Why: the twins are the confirmed cause of the Iris regression. Walk A (the tip with no twins) took
137.4 s of GPU time against 145.8 to 150.2 s for three walks with twins; Face Tracking 13.50 s
against 18.1 to 21.1, Super Resolution 25.78 against 28.2 to 28.4, Background Blur 4.93 against
5.7 to 6.4; Horizon Detection gives up about 1.3 s (17.78 against 16.2 to 16.8). No structural
rule separates where a twin pays (ftreg's report to main).

SEMANTICS and RUNTIME are bumped at landing; golden tables and the compile census are re-blessed
on development.

Test: engine_access::a_kernel_constant_slot_binds_its_uniform_view_alone. On
intel-irisxe-rplp-anv, with and without uniformBufferStandardLayout,
buffer_end_byte_load_constant's slot 0 is UniformWords/UniformVec4, its RangeAtBindOffset key is
read, and set 0 links exactly slot 0 at (0,0) and slot 1 at (0,1). A plan of nothing bound writes
those two alone in set 0 (UNIFORM_BUFFER, STORAGE_BUFFER), and only them on four other profiles.
At development the slot is UniformWithStorageTwin and set 0 holds a third binding, so it fails.

ARTIFACT_FORMAT_VERSION 524: the codec drops the twin variants.

Verified: m3-max-36704 (msi) at 2b88dec3f1 clippy --all-targets --all-features 0; m3-max-36706 clippy --cfg m2v_gpu 0. Rustdoc, the translator suites, clippy --cfg m2v_cpu_icd with the lavapipe runtime tests, and the negative control (the new test at development fails) run after the merge; golden tables and the compile census are re-blessed on development.
2026-11-16 07:51:36 -08:00
Anees Iqbal e10f3529c2 FAST-PATHS: the Iris Xe reads imported host memory at about 2.2 times device memory's GPU time
A known gap, the device's: under ANV (Mesa 26.2.6, i915) a compute kernel's reads of
constants over imported host pages cost per read, by host pointer or udmabuf dma-buf alike.

Measured on the Iris Xe (reads_k probe, one pass, rings of 64): 256 threadgroups with 1,024
uint4 reads per thread took 325 us per dispatch from device memory against 714-740 us from
a pointer import or a dma-buf import (jobs m3-max-36557, m3-max-36652). 4 KiB and 64 KiB
rings cost the same, uniform and storage views cost the same, and no recorded command count
differed between placements. The dma-buf route ran (dma_buf_imports 4, no pointer imports).
The only lever would copy guest constants into device memory, which zero copy excludes.
2026-11-16 07:33:05 -08:00
Anees Iqbal aa95a93e00 Predicated loops: the loop rebind test asks the announcements with contains
Clippy's manual_contains (-D warnings, --cfg m2v_gpu, job m3-max-36629) refused
the iter().any() over the heard degradations in
tests/rebind_loop_check.rs; it reads them with Vec::contains instead.

Fix forward of RUNTIME 2457 (83b3b67f30, test only).
2026-11-16 07:25:54 -08:00
Anees Iqbal be50ccef9c 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-16 07:25:00 -08:00
Anees Iqbal 83b3b67f30 RUNTIME 2457: Predicated loops: a rebind while a loop without work apart runs again is taken
A predicated loop's check (Deferred::Loop) answered false in
Deferred::resolved_at_its_calls, so the commit's steps_hold kept the pages of
every buffer over host pages its command buffer used until it completed, and a
rebind of one meanwhile was refused Invalid(Rebind(EncodedUses)) for as long as
the loop ran on, which Metal does without bound.

The check's host step reads only its unit's halt word, in the command buffer's
upload arena. Each run again submits the laying's VkCommandBuffers again as they
were encoded (Piece::Raw), the predicate word's VkBuffer or address and the
body's sets taken at encoding, over the pages the laying's event group took at
its first submission, which Submitting::submit keeps in State::retained until
the command buffer completes; the batch the check holds keeps it from completing
before the loop ends. Only the work the laying left apart is recorded again at
each run: a host step's resolves the buffers its encoder named then, and work on
the GPU alone records over the buffers as they lie then.

So a loop's check is now resolved at its calls where its laying left no work
apart (LoopCheck::leaves_work_apart). A rebind after the laying's submission is
taken and every run again keeps the old pages, as Metal's loop reads the pages
its submission found. A rebind before that submission is taken too, and the
laying's encoders, which keep no log to be encoded again from, fail their
submission EncodedUseRebound (announced), as every other compute encoder that
predication reaches past does. A laying that left work apart keeps holding as
before. The docs say so: deferred.rs, rerun.rs, rebind.rs (the module doc,
RebindProblem::EncodedUses, Buffer::rebind_bytes_no_copy), the commit's
steps_hold comment, the runtime README, and FAST-PATHS's two known gaps (the
refusal now names a loop whose laying left work apart; the rebind between
submissions names a loop's laying rebound before its submission).
docs/REFUSALS.md does not move.

The test is tests/rebind_loop_check.rs: a no-copy buffer holds a DoWhile's word
and its body's input. A rebind while the loop runs again is taken, the loop runs
again after it, ends on the old page's word alone, and its body wrote the old
page's input; a rebind before the laying's submission fails the command buffer
EncodedUseRebound, announced, its output unwritten.

Verified: m3-max-36621 (msi, lavapipe, --cfg m2v_cpu_icd) at 30a7bfaa4e: rebind_loop_check 2/2 (running: rebind Ok, loop ends on the old page's word, old input; before submission: rebind Ok, EncodedUseRebound announced); rebind_*|pending_rebind|host_step_*|rerun_*|predicat* 29/29; control (development's Loop arm) fails both with Err(Invalid(Rebind(EncodedUses))); m3-max-36628 clippy --all-targets --all-features 0. clippy --cfg m2v_gpu / m2v_cpu_icd, rustdoc and the validation lanes run after the merge.
2026-11-16 07:24:16 -08:00
Anees Iqbal bdba2e7858 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-16 07:10:35 -08:00
Anees Iqbal 74b2b04859 RUNTIME 2456: Bind inside a releasable import before keeping it for good
bind_in_import took the outer import with `pages(ReadApart::Inside)` before
any of its checks: that call keeps a releasable import imported for good.
Every refusal after it (a dedicated dma-buf, the window outside the
placement, the alignment, the memory types, a failed vkBindBufferMemory)
then returned None, the buffer became a copy, and the outer import stayed
held for good with nothing bound in it: never released while idle again.

Now the checks and the bind read the import through the blit's
non-pinning hold (`blit_pages`, imported again where released, which the
release sweep skips while it is held), and `expose(ReadApart::Inside)`
runs only once vkBindBufferMemory succeeded. A released import the device
cannot import again is now a refused bind (a copy) rather than a lost
device, since no work reads the stand-in there.

The test `a_bind_refused_inside_a_pointer_import_leaves_it_releasable`
refuses a bind inside a live pointer import through a test hook
(`refuse_binds_in_imports`, compiled only into the Linux device tests) and
checks the outer import is not counted as read apart inside, not kept for
good, and released; then binds a second buffer inside it and checks it is
kept for good. At development's bind_in_import the first check fails: the
import is held for good and never released.

Verified: m3-max-36585 (msi, lavapipe) at 940903c12e: pointer_residency|one_import|host_import_counts|dma_buf_beside|lone_fetch|host_residency 46/46; the new test alone passes (released after the refused bind, kept for good after the bind); clippy --all-targets --all-features -D warnings 0. The control at development's bind_in_import, clippy --cfg m2v_gpu and m2v_cpu_icd and rustdoc run after the merge.
2026-11-16 07:09:50 -08:00
Anees Iqbal 83f6c5ed10 The what and why of RUNTIME 2455 (9afd9699e1), whose folded message lost them
RUNTIME 2455 folded two commits whose messages did not reach it. They follow verbatim. No change to any file.

--- 9f9a9a2019 Begin ahead: a settled pool's primaries begun on a device thread, one an encoder

A command buffer that gives its first pool back settled posts the pool to
a new device thread (begin_ahead.rs) once its completed handlers ran, and
the completing thread begins none itself. The thread begins as many of the
pool's primaries as encoders of that command buffer opened their own in it,
one at least and spares::AHEAD = 8 at most (a dealt frame's chunks opened
5.6 encoders' own on average on ANV), one at a time: the pool out of the
spares under their lock only while one begins, kept again between begins,
so a taker never waits for a begin and one between two begins takes the
pool with those begun so far. Every encoder that opens its own primary
takes one begun while the pool holds any; before, only a command buffer's
first encoder did, and only where no thread waited for the command buffer
that gave the pool back.

Why off the completion path too: each begin was 8 to 20 us on ANV
(spares.rs), spent by the completing handler thread while the queue's
context was held, for every settled command buffer no thread waited for.
The completion now only posts (one lock, one push, one wake). The cost is
a race: a command buffer that takes the pool before the thread made its
begins finds fewer. Counted: WorkCounts::encoder_primaries_begun_ahead_missed,
the encoders among as many as the pool's begin ahead owed that found none
(the pool taken first, or out of the spares as the thread came to it);
each began its own as before. A pool is due its begins from the give-back
until the thread made them (CommandPool::due), and owes as many as the
pool's last command buffer opened (CommandPool::owed) to its next taker.

The thread: one a device, started by the first post, at the user-interactive
class as the handler threads that began these before; at most 64 pools
wait, one posted twice waits once; holds the spares' pools, the device's
functions, loader word and counts (spares::BeginTargets), never the device;
each begin in a section of the exit guard; stopped and joined by the
teardown after the handler contexts stop, before the spares are released.
The command buffer allocation the begin may make goes through the same
helper as the device's (device::allocate_command_buffers), counted alike.
CommandPool::begun is a Vec; take_begun is open_encoder, which also counts
the encoder for the pool's next begin ahead. The gate's waiter count
(Gate::awaited) had no user left and is deleted, with its test.

Tests:
- tests::begin_ahead::each_render_encoder_after_a_settled_command_buffer_
  opens_from_a_primary_begun_ahead: a command buffer of 5 render encoders
  on a new pool, then the next takes that pool, the only spare: each of its
  5 render encoders opens from a primary begun ahead
  (encoder_primaries_begun_ahead 5), none missed, same pixels.
- tests::begin_ahead::a_waiter_returns_before_the_begins_and_a_taker_before_
  them_counts_its_encoders_missed: the thread held (test hook) at its
  begins, the command buffer's wait returns with no primary begun; the next
  command buffer takes the pool first and counts 5 missed; released, the
  third opens all 5 from primaries begun ahead.
- spares unit tests for several begun primaries, the AHEAD cap, the misses,
  and a pool that may begin no more being due no more.
- Tests that read the spares or the begin counts after a wait settle the
  thread first (BeginAhead::settle, test only); draw_again's begun-alike
  test holds the thread from the start rather than waiting for a run that
  begins its own, and its begun-meanwhile test holds it until the event's
  command buffer took a pool, so that pool is due a begin; the bound test
  holds it so the begins are its own.

Verified so far (scratch commits of the same tree, msi lavapipe): the touched
suites begin_ahead|spares|draw_again 64/64 and clippy --cfg m2v_cpu_icd 0
(m3-max-36530); the tip's own runs follow.

--- 5774363889 Spares test: a pool past a command buffer's first holds its primaries begun ahead beside POOL_HOLDS

A spare that holds primaries begun ahead and serves a command buffer past
its first pool keeps them begun (only a command buffer's first pool's
encoders take them), and the command buffer grows its made primaries to
POOL_HOLDS beside them: lavapipe (msi, m3-max-36541) saw a spare of 35, 32
primaries, a secondary and two begun ahead, past the fewest test's bound of
POOL_HOLDS + 2. The bound is POOL_HOLDS + AHEAD + 1 now, and the spares
module docs say where the begun ones sit.

Verified: the rest of that job's 243 touched tests passed; this test's
run follows.
2026-11-16 06:54:07 -08:00
Anees Iqbal bdd4710e92 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-16 06:53:45 -08:00
Anees Iqbal 9afd9699e1 RUNTIME 2455: Spares: primaries are begun ahead on a device thread, one for each encoder the pool last served, eight at most
Verified: m3-max-36547 at 5774363889, lavapipe begin_ahead|spares|draw_again|pending_audit 72/72, clippy (host, m2v_cpu_icd) 0; m3-max-36546 clippy --cfg m2v_gpu 0; m3-max-36541 at 9f9a9a2019 rustdoc 0; negative control m3-max-36540 (AHEAD = 1) fails both new tests (taken 1 against 5; missed 1 against 5). PHOENIX (m3-max-36549) runs after the merge.
2026-11-16 06:53:04 -08:00
Anees Iqbal 566dc02f9d 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-16 06:19:14 -08:00
Anees Iqbal 32285d7988 RUNTIME 2454: Carries: a queue holds sixteen, a frame's dozen side by side each open warm
A program that encodes each frame as about a dozen command buffers side by
side (measured: 11 to 12 a frame) opens each of the next frame's against the
carries of this frame's commits. A queue held four (queue::CARRIES), so
over a third of them opened with no carry (measured: 333 a second of 883
command-buffer parts), and each one's first draws took every step. Sixteen
hold a frame's with room.

Memory held per queue at sixteen, measured on lavapipe (msi, job
m3-max-36477, a throwaway test that dropped the carries a queue held and
counted the heap bytes freed with a counting allocator): 33,952 bytes a
carry whose encoders drew once, 34,384 a carry of 100-draw encoders, the
same in each of four rounds; 16 carries 543,232 to 550,144 bytes (about
0.53 MiB) a queue, against about 0.13 MiB at four. size_of: Carried 920,
LiveBind 21,072, BindState 632. A carry's live bind goes back to the
device's live binds as it is let go. Scope: the test's one-state draws;
a program's carries with more slots bound hold larger tables (unmeasured).

Test: tests::carried_draws::a_dozen_command_buffers_encoded_side_by_side_
each_open_from_a_carry_their_queue_holds, two groups of twelve: each of the
second group opens from a carry (kept_draws_carried_across 12), none let go
at a commit, only the first group's draws take every step, the pixels those
of the same passes on queues of their own. side_by_side_frame takes the
group size; the existing callers pass 2.

Verified: lavapipe (msi) carried_draws 16/16 at the scratch commit with the
same tree plus the measurement (m3-max-36477); the negative control and the
tip's own runs follow.

Verified: m3-max-36493 at 3c8f52ce23, lavapipe carried_draws|spares|draw_again 76/76, clippy (host, m2v_cpu_icd) 0, rustdoc 0; m3-max-36494 clippy --cfg m2v_gpu 0; negative control m3-max-36492 (CARRIES = 4) fails the new test (across 4 against 12). PHOENIX runs after the merge.
2026-11-16 06:18:31 -08:00
Anees Iqbal 9dc0a6a6ef Docs: name no workload of a consumer's benchmark
docs/FAST-PATHS.md's unshared-isolation row and a spares test's doc named two workloads of a
guest compute benchmark; they now say 'one workload' and 'a guest's compute workload'. The
repository names no consumer app, benchmark or workload. No behaviour change.

Verified: git grep for the benchmark's and its workloads' names finds none after the change.
2026-11-16 05:58:45 -08:00
Anees Iqbal 5ecdb6a1ac 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-16 05:56:42 -08:00
Anees Iqbal e63ecb9405 RUNTIME 2453: Host pages: a buffer inside a no-copy buffer's own dma-buf import dedicated to nothing is bound in it
What: Device::bind_in_import now binds a no-copy buffer whose pages a live
import of dma-bufs holds all of inside that import, as it does inside an
import of the pointer, where the import is one VkDeviceMemory dedicated to
nothing (a no-copy buffer's own dma-buf of one chunk, a piece of a shared
file's import, a guest RAM chunk's). The new VkBuffer is made for the import's
handle type (VkExternalMemoryBufferCreateInfo DMA_BUF, from bound_memory), its
alignment and memory type checked as before, and the holding import is kept
imported for good (HostImport::pages(ReadApart::Inside), as for a pointer
import). Still refused: an import the driver took only dedicated to its buffer
(DmaBufPages::dedicated_to_buffer, NVIDIA 615's retry) and several chunks bound
to a sparse buffer (no memory); those pages stay a copy, or an import of their
own beside dma-bufs. Before, every dma-buf import but a guest RAM chunk's
refused, so such a buffer was a copy (copied_over_live_imports) whenever it
came with no dma-buf source, or a second import beside it.

The Vulkan rules: VUID-vkBindBufferMemory-memory-02985 (a buffer bound to
imported memory names the import's handle type in
VkExternalMemoryBufferCreateInfo::handleTypes, which host_buffer does from
bound_memory's External(DMA_BUF)); VUID-vkBindBufferMemory-memory-01508 binds
only the dedicated buffer where VkMemoryDedicatedAllocateInfo::buffer was not
VK_NULL_HANDLE, which holds only for the dedicated retry, still refused;
VUID-vkBindBufferMemory-None-10739 (offset a multiple of the alignment) and
-memory-01035 (memory type) as checked before.

Why: on the Iris, with a platform mapping a view of guest pages through one
dma-buf, a guest heap's region takes a 2 MiB no-copy buffer imported through
that dma-buf, and the 256 KiB buffers placed in the heap's pages, handed over by
their pointer alone, became copies of the pages over the live import: 582 copy
ins compared a second, each the copy's whole 64 pages (155 MB/s), 10.7 MB/s
copied in, commit_nanos 43.7 -> 120.5 ms/s. With the views mapped from their
files the same buffers were bound inside the pointer import
(buffers_bound_in_import), with no copy. dma_buf_buffer_imports_dedicated was
0 there: every such import was dedicated to nothing.

Docs: bind_in_import's doc no longer says a buffer's own dma-bufs' memory is
that buffer's alone; dma_buf.rs's module docs, import_from_source's and
chunks_buffer's `sole` contract and DmaBufPages::dedicated_to_buffer say a
buffer over part of the pages binds inside an import dedicated to nothing and
in none dedicated to its buffer; FAST-PATHS's NVIDIA dma-buf gap says the same.

Test: tests/dma_buf_beside.rs's
without_pointer_imports_a_buffer_inside_a_live_dma_buf_import_is_bound_in_it,
on a device made without VK_EXT_external_memory_host: a first no-copy buffer
over 4 pages of a memfd with a dma-buf source, then inside it a second with no
source and a third with one, each bound inside ([0, 0, 0, 0, 1] of copied over
live, beside, inside live, pointer imports, bound inside) where the first's
import is dedicated to nothing (else a copy, and beside or a copy); the GPU
reads the CPU's bytes through each, a CPU write before the commit reaches a
copy through the second, a fill through one and a copy through the other in one
encoder are ordered either way, and after the first's release the second's
fill reaches the file's pages and reads through the third.

Verified: m3-max-36423 at e377c24dce, clippy -D warnings (runtime and translator, all targets and features) 0 and rustdoc -D warnings 0. Lavapipe tests, the negative control, the cfg clippy and PHOENIX run after the merge.
2026-11-16 05:56:00 -08:00
Anees Iqbal 3ce1d01744 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-16 05:55:16 -08:00
Anees Iqbal aa272cd706 Rebind: record the refusal while a dispatch's host step is left as a known gap
A compute encoder can leave a dispatch to its host step (Deferred::Dispatch,
indirect_dispatch.rs): an indirect dispatch off the GPU's own path, or any
dispatch while an indirect stage-in region is set. The host step reads the
arguments once the work before it completed, and resolves the buffers its
encoder named as it records. Deferred::resolved_at_its_calls is false for it,
so the commit keeps the pages of every buffer over host pages the command
buffer used until it completes. A rebind of one meanwhile is refused with
Invalid(Rebind(EncodedUses)), where Metal's replace before the submission
reaches the new pages.

Encoding the encoder again (the reverted 947c110e49) would not reach this
path: the rebind is refused before any encoding again. So the behaviour stays,
and is now recorded:
- rebind.rs's module doc lists the dispatch among the commands that keep a
  committed command buffer counting as uncommitted until it completes, with
  the refusal;
- the doc comments of RebindProblem::EncodedUses and of Buffer's and Heap's
  rebind_bytes_no_copy name the committed case;
- Deferred::resolved_at_its_calls names its false arm (an execution, a
  dispatch left to its host step, a loop's check);
- the runtime README's rebind sentence names the committed case;
- docs/FAST-PATHS.md has a known-gaps entry.
HOWTO does not state the rebind's refusal, so it is unchanged.

The test is host_step_reads.rs's
a_rebind_while_an_indirect_dispatch_s_host_step_is_left_is_refused_until_completion.
On a device without device addresses (shaderInt64 withheld), it dispatches
[4, 1, 1] threadgroups from a no-copy page behind a shared-event gate, and
rebinds the page before the signal over one holding [2, 1, 1]. It asserts:
- the rebind is refused with Invalid(Rebind(EncodedUses));
- the command buffer completed with no error;
- the host step ran;
- the dispatch ran the encoded page's 256 threads;
- a rebind is taken once the command buffer completed.

Degradation kinds added or removed: none.
2026-11-16 05:52:20 -08:00
Anees Iqbal 286d25bded 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-16 05:44:55 -08:00
Anees Iqbal 439b3b7280 RUNTIME 2452: Sparse scrubs: a rebind encodes the encoder of a scrub again
A blit or a render pass that writes a sparse texture leaves a scrub of the
unmapped tiles it wrote, recorded at its batch's submission
(Deferred::SparseScrub). Deferred::resolved_at_its_calls answered false for
it, so the commit's steps_hold kept the pages of every buffer over host pages
the command buffer used until completion, and a rebind of one before the first
submission was refused with Invalid(Rebind(EncodedUses)). Had it not been,
the encoder kept no log (Unlogged::Segments), and the submission would have
failed EncodedUseRebound.

The scrub zeroes tiles of its texture alone, as its batch mapped them, and
reads no buffer. So it is now resolved at its calls, and left again by an
encoding again: the blit or pass encoded again leaves its own scrub over the
same texture, and the first's goes unrun (finish_replay prepares it;
splice_replay retains the first's). Unlogged::Segments now names only a
GPU-written indirect dispatch's host step. The docs of records_again,
finish_replay and splice_replay name the scrub.

The test is tests/rebind_sparse_scrub.rs. The texture's left tiles are mapped,
then a blit writes the whole texture and fills a no-copy buffer behind a
shared-event gate. The buffer is rebound before the signal, and the test
asserts:
- the command buffer completed with no error;
- one encoder was encoded again;
- the fill reached the new pages and not the old;
- the mapped tiles hold the blit's texels.
The control (this commit's deferred.rs reverted) fails at the rebind with
Invalid(Rebind(EncodedUses)).

Degradation kinds added or removed: none.

Verified: m3-max-36396 at 8f4ce875f5 (same tree), clippy -D warnings of the runtime (all targets and features) 0 and rustdoc -D warnings 0. The cfg clippy, the control, the rebind tests, the suites on lavapipe and the sparse conformance replay run after the merge.
2026-11-16 05:44:09 -08:00
Anees Iqbal 56c04b2f41 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-16 05:36:09 -08:00
Anees Iqbal f27f432487 RUNTIME 2451: Shadows: a gated copy in copies from the truth's buffer as its call found it
RUNTIME 2450's test,
dirty_pages_device::a_rebind_before_the_first_submission_encodes_a_gated_copy_in_s_encoder_again,
failed on lavapipe at RUNTIME 2450 and at the tree before it alike
(m3-max-36334): rebind_bytes_no_copy answered
Invalid(Rebind(EncodedUses)), not EncodedUseRebound. A shadow's copy in
left to its batch's submission (Deferred::GatedCopyIn) read the truth's
VkBuffer as its record ran there (ShadowBuffer::Rebound), so it was work
whose step resolves what it records then
(Deferred::resolved_at_its_calls false): its commit held the pages of
every buffer over host pages the command buffer used until it completed
(steps_hold), and a rebind of one meanwhile was refused at the call, as
for a command buffer not yet committed, where Metal's replace is not.
The rebind never reached the encoding again, so RUNTIME 2450's
predicate (Deferred::left_again_by_an_encoding_again for GatedCopyIn)
was inert on that path; the test's control at development's files fails
on the same refusal.

Now a GatedCopyIn captures, at its encoder's call, the VkBuffer of a
truth a rebind may move (GatedCopyIn::from: bytes of a buffer over host
pages, the only such truth a gated copy in reads, a log's; a standing
one's truth only the runtime's commands write), and its record at the
submission copies from it (ShadowCopy::record_gated and record_moves
take it beside the gate; every other caller passes none and reads the
buffer as it is). Its recording then reads nothing of a buffer resolved
later, and Deferred::resolved_at_its_calls answers true for it: the
command buffer lets those pages go at the commit (held weakly until its
first submission), a rebind before that submission is not refused but
encodes the encoder again, whose own gated copy in captures the new
buffer and takes the first's place (RUNTIME 2450), and a rebind after it
leaves the old pages to the command buffer until it completes. A first
gated copy in whose encoder a rebind could not encode again is let go of
with its encoder's failing segments (State::fail_part, before
record_scrubs), so no captured buffer is recorded after its pages went.

Docs: shadow.rs (GatedCopyIn, record_gated), deferred.rs
(resolved_at_its_calls), and attached_read_faces' busy lane, which said
a rebind there is refused.

Verified: cargo fmt only; the job reported with this tip runs RUNTIME
2450's test (which this fix-forward makes pass) and its control.

Degradation kinds added or removed: none.

Verified: m3-max-36366 at fc0e1aee30 (same tree), clippy -D warnings (runtime; m2v_gpu; m2v_cpu_icd runtime+validation) 0 and rustdoc -D warnings 0. The control, RUNTIME 2450s test, the rebind tests and the touched suites on lavapipe run after the merge.
2026-11-16 05:35:25 -08:00
Anees Iqbal 2687d19eb6 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-16 05:24:00 -08:00
Anees Iqbal 5410cd5cf4 RUNTIME 2450: Shadows: a rebind encodes the encoder of a gated copy in again
An encoder that left a shadow's copy in to its batch's submission
(Deferred::GatedCopyIn: over host pages a consumer logs, the regions its
log decides; or a command buffer's first copy in of a shadow that may
stand across command buffers) kept no log (Unlogged::Segments): no
Segment::records_again test held for it. A rebind, before the command
buffer's first submission, of a buffer over host pages that encoder used
then failed the command buffer with EncodedUseRebound, where Metal
resolves the use at the submission. Keeping the log alone would not do:
the encoding again redoes the copy in for itself (a gate of the log
taken again, a standing decided at the submission, ended_encoders_wrote
answering false while replaying) and leaves a GatedCopyIn of its own, or
records the copy in in place, but finish_replay asked every other
segment to record on the GPU alone, which a gated copy in does not, and
refused the encoding again.

Now Deferred::left_again_by_an_encoding_again answers for GatedCopyIn
too: the encoder keeps its log, its place takes the encoding again
(splice_fits), finish_replay prepares the encoding again's segment as the
commit prepares one (no recording, StepInputs::None), and the batch's
submission records it (submit.rs's record_scrubs, which takes every
unrecorded such segment). The first's goes unrun, retained. A gated copy
in made by the encoding again holds a gate of the log made after the
commit's decisions (DirtyShadows::committed), whose decision is none, so
it copies every region (CopyInGate::regions): a superset of the rows the
log reports changed, read at the submission, after every CPU write before
the commit; the shadow's hold was advanced to the commit's stamp by the
first gate's decision, and its image then holds at least that. Its cost,
one whole copy in, falls only on a rebind of such an encoder. A standing
gate is decided at the submission (stands), as the first's would be. GPU
parts are unchanged: a gated copy in starts none.

Unlogged::Segments now names a GPU-written indirect dispatch's host step
and a scrub. Docs: deferred.rs, rebound_use.rs, encoder.rs, reencode.rs,
shadow.rs (GatedCopyIn).

Test: dirty_pages_device's
a_rebind_before_the_first_submission_encodes_a_gated_copy_in_s_encoder_again:
a kernel inverts a shadowed RGBA8 texture over a logged no-copy buffer
into a plain texture, behind a shared event only the host signals; the
buffer is detached and rebound over other pages, logged by the same log,
before the signal. Asserts the command buffer completes with no error,
the rebind encoded the encoder once, one gated copy in ran (the encoding
again's) and copied every row (dirty_copies_in_gated +1,
dirty_copies_in_whole +1), and the kernel read the new pages' texels. At
development's files it is expected to fail on the error
(EncodedUseRebound).

Degradation kinds added or removed: none.

Verified: m3-max-36334 at a7b5d28822 (same tree), clippy -D warnings of the runtime (all targets and features) 0. Rustdoc, the cfg clippy, both controls, the rebind tests and the touched suites run after the merge.
2026-11-16 05:23:18 -08:00