Commit Graph
601 Commits
Author SHA1 Message Date
Anees Iqbal e3b8d67b5b runtime: a command buffer whose timestamps read unavailable completes, counted, and is no victim
A regression fix in the frozen old runtime. Matrix 749c939440's UHD 630 leg (Windows, Intel driver
101.2145, job 48872) failed the old runtime's burst_2000 and burst_2000x5 with "the command buffer
ended Error: Some(GpuRecoveryVictim)", with no device loss and no recovery notice: at least one of
the old runtime's 2,010 submissions a run read a timestamp unavailable once its queue's timeline
had passed it, and the old runtime took that as work the driver dropped and failed it as a victim
of a GPU recovery. The old runtime's poll already orders the read after a host wait on the fence
or the timeline, so this driver showed the signal before the timestamps' availability. A
signalled submission with its timestamps unavailable is no lost GPU: the command buffer now
completes, its GPU times 0, counted as before (`WorkCounts::unrun_command_buffers`), as the new
runtime counts the same case and fails nothing.

The cost is the case the branch was made for: work Linux's amdgpu drops with no error (a job its
timeout ended, and those queued behind it) completes with no error too. The FAST-PATHS known gaps,
the module docs, the error's and the count's docs and the README say so.

Test: the device test `dropped_work` now asserts the injected unavailable read completes with no
error, its fill ran, its GPU times 0, counted once, and the queue runs on (the old form asserted
the victim). Verified in the jobs named in the landing message.
2026-11-18 17:45:51 -08:00
Anees Iqbal 4da77d8518 FAST-PATHS: what an NVIDIA host whose type 0 reads right loses to the Shared dma-buf refusal 2026-11-18 12:54:29 -08:00
Anees Iqbal 1d5226bef7 runtime: a Shared dma-buf import takes host-coherent types only, and none where its first is not
The old runtime imported a Shared no-copy buffer's dma-buf on NVIDIA as type 0 (system memory,
no property flag): its udmabuf order (system-memory types the host maps last) puts type 0
before type 4. A type without HOST_COHERENT promises nothing of what the caller's own mapping
of the pages and the device see of each other's writes, and Shared memory's bytes are exactly
that; the consumer's probe showed wrong bytes there.

The form, decided by the memory types' flags alone (no fact row, device check or switch):
today's order is computed unchanged (memory::dma_buf_order, the former dma_buf_candidates);
for MemoryClass::Shared, dma_buf_candidates then keeps only its host-coherent types, in its
order, where its first type is host-coherent, and none where it is not. An empty order tries no
import and refuses as ImportFailure::NoMemoryType, which callers already map to not_importable()
("host memory this device cannot import exactly"), so what it would back takes the refused
dma-buf's path, a copy of its pages. Type 4 is never tried: a refused import there breaks every
later exportable device-local allocation for the device's life (tests::export_after_dma_buf).
Private and the other classes keep the order whole (type 0 on NVIDIA as before).

Tests:
- tests::memory::a_shared_dma_buf_import_takes_host_coherent_types_or_none: over NVIDIA's,
  ANV's, RADV's (discrete) and lavapipe's types and udmabuf bits, the first type before and
  after is the same but NVIDIA's (0 before, refused after, no attempt), and every other class's
  order is unchanged. The order tests name dma_buf_order.
- tests::export_after_dma_buf::a_shared_dma_buf_import_is_host_coherent_or_refused_untried
  (device test): where the order is empty the import is refused and exportable Private buffers
  made after it still lie in device-local memory with no overflow; elsewhere it imports as a
  host-coherent type and a Shared buffer over it shares bytes both ways (the GPU's fill read
  through the caller's mapping; the CPU's writes there read by the GPU's copy).

docs/FAST-PATHS.md's known gap on NVIDIA's dma-buf imports says so. docs/REFUSALS.md
regenerates unchanged (the refusal is the existing one).
2026-11-18 12:54:29 -08:00
Anees Iqbal 8ec8cbbc20 old-runtime regression fix: a half color output is 16-bit again under Device::new
6f5bd20321 removed the 16-bit `half` color output form on every device. That moved Device::new's
output, which the old runtime builds on: 111 golden cells on each RADV, ANV and MoltenVK profile
(5c47b9c867 -> bfe63b5097). The form comes back for Device::new alone, as a profile fact:
ProfileFacts::half_outputs is HalfOutputs::Sixteen in Device::new's facts (ROWS) and
HalfOutputs::Widened in Device::from_queries' (EVERY). Under Sixteen a `half` color output is
declared with 16-bit `float` lanes where the profile enables storageInputOutput16 and
shaderFloat16, as before 6f5bd20321. storageInputOutput16 is not one of the queries rule 2 lets
choose a second form, so the new runtime keeps one 32-bit form for every stage output. The fact
renders into no ROWS fingerprint, so Device::new's profile keys do not move.

- lower::stage_io: plan::half_variable (now reading the fact and the enabled feature),
  IoObject::User::half, the 16-bit store and io_elem's width are back. StageIo::half_outputs and
  the link contract's 16-bit lanes are back.
- The HalfOutputPrecision and HalfOutputFastMathBlend note texts, docs/API.md's degrade
  catalogue, docs/FAST-PATHS.md and the half-output-blends case say what they said for the old
  path, each scoped to Device::new, with Device::from_queries handing every device the `float`.
- known-gaps.tsv: the 52 MoltenVK rows for the M3 Max's half-output-blends-r16f, -rg16f and
  -rgba16f go, as before 6f5bd20321: with the 16-bit output MoltenVK stored Metal's codes there.
  docs/CONFORMANCE-COVERAGE.md is regenerated (3,783 -> 3,731 ledger rows).
- The Iris Xe's 62 half-output rows (6769c2eaaf) were measured with the 32-bit form on ANV, which
  gets the 16-bit form again under Device:🆕 they are owed a re-run with it.
- SEMANTICS_VERSION 2157 (the 111 cells per profile change under unchanged keys) and
  ARTIFACT_FORMAT_VERSION 530 (the artifact codec has StageIo::half_outputs again).
- The engine_stage_io test is back. It also checks that the profile from Device::from_queries is
  HalfOutputs::Widened and keeps the output 32-bit on MoltenVK, RADV and lavapipe, with no
  StorageInputOutput16.

Verified at 8e0e199a12 on 00ca405504, whose tree is this commit's but for SEMANTICS_VERSION (2156
there; development took it meanwhile) and development's later commits (03a3741772 and the
harness's), which touch none of this commit's files:
- msi 41897: golden_hashes_match_the_table with every difference listed, compared with the
  tables at 5c47b9c867 and bfe63b5097. All 504 stage-io cells on the .ll rows that Linux compares
  (56 on each of the 4 RADV, 4 ANV and MoltenVK profiles) are back at their 5c47b9c867 values,
  none elsewhere. On ANV and MoltenVK those are the only cells that moved (280, under unchanged
  keys). The RADV and NVIDIA columns are stale under profile fingerprints that development's
  e0f567a8bc moved back before this commit (12,705 cells, the table not yet blessed for it); in
  them only the stage-io cells above and 185 cells on each of nvidia-rtx50-linux and
  nvidia-rtx5080-laptop (e0f567a8bc's NVIDIA restore) moved. No ROWS fingerprint moved with
  this commit. The 55 stage-io cells per profile on .air.ll rows need metal-as and wait for the
  M3 bless.
- msi 41813: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc
  -D warnings, nextest -p metal2vulkan -p metal2vulkan-conformance in full: 4,719 of 4,722 pass.
  The failures: golden_hashes_match_the_table, for the bless above;
  the_public_signatures_are_the_committed_table, development's degradations! row, fixed since by
  489bc24c4e; the_authored_4096_step_kernel_compiles_inside_the_budget, which passed alone on
  the same build (41862) and is not in this commit's scope.
- msi 41814: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
2026-11-17 11:30:29 -08:00
Anees Iqbal d5a475f1a0 old-runtime regression fix: the stage bounds return to Device::new's ANV rows; the bound on every device is a fact of from_queries' profile
576a7348bc put one stage bound on every device on the shared translator
path, so the old runtime (Device::new) newly refused what it compiled
before: on the UHD 630 and on every committed profile without maximal
reconvergence, 6 corpus modules (12 rows) went from compiled (emulated
simdgroups, entry weights 104,424 to 188,554) to Needs::StageBound.
Measured on gem10 through Device::new at 9cb90de8cc (job m3-max-41747).

Restored for Device::new, as before 576a7348bc:
DriverWorkaround::SerializedStageWrapsLargeModules and
CompilerMemoryGrowsWithStageSize on ANV's identity row, their bounds
(786,432 and 99,109), the re-plan keeping the widest pin, and the
refusal as Needs::DriverDefect naming the defect; no bound elsewhere.
The old runtime's heap-trim test, warm-refusal kinds and their tests go
back to their text before 576a7348bc.

rt keeps what landed, carried with no switch. The bound is a fact of
the profile (device::profile::StageBound): Device::new builds
StageBound::Defects (the bounds of its rows), Device::from_queries
builds StageBound::Every (99,109 on every device, refused as
Needs::StageBound). stage_bound::emit reads that one field. The
fingerprint renders the fact only when it is Every, so every
Device::new fingerprint is byte-identical to before 576a7348bc. Every
from_queries fingerprint moves, so an rt profile is never one of the
old path's.

Tests:
- The pre-576a7348bc ANV tests are back (both defects' bounds, and the
  same profile without them emitting under every bound).
- New every_stage_from_queries_keeps_the_widest_pin_or_is_refused:
  re-planned, then StageBound; the serialized bound is none there; RADV
  through Device::new is unbounded.
- the_stage_bound_fixture_keeps_the_pin_or_is_refused covers both
  paths. Iris pinned through both. Without maximal reconvergence:
  StageBound through from_queries, DriverDefect on ANV through
  Device::new, and emitted emulated through Device::new under Intel's
  Windows driver (the UHD 630's case).
- New the_stage_bound_is_a_fact_of_the_profile checks every committed
  profile.

Docs:
- FAST-PATHS' known gap is ANV's again.
- The rt README's known gaps gain the every-device bound.
- API.md and the Needs::StageBound and Feature::StageSize docs name
  both paths.
- REFUSALS.md regenerated; the API table regains the two variants.

SEMANTICS_VERSION 2153.
2026-11-17 10:57:34 -08:00
Anees Iqbal 576a7348bc translator: one stage bound on every device; the two stage-size workarounds go
A module whose entry weighs more than COMPILED_STAGE_WEIGHT (99,109, the
heaviest stage measured to compile within host-sized memory, on ANV) is
now handed to no driver, whatever its identity. A kernel that emulated
its simdgroups only in place of the widest mode's pin (the subgroup size
range decides it) is planned again keeping the pin, as before; every
other module past the bound is refused with Feature::StageSize and a new
Needs::StageBound, its symbol naming the weight and the bound. The
refusal is permanent for the input on the device (its plan decides the
weight), so it is not NotImplemented; validation reads it as the
translator's own gap.

DriverWorkaround::SerializedStageWrapsLargeModules and
CompilerMemoryGrowsWithStageSize go, with ANV's identity entries for
them and the serialized bound (786,432), which the single bound sits
far below. Why: the workaround ladder takes one form for every device,
the slowest compiler's; a device whose compiler would take a heavier
stage is refused it, recorded in FAST-PATHS' known gaps.

Measured before this change, with a scratch build that applied the
bounds and the re-plan to every profile: the corpus on the Iris Xe's
description without its identity refused nothing (largest planned
module 91,399, job m3-max-41496), and RADV and NVIDIA nothing either;
without maximal reconvergence 12 rows were refused, 6 distinct
simdgroup-matrix modules of 198 to 285 products whose lockstep pairs
force emulated simdgroups (jobs m3-max-41474, m3-max-41523).

The owned fixture stage_bound/stage_bound_matrix (512 simdgroup matrix
products beside a lockstep pair in divergent flow, our own MSL) has
their structure: on the Iris Xe its emulated module weighs 123,307 and
its pinned one 37,646; without maximal reconvergence it is refused at
123,308 (scratch weighing, job m3-max-41602). The new test
the_stage_bound_fixture_keeps_the_pin_or_is_refused asserts both paths
and that the re-planned kernel is under the bound.

The old runtime's heap-trim test loses its long chain, now refused on
every device; it asks for a trim where the making left more than the
floor free (NVIDIA's compile never does under the bound, 189 MB at
most measured). SEMANTICS_VERSION 2150; REFUSALS.md regenerated; the
API table loses the two variants and gains Needs::StageBound.
2026-11-17 10:24:59 -08:00
Anees Iqbal 6f5bd20321 stage io: one 32-bit form for every stage output
The translator declared a `half` color output with 16-bit float lanes where the device enabled
storageInputOutput16 and shaderFloat16: a second form chosen by a query that is not one of the four
the owner's rule 2 allows (the 3090, 2080, RX 550 and lavapipe lack it; MoltenVK, RADV and ANV
have it). Every interface variable is now 32-bit on every device: a `half` output is widened to
`float`, which holds every `half` exactly, and no module needs StorageInputOutput16.

- lower::stage_io: plan::half_variable, IoObject::User::half and the 16-bit store are gone, and
  io_elem takes no width. StageIo::half_outputs and the profile's input_output_16bit are gone;
  the link contract checks 32-bit float lanes only.
- SEMANTICS_VERSION 2145 and ARTIFACT_FORMAT_VERSION 527 (the artifact codec lost a field). The
  golden table needs its re-bless on development: every profile's key moved with the profile's
  lost field.
- The HalfOutputPrecision and HalfOutputFastMathBlend notes, docs/API.md's degrade catalogue,
  docs/FAST-PATHS.md and the half-output-blends conformance case say what the device receives
  now; their statements about the 16-bit form are gone.
- known-gaps.tsv: 52 rows for MoltenVK on the Apple M3 Max. With the 16-bit output MoltenVK stored
  Metal's codes at every word of half-output-blends-*; with the `float` output its blend is the
  device's own (half-output-fast-math-blend) at 17, 17 and 18 sites of the R16Float, RG16Float and
  RGBA16Float cases, largest differences 1 to 1,582 codes at the stored value (the blend-colour
  sites the largest). Its 32-bit float cases still store Metal's codes.

Verified (code at c55bc28e43, ledger rows added at 2754676210, this commit's tree):
- msi 40877: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc
  -D warnings, nextest -p metal2vulkan in full: 3,661 of 3,662 pass; the one failure is
  golden_hashes_match_the_table (every profile's key moved), for the re-bless on development.
- msi 40827: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- XTX (RADV NAVI31) 40843: runtime_lane color_writes (every `half`, NaN and infinity included),
  half_output_blends and extended_range_blends, 16 of 16 pass; the conformance replay of the six
  half-output-blends cases exits 0 against the RADV rows, so every row's count and largest
  difference held.
- RTX 3090 (ms01) 40844: the same 16 lanes pass; the replay's 59 divergent sites are exactly the
  RTX 5080's 59 rows (the ledger holds no 3090 rows; NVIDIA never had the 16-bit form).
- M3 Max on MoltenVK: 40833 before the rows (52 new gaps, all in the 16-bit float cases), 40862
  with them (exit 0, every count held on the second run).
- msi 40875: the conformance crate's ledger tests, 7 of 7.
2026-11-17 07:01:32 -08:00
Anees Iqbal 96e1041dbf RUNTIME 2538: submission checks: an answer that load could have made stands only for now
What: a merge or import tax answer now stands as far as it earned
(`Stands`). A merge `Holds` clear of the load and repeated, an import tax
`Holds` past its margin and repeated, and an `Unchecked` of a refused call
or a device with no pointer import are recorded. A `Fails` clear of the
load whose every try ran quiet stands for the device's life and is never
recorded. Every other answer stands for now: the checks' thread keeps its
command buffers and fence and checks it again 1, 2, 4 ... 64 s after the
first answers, then each minute, until none stands for now. A check again
replaces the verdict (tries that all split keep it), so a device whose
first merge answer was a loaded `Fails` groups once a check again answers
`Holds`. A record's `Fails` is a hint and no answer: a device that reads
one checks that check again at its making. Before each round and each
submission of a phase the checks stand by, at most 20 ms, until the
device's work is quiet (`DeviceShared::work_quiet_for`, shared with the
checks' thread through `WorkShare`).

The stop rule's thresholds (`Load::ran_quiet`): every stand-by found the
device's work quiet, no round or submission took past QUIET_ROUND_MOST
(2 ms, from its first call to its fence's reset), and all of them no more
than QUIET_TRY_MOST (30 ms). A merge `Fails` must also be clear
(MERGE_FAILS_CLEAR, 0.75 of the calls apart) and repeated
(MERGE_REPEATS); an import tax `Fails` must agree in its halves with a
held import adding at most half its bound (TAX_FAILS_CLEAR).

Why: on the Radeon 780M beside other jobs (m3-max-39740, load average
18-24 on 16 threads), two of four devices answered merge `Fails` at 0.72
and 0.745, both forms lifted by about the same 58-80 us, short of the
record but held for the device's life, so those processes grouped no
batch at all. At 0.75 and up with its repeats, the same load would have
written a `Fails` record that every later device of that release read
without checking. Threads of the process's own spinning or touching fresh
pages (m3-max-39786, 2x the host's threads) lifted every call alike and
left all eight devices at `Holds` (0.23-0.64), so the device test injects
the observed shape instead (`lift_next_merge_tries`: 70 us on the first
call of every round, its stand-bys not quiet).

Costs: a driver that does not merge or whose imports cost nothing pays
that check at every device's making, as before any record, and once more
at least where no try of its first answer ran quiet. An answer for now
costs a check again at each step of the schedule. The import tax is
included: a loaded tax `Fails` placed the device's long buffers in fresh
pages for its life on a driver whose imports do cost (39740's
b202c-bench run: 148.6 against 121.5 us, short of its margin).

CHECK_VERSION 9 (a record may hold no answer of a check, and a `Fails` in
one is no answer). Tests: unit tests of what each answer earns, the
schedule, the quiet bounds and the record; device tests that a recorded
`Fails` is checked again and that a lifted merge answer is checked again
and comes to the answer of a device beside it, with no `Fails` recorded.
in_place_check takes its answers through `answer_next_device`, since a
record can no longer hold a `Fails` as an answer. Forced verdicts
(`SubmitChecks::force`) stand for the device's life.

With it: the drag bench reports the submission checks' answers before and after its measurements
(test only); a lifted try's count goes down by AtomicU32::try_update (fetch_update's new name).

Verified (launchreg lane, tip 942672e8cb = these three commits on development 01415e33d6):
m3-max-39884 (msi): clippy -D warnings plain, m2v_cpu_icd and m2v_gpu 0; lavapipe submit_check,
in_place_check, teardown_threads, relay_facts, fresh_pages, padding_unobserved, host_ram_dma_buf,
dma_buf_parked_images, exported_textures, icb_records_policy, pointer_residency, fast_paths,
queue_quiet and view_check 114/114; view_check_device's stand-by test 3/3. The control (the fix
without the re-check of loaded and recorded answers) fails the new device tests as meant: lavapipe
(m3-max-39818) 2 of 2, RX 550 (39863) 2 of 2, Radeon 780M (39885) the recorded-Fails test; the fix
passes 26/26 on the RX 550 and the 780M. On the 780M (39907, the fix on an earlier base) a device
made under host load answered merge Pending (one try split), then "Holds, recorded (14.4 us in one
call of 4 against 39.4 us apart)" after its re-checks, and grouped; every later device answered
Holds in 3 tries.
2026-11-17 02:01:04 -08:00
Anees Iqbal 7dcde89ddb RUNTIME 2522: a head whose line signals what another queue's head awaits takes no turn
Under the default Fair queue turns, a later command buffer of a queue sharing a
VkQueue is held for its turn while its queue's earlier one is in flight. Where
that later one signals a value another queue's held head waits for, and the
earlier one waits on the GPU for a signal the program gives only once that
waiter is scheduled (a caller's reserved signal, Event::reserve_vk_signal), the
program waited for the watchdog, where Metal schedules them all at once.

Each look now first gathers the values the line heads wait for that no
submitted signal or host set reaches (EventShared::landing), and, only where
there are any, marks each turn-taking line's head by whether a batch of its
line signals such a value for another line (one read per command buffer).
Such a head takes no turn (scheduler/mod.rs mark_awaited_signals; Held
signals_awaited); once the signal went, its line takes turns again. The
awaited values live in State and are emptied after each look, so a look
allocates nothing. queue_turns.rs gains the "Awaited signals" rule and the
FAST-PATHS queue-turns row says it.

The lane test runtime_lane::events::a_signal_another_queue_waits_for_takes_no_turn_behind_a_gpu_wait
(queue B's first command buffer waits on the GPU for a reserved gate, its second signals W=1,
queue A's waiter waits for W=1; the gate opens once A's waiter left Committed) comes with it.

Verified (evwait lane, tip b77e692259 on fe3f09f569): m3-max-39516 (msi): clippy -D warnings
plain, --cfg m2v_gpu and --cfg m2v_cpu_icd 0, rustdoc -D warnings 0, runtime unit tests
queue_turns|unshared_hold|fast_paths|scheduler|order 222/222. The lane test's before/after
on the XTX (m3-max-39536) and PHOENIX follows on development; unverified there until then.
No new Degradation kind, WorkCounts field or public signature.
2026-11-16 23:42:39 -08:00
Anees Iqbal d0714ec9a6 RUNTIME 2518: queue turns hold only a command buffer's first batch; its later batches follow
What: under QueueTurnPolicy::Fair, CommandBufferShared::held_for_turn now holds only a
command buffer's first batch (index 0). Once that one went, each later batch of it (a
command buffer splits at an event wait after its work or at a signal before more) goes as
it is ready, as Metal schedules a command buffer whole. queue_turns.rs gets a "Whole
command buffers" bullet and loses the claim that the turns add no wait that can close a
cycle; the FAST-PATHS queue turns row says it.

Why: a REGRESSION of RUNTIME 2490 (Fair, the default). A queue with no run seen keeps one
batch in flight, so a command buffer whose first batch waits on the GPU for a signal not
yet given (the caller's reserved signal, Event::reserve_vk_signal, or another VkQueue's)
had its later batch held for the turn until that first batch completed: it read
Scheduled only then, and another queue's command buffer waiting for its later signal was
held for EventValue meanwhile. A program that gives the signal once that waiter is
scheduled (Metal schedules both at once) waited for the runtime's 20.2 s watchdog, which
failed the signaller (GpuHang / victim) and recovered the device: the XTX lane's
runtime_lane::submission_checks reds. Every device whose command queues share a VkQueue
(RADV, ANV, lavapipe) takes Fair.

Verified before the fix (carried --lib gpucfg archives, alone, --test-threads 1):
development 68c456e5ba on the RX 7900 XTX (m3-max-39361) and the 780M PHOENIX
(m3-max-39362): a_submission_detached_while_a_gpu_signal_is_in_flight_fails,
a_wait_the_host_meets_is_checked_without_waiting_for_the_gpu and
an_event_wait_a_gpu_signal_in_flight_meets_is_checked_at_once FAIL (signaller Error after
the watchdog); the same tree with QueueTurnPolicy::CommitOrder (a probe, not landed):
4/4 pass in 0.1 s each on both. RUNTIME 2493 and 2503 fail alike on the XTX.

Verified after (evwait lane, tip c435183fba): clippy -D warnings on runtime + validation,
all targets, all features (m3-max-39391, msi), queue_turns + unshared_hold + fast_paths
unit tests 61/61; PHOENIX 780M (m3-max-39414): runtime_lane::submission_checks 9/9 as a
module in parallel, the three reds included (1.4-2.1 s each), and the runtime's
queue_share_device, queue_turns, scheduler_held_wakes, submission_turns and unshared_hold
tests 56/56. Clippy under the GPU cfgs, rustdoc and the XTX run follow on development.
No new Degradation kind, WorkCounts field or public signature.
2026-11-16 23:05:56 -08:00
Anees Iqbal db341427bf RUNTIME 2499: Queue turns: a held head waits for the completion that lets it go, and its bound's wake is no slice
pinreds' lavapipe counts (m3-max-38335) under Fair: submission_turns' committing-pass check had
0 completion wakes, 1 sleep slice and 1 slice rescue; grouped_submissions 4-5 completion wakes
for 6-7 turn holds and 1-2 rescues. Read, not a missed completion wake:

- A sleep the scheduler's thread ended at a held head's bound (await_room's wake_by: the time
  the oldest batch's run brings its queue's work under the budget, the turns' designed wake) was
  counted as a sleep slice and its pass as a slice rescue, though WorkCounts calls a slice the
  thread's longest wait with nothing having woken it. A bound shorter than the slice now ends
  the sleep as no slice does (short, as the idle's length before a driver's stall), on the
  condition variable and on the GPU.
- A turn-held head was gated on the oldest batch in flight, so every completion before the one
  that lets it go woke the thread to hold it again. Flight::own_ahead now gates it on the batch
  whose completion lets it go, or makes the batch of its queue whose run does so the oldest
  (turn_through), so the timer can be set then; a queue of unknown run on its first batch.
  Flight::turn adds the time another queue's last batch is 50 ms old where 2 ms holds the head
  and 16 ms would not, which the oldest's completion caught before.

Tests: queue_turns::a_held_batch_waits_for_the_completion_that_lets_it_go (the gate is the
fifth's predecessor, not each completion); the two turn unit tests' holds now carry the gate and
the quiet timer; queue_share_device's turns test asserts 0 slice rescues, at most a completion
wake per burst command buffer, and each submitted within 20 ms of the GPU end before it.

Verified (msi, at d4074ffeaa): m3-max-38421 runtime clippy --all-targets --all-features 0, unshared_hold|queue_turns 25/25, rustdoc 0, fast_paths 36/36; m3-max-38422 clippy --cfg m2v_gpu 0; m3-max-38423 lavapipe clippy --cfg m2v_cpu_icd 0, unshared_hold|queue_turns|submission_turns|scheduler_held_wakes|queue_share_device 64/64 (the turns test under Fair: 14 looks held, 0 slice rescues, 7 completion wakes for 12 command buffers, each submitted by the previous one's end). Open: validation grouped_submissions 14/15 in m3-max-38424 (a_shared_event_wait_for_a_kept_group_s_signal_ends_at_the_next_completion_turn, "Y completed before X"); its A/B against the parent (m3-max-38439, 38442) runs after the merge.
2026-11-16 17:30:51 -08:00
Anees Iqbal a55586f456 FAST-PATHS: the queue turns row's PHOENIX numbers at the landed shares fix
m3-max-38270: RADV on um790's Radeon 780M (PHOENIX), queue_share built at 037f1959bf
(m3-max-38259), frames, 5 s per run, load 1-3. Three 30 ms command buffers in flight beside a
draw every 16 ms: CommitOrder p50 71.1 ms, max 89.4 ms; Fair p50 17.6 ms, max 56.7 ms, every one
of the 313 draws run. Eight 4 ms in flight: CommitOrder p50 23.8, max 36.8; Fair p50 4.0, max
17.7, the GPU idle 1.68% against 0.08%.
2026-11-16 16:57:27 -08:00
Anees Iqbal a1ac85d9cd Queue turns: the burst probe's measurements replace the 200 ms oracle claim
cross_queue_burst_turns ran every case (m3-max-38188, 38240 on the M3 Max; 38189, 38241 on the
MacBook Pro's UHD 630 and Radeon Pro 5300M). The M3 runs a second queue's small command buffer
among a first queue's burst of 64 and beside its one 244 ms command buffer; the 5300M runs a blit
or render one among the burst but a compute one after the burst and after the long one; the 630
runs it after them in every case. The probe header records each case; the FAST-PATHS queue_turns
row, its known gap, queue_turns.rs and QueueTurnPolicy's docs said Metal ran it beside a 200 ms
one on the 630 and the 5300M, which the probe's compute one-long case contradicts, and now say
what was measured.
2026-11-16 16:57:27 -08:00
Anees Iqbal a9f42dd2f9 RUNTIME 2496: Scheduler: a committing thread leaves a VkQueue's batches to the scheduler's thread where its submit calls are slow
What: each VkQueue keeps the time of its last 15 batch vkQueueSubmit calls, whichever thread made
them, timed under the queue's lock in submit_logged (device/submit_calls.rs), and publishes their
floor, the least of them. Where that floor is 100 us or more, a committing thread's pass
(commit_and_submit) leaves the VkQueue's batches to the scheduler's thread, which it wakes at once
through the existing left_over wake, counted as LeftAtCommit::SlowCalls
(WorkCounts::scheduler_at_commit_left_slow_calls, new). Below it the committing thread submits as
since RUNTIME 2461. A thread about to wait for a command buffer still submits for itself whatever
the cost. No batch is reported as left for a host step with none due.

Why: a REGRESSION of RUNTIME 2461, which let a committing thread submit a batch that holds segments
with no host step due. On a host of unified memory every guest batch names host imports, and RADV
lists every import in each kernel submission, so on the Radeon 780M each such call took about 245 us
(p50; 394 p90), now on the guest's committing thread: the consumer measured the walk per render
encoder 84.0 -> 130.9 us and the commit call per part 19 -> 256 us, with 2461's one plain() line
undone matching the parent on every row. The cost is the driver's and the kernel's, so the decision
reads the measured call time, not a driver, GPU or memory kind. The floor rather than the median:
in m3-max-38258 a fresh lavapipe device's first calls held the median of 15 past 100 us for 14 of
200 commits while its calls then took 5.3 us at the median; load and a driver's rare long calls
lengthen calls and never shorten them, as the submission checks' floors already assume
(submit_check.rs), and the import tax this rule is for is paid by every call. Of the guest's
~290 us per inline part, ours before the call is ~43 us (~15%, the consumer's trace).

Tests: commit_and_submit::a_queue_whose_calls_are_slow_leaves_its_batches_to_the_scheduler_s_thread
(each batch call made 150 us slower through a cfg(test) hook, Device::slow_submit_calls: 0 of 40
batches at commit, 40 left for slow calls, floor 207.8 us; without the rule every batch goes at
commit); a_command_buffer_naming_host_pages_is_submitted_at_its_commit warms 15 rounds and asserts
the floor below the bound and nothing left for slow calls (200/200 at commit, floor 2.6-3.1 us).
The guest-shaped bench's SubmitCost leg puts its 250 us stand-in inside the timed call, with two
legs of the other forms (SubmitCostAtCommit, HostPagesHandedOff); on lavapipe release
(m3-max-38261) the hand-off cut the commit call 65.5 -> 8.2 us with commit -> GPU start p50 4089
against 4086 us, and a forced hand-off of the 0.4 us host-pages calls showed no start latency
(2598 against 2606 us).

Docs: scheduler module docs and plain_ready, unshared_hold.rs, commit_and_submit's doc, the runtime
README, RUNTIME-PORTING.md, FAST-PATHS.md's unshared-hold paragraph; api_signatures blessed.

Verified (msi, at f0a34f5d9b): m3-max-38277 clippy 0, lavapipe scheduler/queue/turns suites 101/102
and validation joined_completions|grouped_submissions 19/20 (the two failures fail at the base
b874899768 too, m3-max-38299: grouped_submissions::completions_wake_the_scheduler_only_once_a_head_
may_go 3/3 at both; submission_turns::a_committing_pass_ends_at_its_own_submission_handlers_grouped
1/3 at base alone); m3-max-38302 clippy --cfg m2v_gpu 0, --cfg m2v_cpu_icd 0, rustdoc 0. The 780M
before/after (m3-max-38281) and the Iris run after the merge.
2026-11-16 16:53:53 -08:00
Anees Iqbal f2367d8956 SEMANTICS 2142 / RUNTIME 2495: View facts from the device's own check: the runtime's view check, measured workarounds in the description
What: the two constant-window view cost facts no longer come from a GPU identity.
- metal2vulkan: DeviceDescription::measured (a set of DriverWorkaround, serde default) is a
  profile input: the profile takes those workarounds beside its identity's, so the fingerprint and
  every cache key follow it. The identity rows of UniformBufferPerLaneReadsSerialize (RTX 3090,
  RTX 2080, RTX 5080 Laptop) and ExternalUniformReadsSkipACache (ANV on the Iris Xe RPL-P) are
  gone, and NVIDIA_RTX_2080 with them (nothing else used it).
- The texel form now applies only to a slot with an indexed read (SlotPlan::indexed_read, from
  Provenance::indexed_constant_reads, marked on a profile with the texel fact): a slot read at
  constant offsets alone keeps its uniform buffer, whose ranges ANV pushes into registers (Mesa's
  brw_nir_analyze_ubo_ranges; read, not measured), as reims's Iris Geekbench pair 2 suggested.
  With both facts, view_kind gives a per-lane slot storage, an indexed-uniform slot the texel view,
  a constant-offset slot the uniform buffer: no conflict.
- bind::view_check_module (CheckView x CheckReads): the check's kernels, built and verified like
  any crate module (push-constant window mask, uvec4 reads, uniform / per-lane / fields).
- metal2vulkan-runtime: view_check.rs, a device check on its own thread, started as the device is
  made, once per driver + release + runtime, its medians kept in the shader cache's directory:
  8 kernels x 1 KiB / 4 KiB windows in device memory, and UBO / texel uniform reads over imported
  host pages; 7 interleaved rounds after a warm-up, medians of timestamps x timestampPeriod. Facts:
  per-lane where storage/UBO per-lane < 0.3 at both windows (NVIDIA 0.011-0.107, RADV 0.96-1.00);
  texel where texel/UBO uniform over imported pages < 0.7 at both (Iris 0.40-0.49). Unchecked
  (no fact) without timestamps or on any refusal. Device::settle_view_check, view_costs
  (ViewCosts, ViewVerdict), view_check_report.
- Timing: creation never waits. Device::compile_device returns the description's compile device
  until the check answers with a fact, then the one with the facts measured (made before the
  answer is published, held in the line's Invariant); a recorded answer applies from the first
  pipeline. pipeline::Sources reads the compile device once per creation or variant, so one
  compile and its link never straddle the answer. The runtime's own tests fix the facts
  (DeviceOptions::view_facts, cfg(test), default none) unless a test runs the check; it replaces
  compile_as.

Tests: device::tests::profile view_facts_come_from_the_measured_set_alone (no committed profile
nor the 3090/2080 IDs carries either fact by identity; each measured set its own fingerprint);
engine_lane_reads (the fact from the measured set on NVIDIA's and RADV's captures; NVIDIA
identities without it keep UniformWords; both facts compose: Storage / UniformTexel /
UniformWords); engine_access (the texel form for an indexed read, a constant offset keeps the
uniform buffer, nothing measured keeps it); bind::view_check validity on every committed profile;
runtime view_check::tests (facts on both sides of each bound, the measured GPUs' ratios, the record
round trip, the measured compile device and its fingerprint); view_check_device (lavapipe: settles
Measured with its medians, the compile device carries exactly its facts, a later device reads the
record); uniform_texels on indexed inline kernels under fixed facts.

Docs: API.md (DeviceDescription::measured, the texel form's indexed-read rule), runtime README
(the check, its cost, its verdicts, when translation takes them), FAST-PATHS known gap, api
signatures blessed, api_surface entries, REFUSALS regenerated (unchanged).

Verified so far: msi job m3-max-38239 at 5d493d44f7: clippy -p metal2vulkan -p
metal2vulkan-runtime --all-targets --all-features -D warnings CLIPPY=0.

With it (folded): View check: the inline kernels' module metadata llvm-as takes; the windows' descriptor alignment checked

The engine_access and uniform_texels inline kernels named llvm.module.flags and air.version with
the version tuples of air.version and air.language_version, which llvm-as rejects (msi job
m3-max-38254: engine_access's texel test panicked in assemble_text). The view check refuses a
window or out buffer whose VkBuffer offset lies off 256 bytes, the most any descriptor offset
alignment Vulkan bounds may ask, rather than write such a descriptor.

Verified: m3-max-38239 (msi) at 5d493d44f7: clippy -p metal2vulkan -p metal2vulkan-runtime --all-targets --all-features 0. m3-max-38262 at f941e38fab: clippy --cfg m2v_cpu_icd (runtime) 0; lavapipe 21/21 (uniform_texels, uniform_bind_offsets, view_check_device, view_check unit tests); lavapipe verdict Measured, no facts (per-lane storage/UBO 1.17-1.44, texel/UBO over imported pages 1.99-2.30, fields texel/UBO 1.99-2.09; the check took 267-487 ms; a second device read the record). m3-max-38254 at 46e4aaab03: translator 146/147 (engine_access's inline IR, fixed in the second commit). clippy --cfg m2v_gpu, rustdoc, the translator rerun and the device verdicts (2080, 780M, XTX, 3090, Iris) run after the merge.
2026-11-16 16:42:53 -08:00
Anees Iqbal c62128b564 RUNTIME 2493: Queue turns: a run several batches were seen complete in shares in proportion to their expected runs
What: unshared_hold's flight split a completion's run equally among the other queues' batches seen
complete in it. It now shares the run in proportion to each batch's expected run at its submission
(unshared_hold::Shares): a light batch seen complete with a long one keeps a light run, the long one
its own. Batches of queues with no run seen take the run beyond the others' expected runs, an equal
part each, at least 1 ns; when every batch is of unknown length they share it equally, as before.
Equal expected runs split as before, so the unshared hold's tests keep their numbers.

Why: a REGRESSION of RUNTIME 2490's Fair default. Under QueueTurnPolicy::Fair a compositor's plain
queue takes such a share: its light draw, seen complete together with the application's 30 ms
command buffer it waited behind, got half the run, about 15 ms, as its queue's expected run. With
2 ms of its own work allowed in flight, one draw in flight then held the next until that draw
completed, behind the application's next batch: one draw per application batch. On RADV PHOENIX
(m3-max-38213, frames, a draw every 16 ms beside three 30 ms command buffers in flight) the
compositor fell 2 s behind (p50 1192 ms, max 2062 ms, against CommitOrder's 77.8 and 106.3 ms).
2 ms stays the budget: 4 ms was worse for the compositor in both shapes measured.

FAST-PATHS: the queue turns row says how a grouped run is shared, and that the Macs disagree on
bursts (cross_queue_burst_turns: the M3 Max ran a second queue's small command buffer ahead of 56 to
62 of a first queue's 64; the UHD 630 after 60 to 63 of them; m3-max-38188, m3-max-38189).

Tests: queue_turns::a_light_batch_seen_complete_with_another_queue_s_long_one_keeps_its_light_run
fails under the equal split (the compositor's next draw is held);
a_batch_of_unknown_length_takes_the_run_beyond_the_others_expected_ones.

Verified (msi, at 7f6f9c4c6b): m3-max-38234 runtime clippy --all-targets --all-features 0,
unshared_hold|queue_turns 24/24, fast_paths 36/36, rustdoc 0; m3-max-38235 clippy --cfg m2v_gpu 0.
Lavapipe clippy and the queue_share_device / scheduler_held_wakes device tests (m3-max-38236) and the
PHOENIX rerun of both shapes run after the merge.
2026-11-16 16:33:21 -08:00
Anees Iqbal c091862da8 Fair queue turns: the FAST-PATHS row's measured lavapipe numbers; the queue_share example's --fixture
The lavapipe test of both QueueTurnPolicy values (job m3-max-38162, msi, load 7.32): twelve
command buffers of one queue committed at once, each about 37 ms there, and a small one of
another queue committed after the first was scheduled. Fair: the small one's GPU run started
37.5 ms after its commit, between the burst's first and second (14 looks held, 5 let go under
the idle budget). CommitOrder: 454.8 ms after, behind all twelve (0 held).

Verified: m3-max-38177 (msi) at c46daf583b: clippy -p metal2vulkan-runtime --all-targets --all-features -D
warnings 0 (compiles the example); nextest -p metal2vulkan --all-features fast_paths 36/36. The numbers:
m3-max-38162 (msi lavapipe, load 7.32): under Fair the small command buffer's GPU run started 37.5 ms after
its commit, between the burst's 1st and 2nd (14 looks held, 5 let go idle); under CommitOrder 454.8 ms,
behind all 12 (0 held).
2026-11-16 16:08:15 -08:00
Anees Iqbal 2911334351 RUNTIME 2491: A discrete host's small Managed ranges go to the GPU inline in the command stream
WIP: the mechanism, the counter, tests and bench; the bound and docs follow.

Measured bound (managed::INLINE_BYTES = 16 KiB; release managed_inline_bench, 200 one-dispatch command
buffers, p50 GPU us, copy against inline): RX 7900 XTX (m3-max-38126) 64 B 11.7-11.8 vs 10.2-10.3, 4 KiB
12.2-12.3 vs 11.0, 16 KiB 13.8-13.9 vs 11.0-11.1, 64 KiB 20.8-20.9 vs 11.2; RTX 2080 (m3-max-38161) 64 B
36.4-37.0 vs 31.1-31.6, 4 KiB 38.5-39.1 vs 31.7-32.3, 16 KiB 44.7-45.4 vs 39.4-39.9, 64 KiB 69.5-70.0 vs
70.5-71.0 (inline loses). Unaligned ranges keep the copy: widening them would put the host copy's bytes
over GPU writes beside the range. New WorkCounts::managed_ranges_inlined. RUNTIME_VERSION 2491.

Verified: msi m3-max-38118 at 7094cdbcd3: clippy -p metal2vulkan-runtime --all-targets --all-features -D
warnings plain 0 and --cfg m2v_gpu 0; 5f78fe489a compiled in m3-max-38132. managed_inline (bytes at 4 B,
B, B+4, 65540, unaligned ranges, a range named twice, GPU-filled neighbours kept, bound 0 the negative
control with 0 inlined) plus the Managed, host-RAM and copy suites: 61/61 on the XTX (m3-max-38126) and
61/61 on the 2080 (m3-max-38161). Lavapipe has unified memory, so it never takes this path. The 3090
bench and --cfg m2v_cpu_icd clippy and rustdoc follow.
2026-11-16 16:02:43 -08:00
Anees Iqbal 8f1e4157d8 RUNTIME 2490: Command queues sharing a VkQueue take fair turns: a queue's own work in flight there is bounded
What: a new DevicePolicy field, queue_turns. Under QueueTurnPolicy::Fair (the
default), on a VkQueue that two or more command queues hold, a batch of a queue
not made unshared goes only while less than 2 ms of its own queue's expected GPU
work is in flight there (16 ms while no other command queue took a batch there
within 50 ms); else the scheduler holds it in its place (HeldFor::QueueTurn) and
a later commit of another queue that shares nothing with it goes first.
QueueTurnPolicy::CommitOrder keeps the old behaviour: every ready batch at once,
in commit order. exact_answers() keeps Fair.

Why: on a device with one graphics VkQueue (RADV, ANV, lavapipe, Intel's Windows
driver) every ready batch went to the VkQueue at commit, so a command buffer a
second queue committed after one queue's burst (a long command buffer cut into
parts, a backlog of frames) waited for the whole burst. The unshared hold
protected only queues made unshared, and released the other queues' held
batches in commit order, so a later plain queue still waited behind the whole
burst, only paced. Metal ran a second queue's small command buffer beside a
first queue's 200 ms one (the consumer's oracles, UHD 630 and 5300M).

How: the VkQueue's flight (unshared_hold.rs) now counts each plain queue's
batches in flight and the latest two submitting queues; Flight::own_ahead
prices each of a queue's batches at its expected run now (a longer run prices
the rest of a burst at once), credits the running oldest only where it is the
queue's own, and holds a queue with no run seen to one batch. Under Fair every
batch enters the flight. The scheduler's look holds a head for its turn beside
the unshared hold (same gate and timer wake, await_room); a committing or
waiting thread's pass leaves such a head to the scheduler's thread
(LeftAtCommit::Turn). New counters: heads_held_for_queue_turns,
heads_let_go_turn_idle, scheduler_at_commit_left_turns. Unshared queues are
never held for a turn. FAST-PATHS gets the row; its known gap now says what
remains (a submitted batch runs to its end).

Tests: tests::queue_turns (the flight's turn math: two budgets, a later queue
not held by another's burst, repricing against the unshared bound, no run seen,
the oldest's credit, published completions); the existing unshared_hold unit
tests on the new flight API; queue_share_device::
a_later_queue_s_command_buffer_takes_its_turn_ahead_of_another_queue_s_burst on
a device under both values (Fair: the small one before the burst's fourth, heads
held; CommitOrder, the negative control: after the twelfth, none held);
fast_paths' ledger choice, keys-no-profile and exact_answers tests. API
signatures blessed; REFUSALS.md unchanged.

Also: the queue_share example's --turns fair|commit-order; the conformance probe
cross_queue_burst_turns.m (not yet run); the queue-sharing and unshared-hold device tests pin
CommitOrder so they keep testing their own mechanism. Public: QueueTurnPolicy::{Fair, CommitOrder},
DevicePolicy::queue_turns, WorkCounts::heads_held_for_queue_turns / heads_let_go_turn_idle /
scheduler_at_commit_left_turns. Default Fair per the owner's 11-03 decision (isolation outranks peak
rate); CommitOrder is today's behaviour. RUNTIME_VERSION 2490.

Verified: m3-max-38127 (msi, 37143cedda): clippy -p metal2vulkan -p metal2vulkan-runtime 0; fast_paths,
api_surface, api_signatures 51/51; queue_turns, unshared_hold, queue_share unit tests 32/32. At
079c3b7635: m3-max-38140 workspace clippy 0, rustdoc 0; m3-max-38142 --cfg m2v_gpu clippy 0;
m3-max-38141 (lavapipe) --cfg m2v_cpu_icd clippy 0, queue_share_device + queue_turns + unshared_hold +
scheduler_held_wakes 47/47: a_later_queue_s_command_buffer_takes_its_turn_ahead_of_another_queue_s_burst
passes under both values (Fair: the small CB starts before the burst's 4th, held > 0; CommitOrder, the
negative control: after the 12th ends, held 0). The 780M numbers for the row follow.
2026-11-16 16:01:06 -08:00
Anees Iqbal d8b39b12d1 SEMANTICS 2141 / RUNTIME 2481: Read short constant windows through uniform texel buffers on the Iris Xe
What: on a device whose profile takes the new cost fact
DriverWorkaround::ExternalUniformReadsSkipACache (ANV on the Iris Xe of
RPL-P alone), a buffer slot's uniform view whose window the translation
bounded to at most TEXEL_WINDOW_BYTES (4 KiB) is declared as a uniform texel
buffer (UniformConstant image, Dim Buffer, Sampled 1, u32 texels) and read with
OpImageFetch; the plan's form is DescriptorView::UniformTexel, its descriptor
UNIFORM_TEXEL_BUFFER, its use class Sampled, its range the uniform view's own
under minTexelBufferOffsetAlignment and maxTexelBufferElements. Every other
uniform view stays a uniform buffer exactly as before. The runtime makes an
R32G32B32A32_UINT view of the planned range for each write, with no cache,
holds it until the command buffer completed (State::retain_own, which also
keeps an indirect chunk that made one from being kept), and binds whole a draw
rebound or carried at such a slot. The zero buffer takes the uniform texel
usage, and upload regions align to the texel offset alignment too.
ARTIFACT_FORMAT_VERSION 525 (DescriptorView gains a variant); SEMANTICS_VERSION 2141, RUNTIME_VERSION 2481.

WorkCounts: uniform_texels_bound; uniform_buffers_bound_to_16k (a bound
buffer's uniform view written as a uniform buffer, window at most 16 KiB: on
the Iris the 4-16 KiB ones); uniform_buffers_bound_past_16k (longer, or not
bounded).

Why: ANV gives external memory MOCS 61 on Gen12.0, which loses the HDC L1
that uniform buffer reads go through; the sampler path keeps its cache. On the
Iris, a UBO over imported memory ran 2.0-2.5x (and 5.2-5.5x for a divergent
index) the time of device memory, a uniform texel buffer 0.98-1.04x (jobs
m3-max-37703, 37729). The window sweep (37753, 37780) set B: at 1 and 4 KiB
texel-set was no slower than ubo-set on device memory in every pattern; at
16 KiB one row was 3.1% slower; from 32 KiB per-lane patterns 2.8-4.2x.

B = 4 KiB covers the consumer's binds only where the kernel's window (its
struct size or accessed hull) is at most 4 KiB. The counting walk counted
buffer sizes, not windows, so the new counter will tell.

The cost of a view per write: vkCreateBufferView+vkDestroyBufferView 0.082 us
on the Iris (mean of 4000), vkUpdateDescriptorSets 0.007 us against a uniform
buffer's 0.024. A set 0 naming a fresh view is found again by no later
command, so such commands lose set-0 reuse.

Tests: engine_access (the texel form's module, its interpretation at
residuals 0, 4, 16 and 256, the window bound, the slot's plan), the profile
fact's carriers, and a lavapipe test whose compile device takes the Iris's
identity (cfg(test) DeviceOptions::compile_as): offsets 0, 4, 16, 256, 260,
set*Bytes data, bytes written before encoding, after it and by a blit, and a
4100-byte window kept as a uniform buffer, with the counts as evidence.

Also: the fixture uniform_texel_windows's AIR companions (job m3-max-37901); a texel form's
loop-invariant fetches move out of their loops as a uniform block's loads do (spirv::hoist, with
its test); the texel form documented (ARCHITECTURE, FAST-PATHS, view docs, runtime README); the
API signatures blessed.

Verified: msi job m3-max-37946 at 00121399e7: fmt check 0, clippy (plain, --cfg m2v_gpu,
--cfg m2v_cpu_icd; --all-targets --all-features -D warnings) 0, rustdoc -D warnings 0. Touched
suites running in the same job. Golden table and engine fixture inventory re-bless on development.
2026-11-16 14:46:29 -08:00
Anees Iqbal 35ac917d6f RUNTIME 2466: GPU start: written before the batch's first work, and at the top of the pipe on every driver
What: a timed command buffer's first batch with first work (new resources'
first moves and zero fills, Managed copies in, staged copies) writes its start
timestamp in that work's command buffer, after an execution barrier from every
command before and before the work; and every start is written at the top of
the pipe, where batches ordered by their ends wrote it at the bottom.

Why: GPUStartTime must say when the GPU began the command buffer's work. In a
traced Geekbench-like compute pass on an RX 7900 XTX (RADV, Mesa 26.2.6), the
gfx ring's drm_sched jobs placed on the trace's clock (the job trace drifts
39.8 ppm against it, fitted per pass) showed command buffers whose start lay
in the last tenth of their own job: spans of 1 us on jobs of 4.5 to 36.5 ms.
Two causes. (a) The first work is inserted ahead of the start, and the start,
at the bottom of the pipe under by-ends ordering, waited for it: managed copies
in of the guest's did_modify_range ranges were 0.25 to 6.98 GB per workload.
(b) With no first work too (prefixed starts, 237 first-work batches of 7486),
about 1700 command buffers read their bottom-of-pipe start late; a Radeon 780M
showed the same. That GPU time counted as "submitted, GPU not started" in the
consumer's split: 4.06 s of its 5.90 s on the XTX.

Ordering (every driver path): the first work's start follows an execution
barrier ALL_COMMANDS -> ALL_COMMANDS, whose "first synchronization scope
includes all commands that occur earlier in submission order" and "second
synchronization scope includes all commands that occur later in submission
order" (vkCmdPipelineBarrier), the timestamp write among them. A start at the
top of the pipe where batches are ordered by their ends is held by the earlier
batch's end barrier, Barrier::to_all (src ALL_COMMANDS, dst ALL_COMMANDS and
HOST), by the same clause. Where batches are not ordered by their ends the
starts were at the top already and are unchanged; a start after a barrier
planned before the first encoder stays at the bottom, after that barrier.

Whether Metal's span holds a Managed copy in on a Mac with a discrete GPU is
not measured (the 5300M oracle can say).

Verified: compile and device runs pending (tests/start_stamp.rs).

Also folded: the test of a command buffer's GPU start against its own long work and its batch's
first work (e86e9d356e).
2026-11-16 10:17:56 -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 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 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 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 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 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 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 8562b28fe4 RUNTIME 2446: Shadows: a split merge on the host copies no piece; its kernel skips their columns
A merge on the host past shadow_merge::HOST_WHOLE_BYTES split: its host
step stored the pieces of each row in lines beside the texels, and its
kernel the rest. To keep the kernel off those lines, the GPU copied the
pieces' kept bytes into an arena region and their changed bytes over
them in the kept part: two vkCmdCopyBuffer calls of one region per
piece. On the Iris Xe (ANV) that work cost about 7 to 9 us a region,
growing with the rows, not the bytes: about 0.6 ms for 34 rows
(m3-max-35898) and about 15 ms for 1024 (m3-max-36118: a BGRA8 1023x1024
render target over host pages drew in 17.57 ms a command buffer as a
shadow against 1.26 ms in place, its host step 0.28 ms of it).

Now the kernel takes a column window (bind::ShadowMergeModule: two more
push words, PUSH_BYTES 24; shape_within, shape the whole row): a word
outside the columns is neither read nor written in either store form,
and counts as unchanged in its block. A split merge pushes the words
between each row's pieces where every row's pieces lie at the same
places in it (shadow_merge::columns: whole words, the same head and tail
each row; rows whose pitch is no multiple of the line differ, and those
merges go on the host whole). It records the changed copy and its
dispatches alone, with no save, no mask, two fewer barriers and no arena
region; the host step reads each piece's kept and changed bytes in the
scratch's two parts, which nothing writes after the changed copy.
Removed: HostMerge::saved, ShadowMerge::saves, ShadowCopy::merge_saves,
the merge's region in EncoderCore::merge_on_host, MergeDrain::_region,
and the split's copy uses of the kept part. The bound stays 1 MiB; its
doc comment states the measured costs. Linear merges push the whole row.

Tests:
- bind::shadow_merge's
  a_region_merged_within_columns_leaves_the_words_outside_them: 70 rows
  of 6 words, columns 1 to 4, every word changed; words outside the
  columns keep the current buffer's, in both store forms, and a window
  of every column equals shape.
- shadow_runs' merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it
  also asserts shadow_merge_words_examined: every word of the whole
  merge's rows; for the split, the words between each row's pieces
  alone (height * (row bytes - line) / 4).
- shadow_write_lines' cost test gains a 4K shape: 3839 RGBA16Float texels
  a row, 2160 rows 30720 bytes apart.

The merge module is under no golden table (golden_hashes covers the
fixtures' translations). api_signatures: PUSH_BYTES, shape, and the new
shape_within. Degradation kinds added: none.

Landing note: msi m3-max-36189 at 4b09425f2d (same tree): clippy metal2vulkan + runtime, all targets and features, CLIPPY=0. The API tables, the module tests, rustdoc, clippy m2v_gpu / m2v_cpu_icd, the lavapipe control (development's whole-row kernel fails the split test's words-examined count) and the touched suites, PHOENIX and the Iris re-time follow on development.
2026-11-16 04:32:27 -08:00
Anees Iqbal 7fa39e82e5 RUNTIME 2445: Scheduler: a committing pass that ended at its own handlers wakes the scheduler's thread before running them
What: where a commit_and_submit pass ends right after its own command buffer's last batch with
batches left, it marks the state for the thread's pass (State::dirty) under the lock. Right after
the lock is free, before the completion turn it owes and before its handlers, the committing
thread wakes the scheduler's thread (wake_thread, Woken::Host). That pass reports no left_over,
so the end of submit_at_commit does not wake the thread again; passed_over() is still checked.
The thread passes while the committing thread runs its handlers; the batches it submits take
later Turns tickets, so their handlers still run after the committing command buffer's.

Why: in PHOENIX m3-max-36098 (the guest-shaped SubmissionHandlers leg after RUNTIME 2442), the
time from an early end to the next kernel submission made by the scheduler's thread was
p50 27 / p90 278 / p99 986 / max 1273 us (212 samples). The left batches waited for the
committing thread's handlers and the wake after them. The usual wake (wake_for, inbox.nudge)
skips the wake while the committing thread is still counted as the passer, and pass_once_then
never looks again. The scheduler's thread is never gated by a counted passer: it waits only for
the lock.

Tests: submission_turns' a_committing_pass_ends_at_its_own_submission_handlers_{exact,grouped}
now let the scheduler's thread go once the committing command buffer's handler has started. That
handler waits, up to two seconds, for the three later command buffers' submissions
(CommandBuffer::submit_returned_time), and all three are made before it ends (none without the
wake). The handler-order assertion stays. The test's messages lose the runs of spaces an edit
left in them.

The check also requires no sleep-slice rescue (WorkCounts::scheduler_slice_rescues moves by 0): the first control with the wake removed (ctl/complat2f 86baad51c4, lavapipe m3-max-36134) passed the timed check, because a 100 ms WAIT_SLICE let the left batches go within the handler's two-second bound.

Verified: msi m3-max-36132 at 46c7eedd4a (product code as landed): build, runtime clippy plain and --cfg m2v_gpu, unit, sigs EXIT=0. The tightened check at the tip and its control (m3-max-36157), the suites, clippy x3, rustdoc and the PHOENIX legs (m3-max-36158) follow on development.

Degradation kinds added: none.
2026-11-16 04:10:27 -08:00
Anees Iqbal c602b94223 RUNTIME 2444: Host pages: remove the lend of free padding to the copies; such render targets are shadows
What: a texture that renders over host pages whose rows end inside a line, with
free padding, whose renders failed, no longer takes its image in place when the
class's copies failed too. Removed: in_place::lent_to_copies and lends, the lend
branch in in_place() (it now asks each access's own verdict and nothing else),
unlent_words and the shadowed-texture notice words it added,
degrade_line_write_back and line_write_back_reason, the storage form move's lend
count and notice, Degradation::LineWriteBack ("line-write-back") with its
docs/API.md catalogue entry, the device test lent_dma_buf_targets, and the
validation lane's LINE_WRITE_BACK list. copies_verdict stays: through
InPlaceChecks::decided it now decides only whether a shadow's copies back and
merges into such pages are spliced (shadow_splice::splices). FAST-PATHS's
host-pages row and the Iris known gap are edited in place.

Why: the lend loses CPU writes Metal keeps. Both Macs kept render padding over
buffer rows (m3-max-35486 and 35487: clear-and-store and draw changed 0 bytes;
only the UHD 630's kernel changed any), and the lend's render passes write the
rows' last lines back whole on the Iris. Its stated reason was that the shadow
lost the same bytes. That no longer holds: the shadow splices its copies back
and merges on the host on such devices, and on the Iris (m3-max-35898) its
clears and draws put back 0 bytes against the copy control's 5,941 in 300
rounds. Under the user's contract rule a form that loses writes Metal keeps is
deleted, not kept behind a switch.

Guest cost, bounded by counts: the guest's Iris Forward+ boot (reims run 35408
at 44505b3807) lent nothing (line-write-back 0); its 57 shadows are IOSurface
planes.

Tests: the in_place unit tests now assert a render target over free padding is
a shadow by its renders' verdict whatever the copies say, and that a copy back
splices by the crossed copies' verdict; the decision's model in
the_decision_takes_a_texture_whose_class_passed_each_of_its_accesses asks each
access's own verdict, the first that did not pass naming the shadow. The validation lane's render-target test
asserts in place exactly where renders passed.

Degradation kinds removed: LineWriteBack. Added: none.

Landing note: lavapipe m3-max-36064 at 5b9af90e0a: CLIPPY=0, API=0 (15/15), RUSTDOC_RT=0, CLIPPY_GPU=0, CLIPPY_CPU=0; holds 2/2; suites 641/641; validation 33/33 (IN-PLACE-FREE: both render targets shadows, 0 padding bytes changed). PHOENIX m3-max-36117 and the Iris page-short timing (in place against the shadow per import, m3-max-36118) follow on development.
2026-11-16 03:56:47 -08:00
Anees Iqbal 3348b469c2 RUNTIME 2442: Scheduler: a committing pass ends right after its own command buffer's last batch where that one has submission handlers
What: where a commit_and_submit pass submits its own command buffer's last batch and that command
buffer has submission handlers, the pass ends there. It takes no check, and leaves whatever else
is ready to the scheduler's thread, which the committing thread wakes as before (left_over ->
Woken::Host). The committing thread then runs its own handlers once the lock is free, before any
later batch's submission. New WorkCounts::scheduler_passes_at_commit_ended_early counts the
passes that so ended with batches left. A test-only hold point, trace::Point::AtCommitPass, comes
before a committing thread's pass.

Why: PHOENIX m3-max-35993 (the guest-shaped submit-cost leg, a trace of Turns waits by the
holder of the ticket waited behind) found one kind of wait. A segment that a committing pass
handed off waited behind that pass's own ticket: 0.12 a frame, p50 3449 us, max 4586 us. The
handler runs only after the pass's later submissions, which are costly in that leg. Every
segment after it in the one hand-off context waited too: submission return to own handler
p99 3410 us on the handler threads. The scheduler's handed segments never waited in Turns, and
committing threads never waited behind handed segments.

Tests: submission_turns' a_committing_pass_ends_at_its_own_submission_handlers_{exact,grouped}.
The scheduler's thread is held after a pass. A commit_and_submit is held before its pass while
three ready command buffers are committed after it: one on another queue, one behind it on its
own, one behind the first on the other. Its handler runs inside its call with one kernel
submission made (without this change, after all four). The pass submitted one batch and counted
one early end. The handlers run in submission order, each queue's in commit order.

Verified: msi m3-max-36060 at 0c131eff3a: build, runtime clippy plain and --cfg m2v_gpu, unit, sigs EXIT=0 (api_signatures: WorkCounts::scheduler_passes_at_commit_ended_early). Control m3-max-36061 (early return removed, lavapipe): both checks FAIL under Exact and Grouped ("submitted 4 batches, ended early 0; handlers ... [ours 4, ...]"); the other 12 submission_turns tests pass. Lavapipe suites, clippy x3, rustdoc and the PHOENIX submit-cost leg (36069) follow on development.

Degradation kinds added: none.
2026-11-16 03:41:06 -08:00
Anees Iqbal f3390be7f0 RUNTIME 2441: Scheduler: a committing thread's pass keeps only its own command buffer's submission handlers; gated completions post with one look
What: commit_and_submit's own pass (and the pass the lowering thread makes for one left for a
render encoder's end) keeps inline only its own command buffer's submission handlers, which run
on the committing thread inside the call, in their turn, as before. Every other command buffer's
handlers whose last batch the pass submits go to the device's handler threads right after that
submission, as one segment with its Turns ticket; the committing command buffer's ticket is taken
as its batch goes, so submission order holds. Both of submit_plain_ready's places that take
handlers (a submitted last batch and one held in the group) go through keep_or_hand_off.

A transition to Completed or Error whose transition to Scheduled is still owed is posted behind a
gate only where its submission handlers have not run (gate_for_handlers); otherwise plainly. The
gated post pushes the item behind the gate and opens the poster's closing under one lock with one
look for a thread (Contexts::post_gated), where post_behind and open made one each. FAST-PATHS
records the hand-off's own cost (19.1 wakes a frame).

Why: on PHOENIX, in the guest-shaped submit-cost leg after the scheduler-pass hand-off
(RUNTIME 2437), a submission's return to its own handler was p50 991 / p99 5231 us where a
committing thread ran it (978 handlers), against p99 380 on handler threads: a committing pass's
handlers waited for the rest of that pass's submissions. The gated post's second look for a thread
cost 4.4 wakes a frame.

Tests (submission_turns): a_committing_pass_keeps_only_its_own_submission_handlers_{exact,grouped}
(fails at control C2 m3-max-35888, the hand-off reverted: the earlier command buffer's handler ran
on the test thread); a_gated_completion_is_posted_with_one_look_for_a_thread_{exact,grouped} (fails
at control D m3-max-35877, post_behind + open: [(true,2)] against [(true,1)]). The check takes the
device's queue plan.

Verified: msi m3-max-36014 at bd810397db: build, runtime clippy plain and --cfg m2v_gpu, unit
44/44, sigs, lavapipe suites 126/126 (encoder_holds TextureWrite passes). Workspace clippy x3,
rustdoc and lvpval 30/30 at the pre-rebase tip 2d09ed2392 (m3-max-35927). PHOENIX m3-max-35923
(suites at df21628b0f): handler-thread wakes per frame 50.2 -> 48.37 (post_behind + open 8.9 ->
post_gated 6.72); seen to seen-handler p50 11, p99 3658 us.

Degradation kinds added: none.
2026-11-16 03:21:03 -08:00
Anees Iqbal 528379dad5 RUNTIME 2439: Merge on the host whole up to 1 MiB of rows; count host steps
On the Iris Xe (RPL-P, ANV) the split merge's own GPU work (two buffer
copies of the pieces beside the texels, three barriers and the kernel's
dispatch) cost about 0.6 ms a command buffer for the guest's 34x34
RGBA16Float target (m3-max-35898: draw minus clear 0.69 ms, against
0.10 ms when the merge went on the host whole), while the host step's
word loop costs about 0.30 ns a byte (4.97 ms for a 1920x1080 target's
16.6 MB, half its texels changed). So the split pays only past about
2 MB of rows.

A merge on the host whose cut rows hold at most HOST_WHOLE_BYTES (1 MiB,
half the break-even) now goes on the host whole again; larger ones
split. A merge none of whose rows' lines holds a byte beside its texels
still goes by its kernel alone, as on any device. The whole merge is
also the exact form for the unmeasured case (a CPU write to a texel the
commands left in a line whose other bytes they changed), so the known
gap now applies only where the kernel stores: past the bound, and where
no row's line holds a byte beside the texels. Both forms keep the
measured padding contract, so there is no switch and no FAST-PATHS row.

WorkCounts::shadow_host_steps counts the host steps that ran for
encoders' copies back spliced and merges on the host: against
command_buffers_submitted, the GPU-to-CPU round trips a command buffer
pays, for a walk to read before any deferral of them.

Tests:
- shadow_runs::merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it:
  over pages 16 bytes into a page, a 512x512 BGRA8Unorm target (1 MiB
  of rows) compares every byte of its rows on the host, and a 512x513
  one each row's first and last lines alone; each one host step.
- shadow_write_lines: the contract test's draw merges now compare every
  byte of their rows; the cost test alternates its verdict arms round by
  round, so clock drift and order weigh on both alike (the 1080p gap
  35898 showed, equal in Clear and Draw, with the same work recorded in
  both arms by every count); a new test prints, for a render target
  whose rows end a texel short of a 4096-byte page (1023x256 and
  1023x1024 BGRA8Unorm), under the device's own check and default
  policy, over pages imported by pointer and as dma-bufs: every host-page
  class's renders and copies verdicts for those row ends and its memory
  flags, the form the texture takes with its notices, and the median per
  command buffer of a clear-and-store and of a draw.

Degradation kinds added: none.

Verified: msi m3-max-35933 at f763e15338 (same tree): CLIPPY=0, CLIPPY_GPU=0, API=0 (15/15), release archive built. PHOENIX, lavapipe and the Iris run follow on development.
2026-11-16 02:57:29 -08:00
Anees Iqbal 438fdd4eee RUNTIME 2438: Merge on the host only the lines beside a texture's texels
A shadow's merge in place into host pages, on a device whose stores
write back the lines they end in (the Iris Xe under ANV) or whose check
has not answered, went on the host whole: the host step compared and
stored every byte of the merge's rows. On the Iris that cost 12.7 ms a
merge for a 1920x1080 RGBA16Float draw (17.7 ms a command buffer
against 3.7 ms by the GPU kernel), and the guest's scene has about 73
such shadows.

The merge now splits as the splice of a copy back does:

- Its kernel stores the changed words of each row's bytes in the lines
  that hold the texture's texels alone (ShadowMergeStores::Words, never
  whole blocks).
- The host step merges only each row's bytes in the lines that also
  hold a byte of no row of the texture's: the bytes between the rows and
  around them (shadow_splice::beside_texels; at most a row's first and
  last line).
- Before the kernel the GPU copies those pieces' kept bytes into a
  region of the command buffer's arena, then their changed bytes over
  them in the kept part, so the kernel finds them unchanged and stores
  none of them; the host step compares the region's bytes with the
  changed part's.
- The host step compares 4-byte words and stores a changed word with one
  AtomicU32 store (the changed word where all four bytes differ, else
  the word as it holds it with those bytes changed, as the kernel's
  Words form does); bytes outside whole words go one by one.
- A merge none of whose rows' lines holds such a byte (rows that start
  and end on lines, as the 1920x1080 plane's 15360-byte rows do) goes by
  its kernel alone, with its fetch view and kept image where it has
  them. A merge not cut to its texels' rows stays on the host whole.

The measured contract is the padding: row_padding_writes found the M3
Max, the 5300M and the UHD 630 keeping CPU writes to the bytes between
and around a texture's rows under clears, stores and draws, and over
IOSurfaces under kernels. No probe measured a CPU write to a texel the
commands left inside a line whose other bytes they changed, while the
command buffer runs; the kernel now stores into such lines, so that
write may be put back on the Iris. FAST-PATHS's known gaps record it,
beside the measured contract.

WorkCounts::shadow_merge_bytes_on_host counts the bytes the host steps
compared. Buffer::own_pages_flags gives a buffer's memory type flags,
which the cost test prints for a buffer made as the host scratch is,
beside the host loop's time over plain heap memory and over that
memory (1920x1080, half the texels' red and blue changed).

Tests:
- tests::shadow_splice (pure): the pieces equal the rows' bytes in
  lines beside the texels, found byte by byte, over 9 shapes and 6 page
  phases (wrapping among them); the host loop stores the differing bytes
  alone at every alignment.
- tests::shadow_write_lines: each draw merge's host step compares 16
  bytes a row (the row's last texels, in its padding's line); the cost
  test's 1920x1080 draw no longer merges on the host.
- tests::shadow_runs: the rebind test of host merges puts its pages 16
  bytes into a page, so every row's first and last lines hold bytes
  beside its texels, and asserts the bytes compared (a line a row).

Degradation kinds added: none.

Also (65db6f5b40): the old device-local query, left with no callers, is gone; the probe prints
the scratch's memory flags by name.

Verified (fplend): msi m3-max-35872 at a5289d8132 (same tree as 65db6f5b40): clippy 0, clippy
--cfg m2v_gpu 0, api_signatures + api_surface 15/15, debug and release archives built; 35850:
tests::shadow_splice 5/5 (host pieces against a byte-by-byte answer over 9 shapes x 6 page
offsets; the CPU word loop at every alignment). PHOENIX, lavapipe, rustdoc and the Iris run follow.
2026-11-16 02:29:15 -08:00
Anees Iqbal 2feb4e70f1 RUNTIME 2437: Scheduler: hand a pass's submission handlers to the device's handler threads as it goes on
What: the scheduler thread's passes no longer run the submission handlers of the command
buffers they submit (or hold in a group, or make Scheduled behind a host step) at the end of
the pass. Each time the pass is about to look for its next batch, it hands the handlers taken
so far, as one segment with its Turns ticket, to the device's handler pool (one context of the
"metal2vulkan-handlers" threads, made at the first hand-off), and goes on submitting. The
segment runs there in its turn, so submission order holds across passes and with
commit_and_submit's own pass, which still runs its handlers inside the call on the committing
thread. A pass that settled a switch of storage forms keeps the handlers it took from then on
and runs them itself after the switch ended, as before, since the switch must end before those
command buffers are Scheduled.

The blocking wait in run_scheduled (a Finished that found Scheduled owed waited on a pool
thread for the submission handlers) is gone: such a Finished is posted behind a context gate
(finish_after_handlers), its place kept, holding no thread, and the thread that ran the
handlers opens the gate; the Finished then runs the owed Scheduled first. So no handler thread
waits for a submission handler, and the pool's cap cannot be exhausted by such waits.

A held group is cut short for another queue's submission handlers (Alone::Handlers) only where
the pass keeps them (a settled switch): handed-off handlers hold back no pass.

Why: in the guest-shaped submit-cost leg on PHOENIX, a command buffer's submission handlers
started 1683/5299/5776 us (p50/p99/max) after its own vkQueueSubmit returned, behind the rest
of the pass; 4561 of 5280 command buffers were seen complete before their own submission
handler ran, and seen -> seen handler was 1.4 ms p50 / 5 ms p99 against Metal's 0.28 ms p99.

Tests: submission_turns gains a_pass_s_submission_handlers_run_while_it_goes_on_{exact,grouped}
(a handler of an earlier submission starts before the pass's later submission returns plus the
pause) and completions_before_their_submission_handlers_hold_no_handler_thread_{exact,grouped}
(6 queues with owed Scheduled on a pool of 2 threads, all complete within a bound; test hook
contexts::TEST_LIMIT). waiter_submits::Held now holds the scheduler thread with a test hook
after the pass that handed off its command buffer's handler (trace::hold_after_hand_off,
Point::HandedOff), since a submission handler no longer runs there. Tests and lanes that held
the scheduler thread in a submission handler hold it in a submission check instead
(unsubmitted, host_memory's deallocator lane); queue_order's take-up probe notes from the
check, which still runs on the scheduler thread; commit_and_submit's held-check test asserts
the orders that hold (A's handler before B's, B's check before B's handler) instead of one
interleaving; the submission_handlers lane expects the handler threads; grouped_submissions'
cross-queue handler lane counts X and Y's one submission once all completed.

Docs: add_submission_handler names the threads (inside commit_and_submit: the committing
thread; otherwise the device's handler threads), README, RUNTIME-PORTING, FAST-PATHS (the
grouped-completion row's handler rule, the commit cost entry), scheduler, inbox, group,
submit, contexts.

Also: the completion_latency guest-shaped leg times each submission handler from its own
submission's return; the unsubmitted check and the deallocator lane hold the scheduler thread
where an empty opener runs no submission check.

Verified (complat): msi m3-max-35809 at 0e0c55e4e8: build, clippy -D warnings (runtime, plain and
--cfg m2v_gpu), unit 44/44, signatures, lavapipe suites 122/122, all 0; gem10 35797 at 4aa9c2ac29:
workspace clippy x3 and rustdoc 0. Negative controls (msi 35811, lavapipe): with the blocking wait
back, completions_before_their_submission_handlers_hold_no_handler_thread fails under Exact and
Grouped (5 of 6 never completed with 2 handler threads); with no hand-off,
a_pass_s_submission_handlers_run_while_it_goes_on fails under both. PHOENIX suites and the
submit-cost leg before/after follow.
2026-11-16 02:01:45 -08:00
Anees Iqbal be720853a5 Name no consumer benchmark in comments, tests or docs
Eight comments and docs (dispatch_chain, compute_instantiated, spares_compute, unshared_hold and
its tests, FAST-PATHS) named the guest compute benchmark a workload came from, and two named a
consumer's job labels. AGENTS.md keeps consumer apps and benchmarks out of the tree; the shapes
and numbers stay, described by what they are (a guest compute benchmark's super-resolution
workload, its fluid simulation).

Verified: git grep finds no such name; cargo fmt. Comments and docs only.
2026-11-16 01:39:25 -08:00
Anees Iqbal 518d6d8443 RUNTIME 2432: Shadows: merge on the host over host pages on devices that write lines back
What: a shadow's merge in place into a no-copy buffer's host pages, on a device whose
check of those pages failed, or has not answered, the copies or the shader writes of
texels whose rows end inside a line (the same rule as the copy back's splice), now goes
on the host. Its keep and the copy of the texels the commands left go into two parts of
a Shared scratch (ScratchKind::ShadowHost; the fetch view is not used, so the changed
texels are always copied). The encoder records only that copy, and a host step of a
batch of its own (Deferred::ShadowSplice, now carrying HostWrite::Splice or ::Merge)
compares the parts eight bytes at a time and stores each byte that differs into the
pages with atomic byte stores. Such a texture joins no run of passes (render.rs), so
each pass merges as its encoder ends. Devices where both checks passed keep the
kernel merge.

Why: the Iris probe (m3-max-35510) showed the merge kernel's stores losing CPU writes
to padding bytes in the line that holds each row's last texels, as the copy back did.
A CPU store changes only the bytes it stores, so the bytes the commands left, and
every byte the CPU writes meanwhile, stay. Metal keeps those bytes
(conformance probe row_padding_writes.m).

Where the merge stays on the GPU (FAST-PATHS known gaps): merges recorded between a
pass's instances, before a tile dispatch, into a held command buffer, at a segment's
end, merges through a copy, and the runtime's own Shared memory.

New WorkCounts fields: shadow_merges_on_host, shadow_merge_host_nanos.

Tests: shadow_write_lines now asserts the Draw rounds (keep + merge) put back no byte
and go on the host under unanswered verdicts, and follow the measured verdicts in the
second test. A new test, costs_of_a_write_back_spliced_or_not, prints the median
command-buffer time of a copy back and a merge for 34x34 and 1920x1080 RGBA16Float,
with verdicts unanswered and passed.

Degradation kinds added: none.

Verified (fplend): msi m3-max-35675 at bdb1e2cbae clippy (runtime, all targets/features, -D warnings) 0,
touched unit tests 3/3, api_signatures + fast_paths 34/34; msi 35689 clippy --cfg m2v_gpu 0.
PHOENIX suites (35711), lavapipe, rustdoc and the Iris cost run follow.
2026-11-16 01:05:03 -08:00
Anees Iqbal 9ea0a9c1f6 RUNTIME 2431: Shadows: splice a copy back into host pages on devices that write lines back
What: a shadow's copy back (Step::Back) of a 2D texture's image, or of a texture
buffer's staging buffer, into a no-copy buffer's host pages is spliced where the
device's check of those pages (DmaBuf or Pointer) failed, or has not answered, the
copies or shader writes of texels whose rows end inside a line (Access::Copies or
Access::Writes of RowEnds::InLines, Failed or Pending). The GPU copies only the
columns that fill whole lines of memory (nonCoherentAtomSize): one region a slice
where its rows are a multiple of a line apart, else one a row. Each row's head and
tail columns go by the GPU into a line-aligned region of the command buffer's arena,
and a host step of a batch of its own (Deferred::ShadowSplice, after the work before
it completed) copies them into the pages a byte at a time, as the CPU's stores go.
The encoder notes the truth's writes after the step. A copy whose texels fill whole
lines alone copies back as before; a device where both verdicts passed copies back
as before. New count WorkCounts::shadow_copies_back_spliced.

Why: on the Iris Xe (ANV) a copy of texels into a buffer's rows writes back the
64-byte line holding each row's last texels whole, putting back older values over
the CPU's writes beside them. The lane's probe (m3-max-35510) lost 3,539 to 14,319
bytes a kind in 300 command buffers through a shadow's copy back and merge, where
Metal keeps every such byte (row_padding_writes.m). This breaks Metal's contract on
the guest's bytes; the merge is the next change.

Where the copy stays (docs/FAST-PATHS.md, known gaps): a copy back between a render
pass's instances or before its tile dispatch, into a held pass's command buffer, at
a segment's end recorded at a commit or a host step, of rotated, two-plane, tiled or
heap depth/stencil textures, and into the runtime's own memory.

Tests: tests::shadow_splice (the cut run as GPU and CPU over a map of host bytes:
every texel once, no GPU byte in a shared line, every shape of texel, width, pitch
and phase); tests::shadow_write_lines (the probe made a device test: the guest's
34x34 RGBA16Float target over dma-buf pages, buffer and plane forms, a clear's copies
back put back no byte the CPU wrote beside them and are spliced; and a copy back
spliced exactly as the device's measured verdicts say).

Degradation kinds added: none.

Verified (fplend): msi m3-max-35614 clippy 0, tests 0, signatures 0; 35623 clippy m2v_gpu 0;
lavapipe 35625 clippy m2v_cpu_icd 0, 216 passed, rustdoc 0; PHOENIX 35632 (um790) in-place +
shadow suites 287/287, shadow_write_lines 2/2: under the measured verdicts (Copies and Writes
Passed) 0 spliced; under HostPageTexturePolicy::Shadow (no check, verdicts Pending) every copy
back splices (+300 in 300 rounds, 0 bytes put back). The Iris run follows.
2026-11-16 00:46:56 -08:00
Anees Iqbal 8b70cf1ca7 FAST-PATHS: what listing a render target's sibling formats costs its compression
The view bullet now states the measured cost of cdcd787fb8's listing of
a render target's channel-order sibling formats (BGRA8Unorm and
BGRA8Unorm_sRGB of an RGBA8Unorm texture) in its image's format list,
which lets a pass render into such a view of the image in place.

Measured with tests::reordered_list_compression (ignored probe, carried
archive of d6366dcf65 built in m3-max-35552 on msi), the runtime's own
plan of a 2048x2048 Private ShaderRead|RenderTarget texture, its
VkImageCompressionPropertiesEXT::imageCompressionFlags, Mesa 26.2.6:
- Radeon 780M (PHOENIX, m3-max-35557) and RX 7900 XTX (NAVI31,
  m3-max-35558): DEFAULT as planned, without the sibling's formats and
  not mutable, for RGBA8Unorm and BGRA8Unorm.
- RX 550 (POLARIS12, m3-max-35556): DISABLED in all three forms,
  the not-mutable control included: the driver compresses no render
  target image of the runtime's usage there, so the list costs nothing.
- lavapipe (m3-max-35553): no VK_EXT_image_compression_control.
ANV and NVIDIA not measured.
2026-11-16 00:09:12 -08:00
Anees Iqbal b034129644 RUNTIME 2426: Grouped: count each batch that went alone by why, and unshared queues' batches
Under CompletionPolicy::Grouped a batch refused a place in a group while no group
was held went alone and was counted nowhere: group_ends_* count only groups that
held a batch. So the consumer's steady Launchpad walks (batches_grouped 0,
group_ends_drained 1 a window) could not say why nothing grouped.

Each batch on a VkQueue whose batches group that goes in a kernel submission of
its own now counts once, by the first reason in group::Alone's order
(WorkCounts::batches_alone_* and batches_held_alone_*): an unshared queue's
batch, a binary wait or signal (a completion sync file), a sparse update, pieced
work, a fence, an unknown or too long expected run, first work or a wrapped image
with no group held, a committing thread's submission; or, held in a group that
went holding it alone, what sent that group (at most one earlier submission in
flight, an unshared queue's hold on the VkQueue, a head waiting for the GPU,
another queue's handlers, a waiter, kept with none joining, a batch that could
not join, or other). Group::keeps answers why it does not keep. And
batches_of_unshared_queues counts unshared queues' batches on every device, so a
walk under either policy gives their share.

The validation lane's alone_batches checks one batch per reason it can make
deterministic (unknown run, at commit, one pending, a completion sync file, an
unshared queue, beside an unshared queue) on a device that groups, and none
counted elsewhere; steady_presents (ignored, a measurement) runs a steady
present shape with an unshared compositor queue and prints the spread.
Conformance classes the counts that follow what the host had seen complete as
not the case's own. API signatures blessed.

Also 4d71df7f28 (a type alias for clippy) and 5e04b74b48: FAST-PATHS: grouped submissions' measured lateness, the unshared exclusions and the alone counts

Row 38 edited in place, docs only. It now states:
- the measured cost of the fast form in the consumer's guest walks on RADV at
  ca6259f7d1 (lateness of command buffers seen complete after a later one's
  end, p99 18.4 ms against Exact's 2.1 ms on the 780M, 5.1 against 2.4 ms on
  the XTX), against the Metal oracles' p99 of at most 0.28 ms;
- that the bounds are on expected runs, so a later batch running longer than
  its queue's recent ones makes earlier members late by its actual run, which
  no bound set ahead can cap;
- that CompletionPolicy::Exact adds none of this lateness;
- that an unshared queue's batches join no group on a VkQueue held back for it
  and no group is kept there, which on a device of one graphics VkQueue (RADV,
  ANV, lavapipe) keeps no group of any queue: read from group.rs (Group::keeps,
  CommandBufferShared::groups) and create.rs's queue plan;
- the new per-reason counts (batches_alone_* and batches_of_unshared_queues).
The fast form's bounds are unchanged (owner's call, AGENTS.md rule 1).

Verified in the lane: m3-max-35367 at 71158a8ea4 plain clippy (runtime, validation, conformance,
metal2vulkan) 0, api_signatures 3/3, conformance 119/119, runtime group tests 12/12;
m3-max-35394 at 5e04b74b48 lavapipe clippy m2v_cpu_icd 0, alone_batches + grouped_submissions
16/16. Still running when landed: clippy m2v_gpu, plain clippy + fast_paths + rustdoc at the tip,
one PHOENIX run of the counts (path-ran evidence). Bounds unchanged.

New Degradation kinds: none.
2026-11-15 23:15:15 -08:00
Anees Iqbal c053f814b1 RUNTIME 2418: The in-import dma-buf class takes the dma-buf class's copies verdicts
The check's DmaBufInImport class makes its pages exactly as DmaBuf's
(dma_buf_pages, plus the gate that its buffer lies in one import dedicated
to nothing), and a copies round puts no image over the pages: its copies
rounds repeat DmaBuf's over pages made alike. At its copies turn it now
takes DmaBuf's copies verdicts for both row ends, and runs no rounds of its
own, where DmaBuf's were measured this run or known before (passed or
failed) and both classes' noted memory flags are known and equal, the
same-memory-type rule of RUNTIME 2417's crossing; otherwise its own rounds
run as before. The note names the source verdicts and the flags
("DmaBufInImport copies: DmaBuf's verdicts, Failed and Passed for rows on
lines, its pages made as DmaBuf's in memory of property flags 0x..: no
rounds of its own"). A shared failure is a proof for pages made alike; a
shared pass is one draw of the rounds' race fewer, which errs to the shadow.
CHECK_VERSION 22: a record of 21 may hold the in-import class's own copies.

Tests: tests::in_place's unit test of shared_copies (shared where measured
and memory alike; the control: coherent against cached either way, either
memory unknown, a row end unchecked or pending, every other class: none);
tests::in_place_check's device count (the shared note once and no rounds of
its own where the rule holds, the dma-buf class's verdicts taken; printed
with both classes' memory and the check's wall time).

Also 00ba762437 (test only): the lent targets' test prints every host class's memory on a device made
with VK_EXT_external_memory_host too (LENT-TARGETS-POINTER lines).

Verified in the lane (m3-max-34930, msi, at 937274ec72): runtime clippy --all-targets --all-features
-D warnings plain, m2v_cpu_icd and m2v_gpu exit 0; touched tests 39/39; gpucfg archive built.
On the Iris Xe (RPL-P, m3-max-34910 at 00ba762437): lent_dma_buf_targets passed; Pointer, Fresh,
DmaBuf and DmaBufInImport check pages all lie in memory of flags 0xf. Still to run: the PHOENIX
check wall time base against tip, and the Iris count test with the in-place suite.

New Degradation kinds: none. CHECK_VERSION 21 -> 22: every device runs one fresh in-place check.
2026-11-15 20:35:31 -08:00
Anees Iqbal b63bfbfac7 RUNTIME 2417: A render target's lend takes copies' failures through memory of one type
On the Iris Xe walk, a game engine's renderer made 73 RGBA16Float render
targets with free rows' padding over a no-copy buffer's dma-buf pages, and
each was a shadow: their renders failed for rows that end inside a line,
and the dma-buf classes' copies' verdict they lend that padding by
(`in_place::lent_to_copies`) was not failed in the recorded check, while
fresh checks fail it. A class's rounds catch a copy's line write-back only
as often as the CPU's writes race it, so the verdict hangs on a race.

The lend's copies verdict (`in_place::copies_verdict`, through
`InPlaceChecks::decided` at every decision site) now takes another host
class's copies failure, its reads passed, where the class's own kept every
byte or was unchecked, but only where the check's pages of both lay in
memory of a type of the same VkMemoryPropertyFlags as the driver reports
them: a write-back measured through memory of other flags says nothing of
this memory. Each class's memory flags are noted by the check and kept in
its record (CHECK_VERSION 21, eight words more). A shadow that renders with
free padding over host pages names the copies verdict it took in its
shadowed-texture notice. The line-write-back reason and docs (FAST-PATHS
host-pages row and the Iris known gap, API.md section 1 and the catalogue,
the kind's rustdoc) say so.

Tests: the unit test of the rule on the exact shape (same memory in place,
coherent against cached apart in both directions a shadow, unknown memory,
reads not passed, own-memory classes, own failed or pending kept, the
record's memory words); and a device test over a no-copy dma-buf buffer
(tests::lent_dma_buf_targets) whose control notes the pointer class in
memory of other flags and keeps the shadow.

Also 6e1f7b369d: the lend's memory flags are compared and printed as raw bits (ash's
MemoryPropertyFlags has no Debug impl here; clippy's chunks_exact_to_as_chunks).

Verified in the lane (m3-max-34875, msi, at 6e1f7b369d): runtime clippy --all-targets --all-features
-D warnings plain and --cfg m2v_cpu_icd exit 0; tests::in_place, tests::degradation*,
tests::texture_placement 38/38. Still to run: the device test on the Iris, PHOENIX and lavapipe
in-place suites, a sabotaged-build negative control, clippy m2v_gpu, rustdoc.

New Degradation kinds: none. CHECK_VERSION 20 -> 21: every device runs one fresh in-place check.
2026-11-15 20:15:41 -08:00
Anees Iqbal 8d617591f8 RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages'
source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import
dedicated to nothing (no sparse buffer over several imports, no import the driver made
dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the
texels' pitches is bound in that import at the texels' offset, beside the buffer
(vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is
asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory-
image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its
alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737)
and its memory types take the import's. An import dedicated to the buffer binds no image
(-memory-10926): DmaBufPages now notes that.

A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the
check's textures of each dma-buf class take that class's image alone (a thread-local of the
class the check runs). texture/route.rs takes the new class where its verdicts take the
texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making
refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take
it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept
imported for good, as an image in a pointer import's is. A rebind remakes such an image in the
new pages' import by the same order. RADV requires a dedicated allocation of every such image,
so its check leaves the new class unchecked and it never takes the route.

New WorkCounts field: dma_buf_images_in_import. No new Degradation kind.

The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency)
fail the new class's verdicts first, so they keep measuring today's image on any device. A new
device test (tests/dma_buf_in_import.rs) counts the route and its negative control.

Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for
dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b
(docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs).

Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on
the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated
allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the
Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact;
first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453).

Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime
--all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe
in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the
Iris count test with its negative control.

API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane).
2026-11-15 18:55:56 -08:00
Anees Iqbal 873c255ded RUNTIME 2407: Grouping bound: a queue's expected run follows its command buffers' own GPU times
What: the group bound (GROUP_RUN, 16 ms) reads a per-command-queue estimate of its own
(QueueGen::group_run), with the same rule as before: raised at once by a longer run, halved
toward a shorter one. It is fed at each command buffer's completion in place_gpu_times:
- from its GPU duration by its timestamps, the value the long-queue mark already reads;
- where the device answers GPU times from the host, from those placed host times.
Device::flies goes back to the Flight for a VkQueue an unshared queue holds only, so the unshared
hold's Expected and its feed are as they were before 37b1ca8563.

Why: 37b1ca8563 fed the bound from the host's view of each batch's run as its VkQueue's oldest.
That view holds other VkDevices' work on the GPU and the host's latency. Under nextest's parallel
suite on the Radeon 780M (m3-max-34541, at bf0ca5902a), the warm fills' commit-to-completion
times read 0.6 to 825 ms. Queues read past 16 ms, grouping stopped, and five grouping tests
failed. The hazard the bound guards is our own kernel job's length. A command buffer's two
timestamps bracket its own work, and other clients' work does not lengthen them.

Docs: group.rs and the grouping FAST-PATHS row say where the estimate comes from. With
gpu_times_from_host it follows host times, which hold other clients' work too, so under contention
there a queue's batches may stop grouping.

Test: scheduler_held_wakes::a_late_completion_of_short_gpu_work_leaves_its_queue_grouping. A warmed
queue's fill has its completion held unpublished 40 ms (Point::Publish) while its GPU work is
short by its timestamps, then the queue's next group must be kept. Under the host-view estimate
that run reads 40 ms and no batch of the queue would join a group.

Fix forward for RUNTIME 2405 (5021e3b4ac): its regression showed on the 780M as five grouped tests
failing under the parallel suite (m3-max-34541).

Verified in the lane (m3-max-34562, tip c90332ba5e): clippy -D warnings m2v_cpu_icd, runtime and
validation, all targets and features. Still running when landed: the lavapipe set (dropped_work and
the new test), clippy plain and m2v_gpu, rustdoc, and the 75-test 780M rerun under the parallel suite.
Expected, not yet shown: the new test fails against 5021e3b4ac's estimate.
2026-11-15 18:48:54 -08:00
Anees Iqbal 2a13f503ce FAST-PATHS: the grouping row measures its run bound on the Radeon 780M
frame_costs_over_imports, release with --cfg m2v_gpu, before (dcd5b6fc96) and after (37b1ca8563)
on the same node (job m3-max-34529): grouped vkQueueSubmit calls a frame barely move, and no
group went for a batch's expected run.
2026-11-15 18:41:06 -08:00
Anees Iqbal 5021e3b4ac RUNTIME 2405: Grouped submissions: a group's summed expected GPU run stays within 16 ms
What: a batch joins a held group only where its queue's expected run is known and keeps the
group's expected runs, summed, within GROUP_RUN (16 ms). Otherwise the group goes first
(GroupEnd::Long, WorkCounts::group_ends_long), and the batch leads the next group where its own
run is known and within the bound, else goes alone. The expected run is unshared_hold::Expected,
which was fed only on a VkQueue an unshared queue holds. It is now fed on every VkQueue whose
batches group: Device::flies enters each batch there in the Flight. The hold's decisions still
read the Flight only where other queues' batches are held back.

Why: the driver runs a group as one kernel job, and Linux's amdgpu ends a job past its 2 s default
timeout with no error the device reports. On a Radeon 780M a single 3.2 s command buffer was ended
and the one behind it dropped. Four batches that each finish alone could cross the timeout
merged. With the bound, merging adds at most 16 ms of the others' expected work to any job. 16 ms
is the owner's line for an intolerable wait, and it also caps how late grouping makes a member's
completion seen (the FAST-PATHS row said about 20 ms behind a 20 ms batch). A queue none of whose
batches was seen complete has no expected run, so its batches go ungrouped until one completes.

Tests:
- tests::group_run: the admission rule (unknown, alone, a full group of quarters, 12 + 5 ms,
  overflow).
- runtime_lane::grouped_submissions::a_queue_s_batches_group_within_their_run: on a grouping
  device with one VkQueue, behind running work on another queue, a fresh queue's batches group
  none, a warmed one's group, and none after a 40 ms command buffer of its own.
- The grouped lane scenarios, and submit_check_device's paths test, warm each grouping queue with
  one completed fill first. The behind-running-work tests measure the fills' rate on a queue of
  its own, so the B queue's expected run stays its first fill's.
- Every place that sums the group ends counts the new end, and frame_costs prints it.

Docs: group.rs and unshared_hold.rs module docs, the grouping FAST-PATHS row (its bound and its
cost line), and WorkCounts::group_ends_long.

Verified in the lane (m3-max-34508, tip 37b1ca8563): clippy -D warnings with m2v_cpu_icd, runtime and
validation, all targets and features. Still running when landed: lavapipe tests (group_run, the
grouped lane, unshared_hold, submit_check_device, kernel_end_device, commit_and_submit,
queue_share_device, frame_costs), clippy plain and m2v_gpu, rustdoc, and the 780M before/after.
Expected, unverified: conformance cost records' grouping counts (not the cases' own, never gated)
may drop in cases that commit on fresh queues.

API: adds the field WorkCounts::group_ends_long (additive; api_signatures blessed at landing).
2026-11-15 18:29:57 -08:00
Anees Iqbal 1acb205fb0 RUNTIME 2403: Runtime: a command buffer whose timestamps read unavailable after its queue passed it fails as Metal's victim
What: in complete_seen, a command buffer that would complete with no error, but whose own
timestamps read unavailable (Stamped::Read(None)) once its queue's timeline passed its last batch,
now fails with GpuRecoveryVictim. Its GPU times read 0, the new WorkCounts::unrun_command_buffers
counts it, and nothing counts against its queue. Its host-page logs hear of it as of a failed
command buffer.

Why: Linux's amdgpu ends a job past its timeout (2 s by default) with no error RADV reports. On a
Radeon 780M (Mesa 26.2.6, Linux 7.3.3) a 3.2 s fill was ended, and the command buffer queued
behind it on the same queue never ran, yet both completed with no error. Read-only from Mesa
26.2.6:
- radv_device_check_status checks only OpAbortKHR;
- syncobj waits pass no fence error;
- VK_KHR_device_fault reports only GPUVM faults and shader aborts (radv_device.c:2145).
The timestamps are the documented signal. A signal's first scope holds "all commands that occur
earlier in submission order" (Semaphore Signaling), and "a query is made available by the
operation of ... vkCmdWriteTimestamp" (Queries). So a query read unavailable after the signal was
never written. The completion turn already reads both queries with availability: the check adds
no Vulkan call, one comparison.

Docs: gpu_time.rs, the GpuRecoveryVictim and WorkCounts docs, the runtime README's lost-device
section, and two FAST-PATHS known gaps:
- work a driver drops is found only where the command buffer writes timestamps (not with host
  GPU times, MoltenVK on Apple's GPUs, a family of no timestamp bits, no free slot, or an
  adopted device);
- amdgpu's 2 s default job timeout fails a single command buffer that Metal's longer watchdog
  runs.

Test: tests/dropped_work.rs injects the unavailable read (completion::trace::unstamp_of), with no
GPU hang. A command buffer whose stamps read as written completes and counts 0. The injected one
fails as GpuRecoveryVictim with GPU times 0 and counts 1. The queue's next command buffer
completes and its fill lands.

Verified in the lane (m3-max-34463): clippy plain, m2v_cpu_icd and m2v_gpu and rustdoc of the runtime; lavapipe
35/35 incl. tests::dropped_work (injected unavailable stamps fail the command buffer as GpuRecoveryVictim; the
queue's next command buffer completes), gpu_time, device_recovery, completion and stall.

API: adds the field WorkCounts::unrun_command_buffers (additive; api_signatures blessed at landing).
2026-11-15 18:17:58 -08:00
Anees Iqbal 4a06ce915d SEMANTICS 2129, RUNTIME 2399: Heap storage reads by the formats' own read bits on a device without the feature
A compute pipeline that reads a read_write argument-buffer texture was refused
Unsupported{ArgumentBufferTextures, needs ShaderStorageImageReadWithoutFormat}
on a device without shaderStorageImageReadWithoutFormat (ANV on Gfx12.0, the
Iris Xe), so the guest's work waited on a nil pipeline. Vulkan 1.3 and
VK_KHR_format_feature_flags2 enable the SPIR-V capability
StorageImageReadWithoutFormat, and a read of a view without a format is then
valid wherever the view's format has STORAGE_READ_WITHOUT_FORMAT_BIT (spec
19.9.3, VUID-vkCmdDispatch-OpTypeImage-07028). The slot path already took
that route; the heap path checked the feature alone.

- declare_heap takes a storage (and storage texel buffer) read by the
  feature or by the formats' bits (DeviceProfile::storage_reads_by_format_bits),
  and on such a profile needs the read bit of the class's neutral, which a
  null handle reads.
- The binder keeps each storage view as before (writes unchanged). On such a
  profile, a member whose view's format lacks the read bit is held for its
  writes and flagged (new entry flag FLAG_STORAGE_UNREADABLE, bit 28: the
  texel-class field narrows to the 12 bits its indices use), and a storage
  read through its handle reads the null element, as a nil texture's read
  does. A member of one of Metal's read-write tier formats, whose read
  Metal's contract defines, is refused without the bit instead.
- handle_entry_flags takes the profile (the flag is the device's).

On the committed Iris profile every Metal read-write tier format has the
read bit; RGB10A2, BGR10A2, RG11B10Float, BGRA8 and the 16-bit packed
formats do not (Mesa's isl: no Gfx12.0 typed reads).

A read-write tier format whose view lacks the bit is not refused at the member (binding runs for
every shader-writable texture of the runtime's device-wide heap, so a refusal there dropped the
texture's writes on a profile such as roadmap-2022, job m3-max-34236): lower::texture::slot::
declare_heap refuses the function that reads a heap storage class where any tier format would be
held in that class through a view without the bit, naming each view's bit; the member is held for
its writes, flagged. Docs: API.md accepted difference, FAST-PATHS known gap and device-gap row,
REFUSALS.md.

Verified in the lane (m3-max-34272): clippy -D warnings for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation, all targets and features; nextest over the heap, handle, storage, profile,
fast_paths, without_format, texel_class and tier tests plus api_signatures, refusal_surface and
api_surface: 317 passed. A synthetic Iris profile with RGBA16F's read bit cleared refuses the
reading kernel naming that format; the committed Iris compiles it. The lavapipe lane with the
feature withheld and the Iris run follow from the lane.
2026-11-15 17:26:02 -08:00
Anees Iqbal d3b1dbdbe0 SEMANTICS 2128, RUNTIME 2398: Buffer views read at their bind offset where a pushed word lengthens every thread's payload
On ANV (Mesa 26.2.6) on the Iris Xe RPL-P, a compute function that reads a client push word
gets a longer per-thread payload (the base workgroup id moves 17 registers further), and a
light kernel runs about 2.2 times as long: 120.2 us against 55.7 us a dispatch on the same
module with the push read removed (raw Vulkan chains, jobs m3-max-34063 and m3-max-34038).
The 780M (RADV) shows no such gap (m3-max-34031). The runtime's storage views read their
SlotBindOffset residual on every access, so every kernel paid it there.

A measured DriverWorkaround row, PushReadsLengthenThreadPayload, on that driver and GPU:

- the translator declares SpecKey::RangeAtBindOffset for storage views too on that profile
  (access plan's storage_at_bind; the pulled vertex fetch of a shared slot folds its residual
  under the same key), so a key at 1 reads no push word once the driver folds it;
- the binder sets a storage view's key only at bind offset 0, where the runtime tells offset 0
  apart at the slot (StageTable::zero_offset_views, class ZERO_OFFSET_CLASS), and only where
  instantiation's range starts there (starts_at_bind), so the bytes before a bind offset stay
  reachable through the range from the buffer's start at every other offset;
- the runtime keeps the zero-offset slots beside the uniform ones (AtBindViews), leaving out a
  slot once it is bound at another offset, and reads views at their bind offsets on that
  profile (reads_views_at_bind), the uniform views' existing form included.

Every other profile declares no new key and its modules are unchanged; its stage tables leave
zero_offset_views 0, so its shapes and plans are as before.

Also a FAST-PATHS known gap: on the Iris Xe, kernels over exportable or host-pointer-imported
memory run about 2.2x (125.53 and 122.95 us against 55.73, m3-max-33760), cause unobserved;
zero copy stays.

Tests: engine_access (a storage view's module at key 1 reads no SlotBindOffset, at key 0 it
does, answers on the interpreter; no key on the other profiles), the binder's offset-0 rule and
class, the committed profiles' form choice, and a runtime device test of a storage view at
offset 0 and past it.

Verified in the lane: touched tests in msi jobs 34174/34198 (engine_access, bind::, fast_paths,
api_signatures, the runtime pipeline and argument_table tests); lavapipe m2v_cpu_icd 21/21 (34190:
uniform_bind_offsets and the new storage test, answers at offset 0, past it and at 0 again); clippy
plain 0 (34198), m2v_cpu_icd and m2v_gpu 0 (34200); rustdoc 0 (34213). golden_hashes reads stale only
for intel-irisxe-rplp-anv (re-keyed: 1788 cells, fingerprint 6d95bb254f9f9d66 -> 2f820bef4bfb9669); no
cell under an unchanged key moved. The table is re-blessed on development.
2026-11-15 17:07:41 -08:00