Commit Graph
7020 Commits
Author SHA1 Message Date
Anees Iqbal 1262e7ae7c rt: name std::thread in the cache's test-only merge wait
wait_while_merge_held (cfg test with m2v_gpu or m2v_cpu_icd) called thread::sleep without
std::thread in scope, so rt's lib tests failed to compile under both device cfgs (E0433), as
core's landing check m3-max-46232 showed. Host builds never compile the item, so the host gate
stayed green.

Verified: compile check of rt's tests under --cfg m2v_gpu and --cfg m2v_cpu_icd (the pd job named
in the landing report).
2026-11-18 05:49:13 -08:00
Anees Iqbal aeed1fe9e1 matrix: ceilings for the 2080's and 3090's create_64MiB/first_take and the Iris's create_private_16MiB/first_take, as the planner ruled
The planner re-floored the three rows at rt's measured medians from the full matrix at
8a39262627 (1.876 on the 2080, 2.252 on the 3090, 1.877 on the Iris), each with the reason beside
it, and they ratchet down from there.

The take split (probe ef7d99c4d1's predecessor f0b71e45bb, never landed; m3-max-46108 on the
2080, 46176 on the 3090, 46109 on the Iris, one round each, two processes per arm, run as the
matrix runs the creation rows): on NVIDIA the old runtime's 64 MiB Shared buffer is one host
pointer import of fresh anonymous pages (6.4 to 8.2 ms) with no zeros written, a form it picks by a
submission check at run time; rt makes a 64 MiB allocation (10.0 ms on the 2080, 15.4 to 17.4 ms on
the 3090) and zeroes it (2.5 to 2.6 ms). The harness's first touch after the call costs the same on
both, so nothing is deferred. rt takes no such import form (one form per device, and a held import
taxes every RADV submission). On the Iris the old runtime's Private 16 MiB first take allocates on
no thread (create and bind, 4.4 us), carving it from a Private block it already holds; rt's takes
a new block, and its first GPU fill's recording (680 us) and the first GPU use of the new block
stay open against the row.
2026-11-18 05:42:34 -08:00
Anees Iqbal b00a2a27c4 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-18 05:42:05 -08:00
Anees Iqbal 370290b92d conformance: record and time vertex-constant-step-instances on the M3 Max
Record mode (job m3-max-45736 at f5172d90a3, an Apple M3 Max, macOS 27.0.1 26A434) took the case's
two Metal facts:
- Plain Metal ran the pass, Completed with no error, over 3 runs folded into one outcome. Every slot a
  draw's vertex and instance sums reach holds the attribute buffer's first word, 0x10, with its sum,
  and the one slot they do not reach stays 0xEE..: from vertex 0 slots 0-2 (0x10, 0..2); indices 1-2
  at base instance 1 slots 2, 3, 0 (0x10, 2..4); vertex start 2^30 and base instance 2^30 slots 0-2
  (0x10, 2^30..2^30+2). So Metal's constant step reads the first element whatever the vertex start,
  the instance and the base instance, past the buffer's end included.
- Metal's API validation let the case run.
conformance times --runs 8 --write (same job) wrote both legs' figures: within the 10x margin, the
margin reported unjudged (the instrument's floor read 19.59 instrument costs on Metal's leg).
The same job's replay on the M3 Max (the old runtime over MoltenVK) reads exact.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py; --check passes).
2026-11-18 05:41:17 -08:00
Anees Iqbal 43a4cc0ec1 conformance: vertex-constant-step-instances, Metal's constant step across instances, a vertex start and a base instance
The cases that set MTLVertexStepFunctionConstant so far draw one instance from vertex 0, where any
step counting from the draw's start names the first element too. This case draws two vertices of two
instances through the rasterization-disabled fixture vertex_fetch_reach (it writes (v, vid + iid) at
out[(vid + iid) & 3]) with its uint attribute at the constant step, stride 4, over a buffer holding
0x10 + w at word w: from vertex 0 (the control), from base instance 1 (indices 1 and 2), from vertex
start 2^30 and from base instance 2^30. At stride 4 element 2^30 lies past the 64-byte buffer, so
only a fetch of the first element answers 0x10 there.

metal_fetched_the_first_element_at_every_vertex_and_instance holds Metal's recorded answer to that:
every slot a draw's sums reach holds (0x10, sum), the other UNWRITTEN. The cost coverage bill names
the case until the next whole-set cost run.

The recording follows from record mode on the M3 Max.
2026-11-18 05:41:17 -08:00
Anees Iqbal 212bba29c6 rt: Metal's constant step is a vertex-rate binding of stride 0, on every device
Under the identity domains (Device::from_queries' profile, the new runtime's), Metal's
MTLVertexStepFunctionConstant was refused as Unsupported{VertexStepRate}, needing
vertexAttributeInstanceRateDivisor and vertexAttributeInstanceRateZeroDivisor, which the floor
does not enable. The constant step needs no divisor: it is now a vertex-rate binding of stride 0,
one form, no query, every device.

Vulkan permits it. The specification's "Vertex Input Address Calculation" (28.4) gives a
vertex-rate attribute's address as bufferBindingAddress + vertexIndex * stride +
attribDesc.offset, so a stride of 0 reads the layout's first element for every vertex and every
instance, whatever the base instance: what Metal's constant step reads. A binding's stride has no
lower bound outside the portability subset: VUID-VkVertexInputBindingDescription-stride-00619
bounds it above (maxVertexInputBindingStride) and is the only other rule on it, and
VUID-vkCmdBindVertexBuffers2-pStrides-06209 names 0 among the strides a bind may set. Under the
portability subset (VUID-VkVertexInputBindingDescription-stride-04456: at least
minVertexInputBindingStrideAlignment) link refuses the stride of 0 as
Unsupported{VertexInputLayout}, as it refuses any stride the subset forbids.

Translator, under the identity domains only (lower::access::identity), so Device::new's profile
and the old runtime are unchanged:
- metal::vertex::fetch_as answers Constant with VERTEX rate, divisor 1;
- pipeline::link::vertex::binding_stride emits stride 0 for any fixed-function fetch of a
  constant-step layout, keyed on the layout's step rather than on a divisor of 0 (on Device::new's
  profile the only such fetch is the divisor-0 one, so its bindings are the same);
- link's check that an attribute the vertex function lists as alike at every vertex of a
  primitive is fetched once per instance also takes a constant step's binding, which reads one
  element at any rate.
- The per-instance refusal (rate above 1) names exactly what the profile lacks:
  vertexAttributeInstanceRateDivisor, else the maxVertexAttribDivisor the rate passes. Its old
  text, and Feature::VertexStepRate's, claimed the constant step needed the divisor; both now name
  the per-instance step alone.

Docs: docs/API.md (identity-domain vertex input), the rt README's vertex lines, REFUSALS.md
regenerated (the VertexStepRate row and its reach mark no longer name the constant step).

Tests:
- engine_identity_render from_queries_fetches_a_constant_step_at_vertex_rate_with_stride_zero:
  on lavapipe (no buffer robustness, no divisor, no supportsNonZeroFirstInstance) ima_vertex's mark
  layout at the constant step links to a VERTEX-rate binding of divisor 1 and Static(0), both
  modules L3-valid; on moltenvk-m3 (portability subset, minVertexInputBindingStrideAlignment 1) it
  is Unsupported{VertexInputLayout}. Fails without this commit (VertexStepRate on both).
- rt draw every_device_fetches_a_constant_step_attribute_for_every_vertex_and_instance: two
  instances of a triangle from vertex 1 at base instance 1, the uint mark at the constant step over
  four distinct marks: every texel holds the first mark, provoking vertex 1, and its instance (1
  above, 2 below). Points are a gap of rt's draws, so the draw is of triangles; the provoking
  vertex is vertex 1, so a vertex-rate stride other than 0 would read the second mark, and an
  instance step the second and third.
- The Device::new-path tests stay as they were: a_constant_step_links_to_a_zero_divisor_binding_of_
  zero_stride, fetch_is_fixed_function_only_when_exact,
  a_constant_step_is_a_zero_divisor_only_where_a_zero_stride_is_legal.
2026-11-18 05:41:17 -08:00
Anees Iqbal 59391ad5cd rt README: a tiling kernel's creation on the UHD 630, its driver compile against the old runtime's and why
A known gap of pipeline states, closed as one: on Intel's Windows driver (101.2145) for the UHD
630, the driver's compile of the harness's create_state kernel took 1.44 to 1.51 times the old
runtime's. The three parts: the 256-thread workgroup the runtime makes a tiling kernel's pipeline
at, where the old runtime made it at the dispatch's threadgroup (1.1 to 1.3 ms); the decode of
the pushed tile (0.4 to 0.55 ms); the module's device addresses, where the old runtime bound
storage-buffer descriptors (0.37 to 0.47 ms). The pipeline layout and the per-pipeline pipeline
cache cost nothing measurable. The driver keeps compiled pipelines across processes, so the cost
is paid once per driver cache.

Verified, UHD 630, a probe that times vkCreateComputePipelines alone on the two runtimes' modules
of that kernel (never landed, harness.exe M2V_PROBE_COMPILE at 8a28c9ec18, modules dumped at
a67b02abe8 by job m3-max-46010):
- job m3-max-46121: three processes, each module seeded so no driver cache hits, medians of 40:
  old's own form (workgroup 1) 4,473-4,761 us; old at 256 threads 5,599-5,792; the runtime's own
  (256 threads, tiles) 6,680-6,853; 256 threads, tiles off 6,133-6,295; 1 thread, tiles on
  5,317-5,485; 1 thread, tiles off 4,825-5,009.
- job m3-max-46079: the layout (push-only 5,021, set 1's arrays 4,995) and a per-pipeline cache
  (4,990) at one thread; the same modules again in two later processes, 45-48 us (the driver's
  own cache).
2026-11-18 05:34:12 -08:00
Anees Iqbal 6e379c60de rt cache: a device whose cache data begins with no version-one header keeps no blob, and the device tests expect none from it
On lavapipe (Mesa 26.2.4, msi), vkGetPipelineCacheData of an empty cache gives 20 bytes, shorter
than a VkPipelineCacheHeaderVersionOne (m3-max-46080, a print in seed()). The seed already named
no blob then, so the device read and wrote none, but five device tests that landed with the shared
cache, and the merge-window test, assumed every device keeps one and failed on lavapipe
(m3-max-45999: 205 of 211).

The header is now taken by usable_header: the first 32 bytes where their size field says 32 or more
and their version field says one, least significant byte first, as the spec writes them; none
otherwise, a short buffer, no data or another version among them. The spec lets a driver cache
nothing, so "no usable header" is "no blob", never assumed. Its doc, seed()'s and the README's
cache directory list say what lavapipe gives.

Tests: only_a_version_one_header_names_a_blob (host) covers a header with its count, a bare
header, lavapipe's 20 bytes, no data, a header that says it is shorter and another version.
every_device_keeps_a_blob_only_where_its_cache_data_begins_with_a_header (device) reads the
driver's data of the device's empty cache and asserts the device names a blob exactly where that
data begins with a header, and that two devices in turn leave that many blobs in the directory. The
blob tests that need a blob (the bound, the removal, the merge window) skip a device that keeps
none, printing why; the directory tests (lowerings taken by a later device or process, the render
content) expect as many blobs as the device keeps. Verification: the check and lavapipe and GPU
legs reported with this branch.
2026-11-18 05:33:12 -08:00
Anees Iqbal dd52afe31e rt sampler: a constexpr sampler refused past the device's samplers lets go of the table's lock before giving back
hold_constexpr matched on `lock(&core.samplers).take(..)`, and the guard, a temporary in the match
scrutinee, lived through the arms: the Err arm's give_back locks the same table again, so a
refused take (Limit::DeviceSamplers, or a failed vkCreateSampler) locked the thread against
itself. The take now has a statement of its own, so the lock is let go before the arms. Found by
grepping metal2vulkan-rt for a lock taken in an if-let, while-let or match scrutinee whose body
does more than read the guarded value; the other sites' bodies only read or update the guarded
value and return.

Test: every_device_refuses_a_constexpr_sampler_past_its_samplers caps the device's sampler table
at what it holds (a test-only setter), asserts `sample_up`'s constexpr sampler is refused with
Limit::DeviceSamplers, then restores the cap and makes the same state. Verification: a negative
control with the old match, and the check and device legs with the fix, are the jobs reported with
this branch.
2026-11-18 05:33:12 -08:00
Anees Iqbal 980a27b80a rt cache: a creation during the seed's merge goes through the empty cache, never waiting for the merge
take_seeded cloned the current cache in its `if let` condition, and the lock guard, a temporary
there, lived to the end of the block: vkMergePipelineCaches ran with `pipelines` locked, and
creation() takes that lock, so a creation during the merge waited for all of it. One seed of a
31.5 MB blob on ANV spent 240 ms in the merge (m3-max-45839). The clone now takes a statement of
its own, so the lock is let go before the merge.

What a creation in the merge window loses: it goes through the empty cache, which the swap
replaces, so its pipeline is not merged into the seeded cache, is missing from this run's blob, and
is compiled again at the next start. That is bounded: only creations through the empty cache that
end once the merge has begun, all of them counted in Metrics::creations_before_seed. There is no
second merge into the live cache: vkMergePipelineCaches needs its destination externally
synchronized, and creations use the live cache. The README's cache paragraph and seed()'s doc say
so.

Test: every_device_creates_through_the_empty_cache_while_its_seed_merges holds the seed before its
merge (a test-only hold, armed through a thread-local for the device made next on the test's
thread), makes a state on another thread, and asserts it ends during the hold and counts as a
creation before the seed. Verification: a negative control with the old condition, and the check
and device legs with the fix, are the jobs reported with this branch.
2026-11-18 05:33:12 -08:00
Anees Iqbal c66538239e rt: the cache store's removal thread is joined at teardown, so no thread outlives the device
The thread registration made it visible: the store-remove thread, which no stop ended, could
still hold a slot of Gauges::threads after the device was dropped, a leak by the matrix's rule.
The store now keeps the handle of the removal thread it last started (a new start joins the one
before, which has ended its pass), and the core's drop joins it after the caches close, once
nothing writes to the store. What it removes is finite, so the wait is bounded. The Gauges and
README wording that excused the thread go.

Test: every_device_joins_its_cache_directory_s_removal_at_teardown opens a device on a cache
directory with two dead generations, the removal paused 200 ms by a test seam
(cache::REMOVAL_PAUSE), drops it at once, and asserts every gauge zero, threads included, and the
dead generations gone.
2026-11-18 05:26:37 -08:00
Anees Iqbal 3dff069f08 rt: a recorder's pool is reset releasing its memory, so a submission is not held for a free beside it
On NVIDIA's Linux driver (RTX 2080 and 3090), a vkQueueSubmit2 of a command buffer from a pool
that was reset keeping its memory waited until any vkFreeMemory of host-visible memory beside it
ended: in the paced runs a submission was held 20-23 ms, and in the probe a commit 1 ms into a
64 MiB Shared free completed 24-46 ms late (median; up to 70). The probe isolated it to the pool:
neither the host barrier, nor the batch's shape (one SubmitInfo2, no waits, one command buffer),
nor the memory the command buffer touches, nor the completion thread's calls are held. A
non-transient reused pool, or a reset on the recording thread, is held the same. A fresh pool,
or the reused pool reset with VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT, is not.

give_back now resets with RELEASE_RESOURCES: one form on every device, no query. It also bounds a
recorder's memory: a pool that once recorded a long command buffer keeps none of it past its
next reset, where before each of up to IDLE_MAX pools kept its high-water mark.

Probe 6be5985659 (jobs m3-max-46001 2080, 46002 3090, 46003 XTX, 46004 Iris; ms, median):
commit to completion during a free, as it was / released: 2080 24.2 / 0.16, 3090 45.6 / 0.22; with
no free: 2080 0.45 / 0.48, 3090 0.95 / 1.11, XTX 1.55 / 1.49, Iris 1.14 / 1.26 (ranges overlap); the
reset at retire 0.01-0.03 either way on all four.

A device test commits 1 ms into a 64 MiB Shared free the GPU used and fails where the commit's
completion takes half the free's time or more, on a device whose free takes 10 ms or more.
make_allocation, free_allocation and Allocation's memory are pub(crate) for it.
2026-11-18 05:23:01 -08:00
Anees Iqbal 3cbf244329 replay: the new runtime's backend gives textures and sampler states the indices the stream names
The new runtime leaves texture and sampler indices to its consumer. The backend now gives
each object the index the stream names where the runtime takes it: a descriptor's or a
view's resource index, else the index of the ID the program saw of the object (its first
gpuResourceID record, read ahead by the player and handed over before the call that makes
it). Otherwise it gives the lowest index of the object's class that no live object holds
and the program did not reserve, as Metal's pool hands out a sampler state's ID. A reserved
index (reserveResourceIndicesForResourceType:indices:indexCount:) is taken only where the
stream names it. Where the runtime refuses a named index (an object of the play holds it, or
it lies outside the class), the object takes the lowest free one and the report counts it on
the backend's "indices named" line. Released objects give their index back.

Before this, a play of a recorded stream on the new runtime reported tens of objects whose
gpuResourceID differed from the recording's.

Tests: unit tests of the index bookkeeping (Indices), and rt_replay device tests: sampler
states made and released past the class's 3,999 indices reuse the released ones; a reserved
index is taken only where named; a state takes the ID the program saw. docs/REPLAY-STREAM.md
says how the new runtime's backend places textures and sampler states.

The same change, on an older base, passed clippy, the replay unit tests and the four rt_replay
device tests on lavapipe (m3-max-45671, m3-max-45775). The rebased tree's check follows.
2026-11-18 05:07:11 -08:00
Anees Iqbal 00c6a899e7 harness: the own-thread docs link Device::threads by its imported name 2026-11-18 05:04:14 -08:00
Anees Iqbal eb16d34f15 matrix: the instructions gate judges the new runtime's own threads, a driver's left beside
The burst rows' whole-process count swung by up to 25 million instructions per run between
processes on NVIDIA, all of it in the driver's own "[vkrt] Analysis" thread, while rt's own
threads held steady (48-50k instructions per command buffer on the 2080, 23k on the XTX). A gate
on the whole count judged the driver.

rt now registers the OS id of every thread it starts in Gauges::threads, at one place: the
spawn helper device::start, which the reaper, block-maker, submit and completion threads and the
cache store's removal thread all start through. A thread holds its slot until it ends. The list
is bounded by construction (5 slots), nothing on a commit or submit path reads it, and
Device::new's paths are untouched. devtools gains ThreadInstructions (per-thread user-space
counters by OS id, a thread that already ended skipped) and this_thread. The harness reads the
runtime's thread ids through Device::threads before a row's timed runs, counts them with its own
thread, and records own_per_run and others_per_run beside per_run. Every counter read now sits
outside the timed wall span.

results.py, per the planner's ruling: EXACT, the new runtime's own count at most 1.03 times its
stored count (instructions.tsv now holds own counts), ratcheting down; LENIENT, named on every
row, the own count at most the old runtime's whole count, old's driver share not separable since
the old runtime names no threads. A whole count with no own count fails the row. The base
comparison skips the harness's counts: the gate judges them.

Verified: scripts/matrix/test_results.py, 42 tests OK locally. Builds and the other suites run
on the check job.
2026-11-18 05:04:14 -08:00
Anees Iqbal e2a75fffec replay: the two-copy device test passes its range by slice, as cpu-ICD clippy asks 2026-11-18 04:59:03 -08:00
Anees Iqbal 0f9ea3ab7d replay: a device test of a two-copy stream's Managed buffer: the GPU's copy, an announcement with no write, a synchronize
The case the r3 fault came from: a GPU-written counter that the guest resets by announcing its
range with no write. On a one-copy device (lavapipe) the player keeps the second copy; on a
discrete GPU the runtime's Managed buffer has two.
2026-11-18 04:59:03 -08:00
Anees Iqbal 2a3e0d1372 lockstep: lane checks by windows and lane steps, each pointer's lanes once
The lockstep pass's second pair search (the one under the facts that hold where each simdgroup
lies in one row of its threadgroup) was 423.8 ms of the 449.6 ms the pass took in one recorded
stream's 95 lowerings up to its frame 216 on a Radeon 780M, and the pass 449.6 of the 702.6 ms
the lowerings took. An address computed from the thread's position has per-lane offsets only in
that search, and each pair of such addresses went through Lanes::apart, which compared 32 lanes
against 32 in each of 32 simdgroups (32,768 comparisons for a pair) unless both moved by the
same shift from one simdgroup to the next, and evaluated each index's operation tree anew at
each of the 1,024 places.

- Lanes::apart: the bytes of a lane at x and another's at y meet where x - y lies in one window
  of the index width's circle. Where both simdgroups step by one step from lane to lane, the
  lanes' differences are lane 0's plus at most 31 steps either way, so a simdgroup is at most 31
  steps. Otherwise each address keeps its simdgroups' lanes in the order of their offsets, and a
  simdgroup is one pass of two cursors through the other address's offsets read three times:
  at most 32 + 2 x 96 steps, where every pair of lanes was 1,024. The answers are the same.
- AddrFacts::lane_program and run_lanes: each index is read once into a program of its steps,
  which then runs on a small stack at each place, where the tree walk read each value's kind,
  width and builtin at every place. place_value is gone.
- AddrFacts::lanes_once: the accesses through one pointer share its lanes (Rc), computed for the
  first of them.

Work units follow the steps: a lane check charges the steps it takes, not 1,024 per simdgroup.
The answers, barriers, SPIR-V and notes do not change.

The rt README's first-create bullet keeps the device tests' numbers and adds one recorded
stream's: 23 of its 59 kernel contents observe their partition, and their 46 lowerings took 231 ms
on a Radeon 780M.

Verified:
- msi job m3-max-45948 at this tree (b196cd39d2): clippy of the workspace (all features) and of
  the translator under --cfg m2v_gpu, rustdoc, and the translator's suite, 3727 of 3727, which
  holds golden_hashes_match_the_table (every public fixture's SPIR-V on every committed profile;
  the fixtures that need metal-as are skipped on Linux) and the two new tests:
  the_window_answers_as_every_pair_of_lanes (7,200 offset sets and sizes, 8- to 64-bit widths,
  against comparing every two lanes) and
  the_window_charges_each_simdgroup_its_steps_not_its_lane_pairs (3,072 and 992 units for 32
  simdgroups, where comparing every two lanes charged 32,768).
- One recorded stream to its frame 216, cold, Radeon 780M, release, both arms on b6b303f8a0
  with the same timing probes (never landed): before 7fdfc5ee4e (job m3-max-45682), after
  4b979a18a9, this change's lockstep code (job m3-max-45943). The 95 lowerings took 702.6 ms
  before and 387.2 ms after, 515.4 and 302.0 ms of them on the creating threads; the pass took
  449.6 and 134.7 ms, its second search 423.8 and 109.0 ms; work units 369.4M and 69.7M; the
  heaviest kernel 43.3M units (32% of the work cap) and 7.2M (5.4%). The same 39 lowerings
  inserted barriers in both.
2026-11-18 04:54:24 -08:00
Anees Iqbal 14cbc14f9d rt cache: a blob taken is not marked used; the four kept are the most recently written
ff62f0e20f marked a blob a device took as used, setting its modified time, so that the four
blobs kept would be the least recently used. That is a write to the blob each time a device
starts, and it broke two device tests on every leg that ran them (780M m3-max-45834, RX 550
45835, Iris 45836, 2080 45837, Windows UHD 45845; archive 9c0ec21496). Both check that a
second device on a directory writes nothing and leaves every file as it was, and the blob's
time had moved:
- every_device_takes_a_render_content_a_device_before_it_made_from_the_cache_directory
- every_device_takes_the_kernels_a_device_before_it_lowered_from_the_cache_directory

The mark goes. The seed keeps the four most recently written blobs, as the request put it
("oldest removed on open"), and a device that takes a blob writes nothing. On those legs, 204
of 206 tests passed, the other 202 among them, these two the only failures.

Docs: the cache module, prune_blobs and the seed's doc, DeviceOptions::pipeline_cache_dir, the
rt README's blob bullet, the host test's name and doc.

Verified: nothing yet for this commit; its check and device legs are reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal 7e6064be83 rt cache: a state's lowering is written to the store by the reaper, through a bounded queue, never on the creating thread
The cold-creation split (probe a3318b088f, m3-max-45806/45807/45809/45810) showed rt writing
each new lowering to the store inside the guest's creation call: 57-119 us on Linux and
434-446 us on the UHD 630 under Windows (NTFS), per creation. The old runtime hands its
writes to a thread, at 3-7 us. The planner ruled the write off the creating thread.

Now a state serializes its lowering, or the translator's refusal of a variant, and hands it
to the reaper: cache::keep_translation pushes it onto a queue of at most 8 MiB of bytes
(PENDING_BYTES, about the 9.16 MB a long recorded session's 282 lowerings fill) and pokes the
reaper. The reaper writes queued files after its jobs and before anything else it does, so a
teardown writes every lowering handed over before the reaper ends. A file that would take the
queue past its bound is dropped and counted in the new Metrics::cache_writes_dropped, never
waited for: a lowering is only a cache, and a later device lowers it again. Store::put's
state-file lock and the temporary file's rename leave the creating thread with the write. The
warm read stays where it was.

Tests:
- host the_write_queue_refuses_a_file_past_its_bound: a file past the bound is refused and
  nothing is queued; files come out in order; each one taken makes room;
- device every_device_writes_its_lowerings_off_the_creating_thread_and_drops_them_past_its_queue:
  with the reaper's writes held (a test-only stall), a creation returns with nothing written;
  with the queue full, the next state's lowering is dropped and counted; let go, the reaper
  writes what was queued, and a device after it reads the first kernel's lowering and lowers
  the second again.

Docs: the cache and reaper module docs, the rt README's lowerings paragraph, the metric's doc,
the api_signatures row.

Verified: nothing yet; the check and device legs of this commit are reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal e5ede9dee6 rt cache: the blob pruning sorts by key, as clippy asks
m3-max-45811 (check of ff62f0e20f on um790): clippy refused sort_unstable_by with a reversed
comparison in prune_blobs in all three configurations (clippy::unnecessary_sort_by); fmt,
the 79 rt tests (the two new host tests among them), rustdoc, the signatures and the archive
passed. Now sort_unstable_by_key with Reverse.

Verified: nothing yet; the check of this commit is reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal 6268172fbb rt cache: a blob is named by its device's whole pipeline cache header, at most four are kept, and creations before the seed are counted
The blob was named by the first 16 bytes of the driver's pipeline cache header: the length,
version, vendor and device words, without the pipelineCacheUUID. So a driver update did not
rename it. The new driver was offered the old blob at its first start, and only the path that
removes a refused blob carried it. Now the name is the hex of the whole 32-byte header, opaque
bytes with no branch on them: a device or driver version whose header differs in any byte,
its UUID included, has a blob of its own.

So that leftovers stay bounded, a device's seed removes the blobs past the four most
recently used before it reads its own, counting its own among the four whether or not it
exists yet. A blob's time is its last write, or the last seed that took it, which marks it.
Temporary files and anything not named as a blob stay.

New Metrics::creations_before_seed: creations that went through the device's empty pipeline
cache while the reaper read and took in the blob, so a play shows whether that window
matters. It is a cumulative metric, not a gauge: gauges are live counts that return to zero
at the device's drop, which the leak checks hold them to. The seed already starts at device
creation: it is the first thing the reaper thread does, and Device::new spawns that thread.

Tests (host): a_blob_is_named_by_its_devices_whole_header (two headers that differ only in
the UUID get two names; another device gets another), and the fill past capacity
a_directory_keeps_at_most_four_blobs_the_least_recently_used_removed (six blobs, a temporary
file and the state: the three most recently used others stay, then four with the device's
own; the temporary file and the state stay).

Docs: the cache module, DeviceOptions::pipeline_cache_dir, the rt README's cache directory
section, the metric's doc, the api_signatures row.

Verified: nothing yet. The check and device legs of this commit are reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal 0f998e5a03 rt cache: no creation waits for the blob; creations before the seed go through an empty cache merged into it
The reaper made the device's pipeline cache from the blob before any creation could go on, so
a creation that came early waited for the blob's read and the driver's parse. With a blob near
the 32 MiB bound that wait is longer than a first creation today: on the UHD 630 under
Windows (probe 7d51eb039b, m3-max-45701), a 33,535,044-byte blob took 307 ms to read and 35
ms to parse the first time after it was written, and 17 + 17 ms after that. The first
creation, 10-13 ms after the device, waited 342 ms and then 33 ms. A first creation today takes
about 1.3-1.9 ms warm there.

Now the reaper makes an empty cache first, which a creation that comes before it waits for
(the empty cache's creation and header read: 27-75 us in those runs), and creations go on
through it. The reaper then reads the blob, makes a cache from it, merges into it what
creations compiled in the empty cache meanwhile (vkMergePipelineCaches: the destination is
the reaper's alone until it is published, and the source is internally synchronized), and
makes it the cache creations take. The empty cache is destroyed once no creation holds it.
The next write must grow past the blob's own size, so pipelines the merge added are written
at the next look that finds enough growth, or at the drop. A creation that started in the
empty cache and ends after the merge is not in this run's blob. A blob that is not taken is
removed, as before, and the empty cache stays.

The device tests wait for the seed through a test-only flag set when it is done, in place of
the cache's being made. The rollover test waits for it before its first state.

Docs: the cache module, DeviceOptions::pipeline_cache_dir and the rt README's pipeline cache
paragraph.

Verified: nothing yet. The check, the device legs and the probe's measurements of this commit
are reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal 59a387c58c rt cache tests: a look is counted once its effects are in place; the rollover's kernels make their pipelines at creation
The device tests' look counter was raised at the start of the reaper's look, so a test that
waited for a look could read the gauge, the retired list or the blob before the look set
them: on the Iris Xe (ANV) the rollover test read the gauge before the replacement set it
("the gauge falls from 5207 to 5207", m3-max-45704). The counter is now raised after the
look's work, with release and acquire ordering against the test's read.

The rollover test's third kernel, the observing kernel, makes its VkPipeline at its first
dispatch rather than at creation, so no look followed its state and the test timed out on
the 780M (RADV) at that state (m3-max-45702, backtrace in m3-max-45729). It now uses the
precise twin of the second kernel, which makes its tile's pipeline with the state, and
state_and_look asserts that the state made a pipeline, so a kernel that makes none fails at
once and by name.

Verified: nothing yet; the check and the device legs of this commit are reported with its sha.
2026-11-18 04:33:18 -08:00
Anees Iqbal 802679449e rt cache: every VkPipeline is made through one VkPipelineCache per device, kept as one blob
What. The per-pipeline half of the cache directory is gone: no file per VkPipeline, no read
of it before a creation, no VkPipelineCache made per creation, no two-generation lookup for
pipeline data, no pipeline key or module digest (sha2 leaves the crate's dependencies). In
its place every compute and render VkPipeline of a device is made through one internally
synchronized VkPipelineCache, which threads that create at once share:

- The reaper makes it first when it starts, from the blob `pipelines-<header>` where there is
  one, so the read and the driver's parse run off the thread that made the device; a creation
  that comes before it waits for the rest of the seed.
- The blob is the driver's data after a magic, its length and a checksum, named by the hex of
  the first 16 bytes of the header the driver writes into an empty cache's data (the header
  without its pipelineCacheUUID). The data must begin with the device's whole header. A blob
  that does not check, carries another header or that the driver refuses is removed and the
  cache starts empty.
- Once creation has been quiet for 20 ms (none running, none ending) after a creation, the
  reaper reads the cache's size with vkGetPipelineCacheData and no buffer. If it grew by more
  than an eighth since the last write, the reaper writes the data over the blob: a temporary
  file renamed over it. The device's drop writes once more if the size changed at all. No
  creation waits for a size query or a write.
- The cache holds at most 32 MiB at a look. Past that, a fresh cache takes the creations, and
  the old one is destroyed once no creation holds it. The next write replaces the blob, so
  the blob is bounded the same way, with no second file and no generations.
- New `Gauges::pipeline_cache_bytes`: the size at the reaper's last look, zero after teardown.
- Opening a store removes the `pipelines/` directories an earlier version kept under young
  and old, on the store's own thread, with the dead-generation removal.

Why. Each per-pipeline creation paid a store lookup, a per-creation VkPipelineCache and a
write of its own file. The two-generation probe for pipeline data was the 52 us miss found in
the store's lookups. The driver's own cache already dedupes and keys what it compiles. One
cache seeded once gives warm creations the driver's in-memory hit, writes a few times the
blob's final size over a device's life, and keeps one bounded file per kind of device.

Quiet is measured on pipeline creation, not on the pool's submission quiet.
vkGetPipelineCacheData contends only with creations, and a device that renders without stop
would otherwise never write before its drop. The growth-by-an-eighth rule bounds SSD writes:
a run that makes no new pipeline writes nothing. The blob is named by the driver's header
rather than by identity fields, so product code reads no vendor or device ID (the one_path
test), and a driver update replaces the blob instead of leaving one beside it.

Tests. The fill-past-capacity test is the rollover: with a low bound, the gauge drops, creates
still work, the retired cache is reaped when idle and the blob holds the fresh cache. Also
added: a blob that is cut short or carries another header is removed and the next device
writes nothing; the checksum changes with any one bit; an earlier version's pipelines
directories are removed at open. The render and kernel tests now check one blob and a second
device that writes nothing. The rt README's cache-directory section and the store docs are
rewritten here.

The README's store cost figures (open, hit in young or old, miss, write, dead-generation
removal at 100,000 and 1,000,000 files) are identity's measurements: potluck jobs
m3-max-45495 (btrfs, msi) and m3-max-45496 (NTFS, Windows), from the scale probe
84d808649f + 4229ae3525 on the store at 30f96b96f4.

Verified, on the same change at 9e787e58ab (branch steelbrain/store2-shared-cache, before it
was applied to this development tip):
- m3-max-45636: fmt, clippy, m2v_gpu clippy, the rt tests (76 passed), rustdoc, api signatures.
- m3-max-45670: clippy under m2v_cpu_icd too, and the m2v_gpu device-test archive.
Evidence with probe build 7d51eb039b (never lands), whole harness, rounds of old new new old:
- warm creation sum (driver + store read + creation wait, median of four warm processes):
  RADV 780M 1952 us (m3-max-45664), ANV Iris Xe 1776 us (m3-max-45665), RX 550 2050 us
  (m3-max-45667). The shared-cache probe's earlier estimate was RADV 2613 and ANV 2407.
- the reaper's seed of the measured blobs (36-108 KB) takes 0.3-0.6 ms, and the first creation
  comes 7-26 ms after the device, waiting 0.1-0.3 us.
- RX 550 warm second render state: rt 58 us median against old 236 us. Warm two-thread
  creations stay within 1.03 times old's own old-against-old spread on all three legs.
The device-test legs, the 32 MiB seed legs, the NVIDIA and UHD legs and a check of this tree
are reported with this commit's sha.
2026-11-18 04:33:17 -08:00
Anees Iqbal da2f870467 rt: a copy-in records no barrier before its copies
A copy-in with no copies back began with a full barrier (every earlier command, every access)
before its copies into the device copies. That barrier ordered nothing new: every segment, upload,
fill and copy-in on the queue ends with a barrier whose second scope takes every later command, the
rule a segment already keeps (record:🔚 a segment begins with no barrier). So it is gone, and a
commit that copies in a Managed buffer's named ranges records one barrier more than one that does
not, the one after its copies, where it recorded two.

The trailing barrier stays: it orders the command buffer's reads after the copies. A narrower form
of it (source stage COPY and TRANSFER_WRITE only, arm E below) changed nothing measurable.

Test: tests::managed's every_device_copies_a_managed_buffer_s_changed_ranges counts the barriers
of a commit with a copy-in against the same commit with nothing named: one more where the device
keeps a device copy, none where it does not. Without the change it reads two.

Probe (harness constant_managed and constant_private, 300 runs, order A B E D D E B A, exclusive,
one GPU each; wall_us is the host wall a run adds, mean of the two runs per arm). Arms: A base
6ab8b5da26; B this change's form 69228c0b92; E B plus the narrowed trailing barrier 6a5afdbafb;
D no copy-in barrier at all b487b7d9f1 (not correct: the bound only).

  GPU          row      A      B      E      D
  RTX 3090     managed  109.4  104.2  104.0   95.2   (job 45800)
  RTX 3090     private   90.7   90.2   90.0   90.8
  RTX 2080     managed  318.5  314.3  318.0  308.3   (job 45801)
  RTX 2080     private  303.4  302.6  301.4  300.6
  RX 7900 XTX  managed   74.3   75.2   75.9   75.0   (job 45802)
  RX 7900 XTX  private   74.2   73.9   73.9   73.4
  Iris Xe      managed 2673.6 2675.9 2672.8 2680.7   (job 45803)
  Iris Xe      private 2685.5 2692.9 2685.3 2685.9

B takes 5.2 us off the 3090's managed row and 4.2 us off the 2080's; the XTX and Iris Xe move
within their run-to-run spread (XTX runs 75.6/74.8 against 73.9/74.7). The first round (job 45779,
3090) read A 109.3, B 103.9, D 95.9 the same way.
2026-11-18 04:31:50 -08:00
Anees Iqbal 88624689b6 replay: the render-command skip test expects the gap as the runtime's Debug prints it
The device run (lavapipe) printed 'Draw { kind: Points }'; the count, frame and call matched.
2026-11-18 04:30:05 -08:00
Anees Iqbal 3ec80f3c7d replay: a render command the new runtime does not build is skipped, counted, and ends the verdict
The rt backend ended a play at the first render command the runtime answers with a typed gap: r3
stopped at frame 111 on a draw that reads its pass's own target, so nothing past it could be
measured. Such a command is now skipped and counted, as a render state the runtime does not build
is: `skipped_render_commands`, and a report line for each gap with its count and the frame and
call of the first. A dispatch is still skipped only where it names a skipped object.

So that a skip can never pass as a result, the player notes where the backend first skipped
anything (`Backend::skips`, told the frame and stream position of each call through
`Backend::locate`), and `Report::first_skip` holds it. Where it is set, command-replay's skipped
line and its last line (`ok` or `error ...`) end `; not a verdict past frame F, call C`.

Tests: a player unit test on a backend that skips draws (the first skip's frame and call, the
verdict note, none without a skip), and an rt device test where a draw of points after a covering
triangle is skipped, counted, named on its line, and the check still matches.
2026-11-18 04:30:05 -08:00
Anees Iqbal 8b428fe5ed matrix: a compute creation row's call alone is shown beside its first use, never judged
The cold-creation split (probe a3318b088f, m3-max-45806/45807/45809/45810) found the old
runtime returning from new_compute_pipeline_state before it makes its VkPipeline: no
vkCreateComputePipelines runs inside the call, and the driver's compile comes before the first
dispatch completes. rt compiles inside the call, as Metal does at newComputePipelineState. A
compute creation row's `/first` sample already spans the creation, one dispatch and the wait
for it (CreateReport::first_us), so that row compares like with like. The call alone was only
in the table's text.

The harness now also records it as `harness-<runtime>/<row>/first_call` for a compute state row.
The creation processes keep it like the other first samples (FIRST_KEEP matches it as is).
results.harness_budget shows it with the median of each runtime's five processes and their
ratio, as "shown, not judged: the creation call alone, which old returns from before it makes
its pipeline", and never judges it. One process's sample alone is not shown. `/first` and its
floors are unchanged. The planner approved this form.

Test: test_a_creation_call_alone_is_shown_beside_its_first_use_and_never_judged. Docs:
VALIDATION.md's creation and harness budget paragraphs.

Verified: nothing yet; the Python suite and the harness build are reported with this sha.
2026-11-18 04:26:08 -08:00
Anees Iqbal 328da5cc5e Deep threadgroups: positive() matches its operands by slice pattern; the old render key's pin under 2172
What: Consts::positive reads a product's and a select's operands through slice patterns, not
indexing (clippy::indexing_slicing, denied in spirv outside tests); an operand list of another
length is not known positive. the_old_render_descriptor_key_keeps_its_value pins the test
descriptor's key under SEMANTICS_VERSION 2172, which the old runtime's render descriptor key
hashes: its cache entries under 2171 are misses, as every semantics bump makes them.

Verified: check m3-max-45573 at a604f82f82 failed clippy at exactly these four indexes in all
three configurations, and the pinned-key test with this value on the left; the API tables, the
runtime guard and the rt lavapipe tests passed there.
2026-11-18 04:21:18 -08:00
Anees Iqbal e90079a61f Deep threadgroups: the lowering test's plan takes deep, every builtin checked deep; runtime pin
The dispatch lowering tests' plan initializer lacked the new field (the check's compile failure).
A new test runs a kernel that declares DeepThreadgroup over single regions 320 and 100 deep
(with and without MultiRegion, at both modelled subgroup widths), one 2 deep, and the regions of
a dispatchThreads grid of threadgroups 128 deep whose z edge is 60 deep, and checks every Metal
builtin of every thread against Metal's definitions; run_region sets the key from each region.

The runtime-sources pin takes the guard's new hash: the edit changes no behaviour of a recorded
run (Device::new, which the validation runs drive, declares no DeepThreadgroup and its binder
checks are unchanged), so RUNTIME_VERSION stays.

Verified: built and tested under the check job named in the report.
2026-11-18 04:21:18 -08:00
Anees Iqbal 70dffca0c2 Deep threadgroups run as one row: SpecKey::DeepThreadgroup on from_queries, rt keys it on the size
Metal allows 1024 threads along z; a device's maxComputeWorkGroupSize[2] may hold 64 (NVIDIA's),
so rt refused a kernel's threadgroup of 1x1x320 (Limit::ThreadgroupShape) and could not play a
recorded stream past its frame 216 on any NVIDIA card. One form serves every shape on every
device: a threadgroup deeper than DEEP_THREADGROUP (64) runs as one row of its threads.

Translator, on Device::from_queries' profile only (ProfileFacts::deep_threadgroups, OneRow; Device::new
keeps Axes and is byte-equal): a kernel whose workgroup is its threadgroup (LocalSizeForm::Spec,
no compute derivatives) declares the boolean SpecKey::DeepThreadgroup. Its WorkgroupSize is
(Deep ? sx*sy*sz : sx, Deep ? 1 : sy, Deep ? 1 : sz), OpSpecConstantOp selects (the WorkgroupSize
rule now takes spec-constant operations whose defaults are positive), and its position in the
threadgroup Deep ? LocalInvocationIndex unflattened over (sx, sy) : LocalInvocationId. The linear
index, workgroup and grid builtins keep their values, so group counts, regions and indirect
buffers are untouched. The binder sets it for a region deeper than 64 and checks that region as
the flattened tiers' are. MetalDeviceProperties on that profile reports the capped invocations
on every axis (1024 on every floor device) instead of the device's per-axis sizes.
SEMANTICS_VERSION 2172, ARTIFACT_FORMAT_VERSION 536.

rt: the key is a function of the variant's size (size[2] > DEEP_THREADGROUP), so it adds no
pipeline and no cache key. choose() takes no device limit: an image-only kernel's deep tile runs
whole as one row on every device (it ran whole on RADV/ANV and in tiles on NVIDIA). fits(),
ComputeLimits::max_group_size and Limit::ThreadgroupShape are deleted: every workgroup is within
the floor by construction (a const assertion). A module that neither flattens nor declares the
key is a creation gap. README: the deep form, worst-case pipeline counts, the 50-pipeline line.
REFUSALS.md regenerated; API.md; api_signatures blessed; api_surface pins DEEP_THREADGROUP.

Tests: the translator runs a barrier-exchange kernel at 1x1x320, 2x3x100, 1x4x256 (deep) and 4x4x4
on the interpreter, checks the evaluated WorkgroupSize, no key on Device::new, the binder's
setting on an NVIDIA profile, and the reported maxima; rt's choice tests drop the device limit;
the observing-kernel device test adds deep whole, ragged and indirect dispatches; the square
test adds a column 256 deep.

Verified: built and tested under the check job named in the report.
2026-11-18 04:21:18 -08:00
Anees Iqbal 5c5ce57119 replay: the Managed form comes from the identity of the device the guest makes its objects on
A stream may record more than one device: reims's one-copy recording on the 780M also holds the
host window's device on the display GPU, which is not unified. Each segment opens with one identity
record per live device in id order, and the player passed every record to the backend, so the last
one decided how every Managed buffer was kept, whichever device the guest used.

The player now reads ahead which recorded device the guest makes its objects on (the one that most
calls making an object have as their receiver, the lowest id of a tie) and takes the Managed form
from that device's identity record only. The report names the other devices on a
`devices apart from the guest's` line.

Test: a unit test with two devices, one unified and one not, the guest on each in turn.
2026-11-18 04:14:03 -08:00
Anees Iqbal 8a39262627 replay: a second copy's synchronizeResource: takes its buffer from the resource argument
The argument is a {Buffer: #id} variant, not an object: the two-copy play of r3 on the 780M stopped
at frame 203 on 'argument 0 is {Buffer: #3081}, not an object'.
2026-11-18 04:03:19 -08:00
Anees Iqbal 49febff9b5 replay: a two-copy stream's Managed buffers keep a second copy on a one-copy device
A stream recorded where Managed buffers have two copies (Metal's hasUnifiedMemory false) relies
on them: a didModifyRange: makes the GPU's copy of the range equal the CPU's bytes at the next
commit, over whatever a kernel wrote there. On a device whose Managed buffers are one copy (the
runtime's, on unified memory) a kernel's write into the buffer stayed where the recording put the
CPU's bytes back, and later work read it: gb r3's frame 1138 reads such a count and runs a kernel
past the end of a buffer on the 780M.

The backend now keeps the second copy itself there: the buffer object is the GPU's copy and
second::Seconds the CPU's, both Shared buffers in places of its own. The stream's writes and
m2v.check read the CPU's copy; didModifyRange: names a range, and the next commit copies every
range named since into the GPU's copy in a command buffer of the backend's own on the committing
command buffer's queue, committed just before it; synchronizeResource: copies the GPU's copy into
the CPU's. A stream recorded with one copy plays Managed as Shared on every device, as before. The
report's managed second copies line says how many buffers and bytes took a second copy and how
many bytes the commits copied, so that such a play is never read as a one-copy guest's.

Verified: the unit test named_ranges_merge_where_they_overlap_or_touch; the play evidence is in
the hand-over.
2026-11-18 04:03:19 -08:00
Anees Iqbal 53274a5352 rt: a Managed buffer keeps two copies on every device that is not unified
What: where device-local memory has no room for a copy block, a Managed buffer's device copy is
now a Private block of its own, taken through the pool, so it spills to whatever memory type has
room like any Private block; where no type has room, new_managed_buffer returns the allocation's
out-of-device-memory error (Metal: nil). Before, such a buffer was its Shared range, one copy,
on a device whose has_unified_memory is false. Gauges::managed_spilled_bytes counts the bytes of
Managed buffers whose device copy is not device-local, while they live; the replay player
reports it beside spilled_bytes. The rt README states the cost: on a full discrete card a
Managed kernel reads its copy across the host link.

Why: the planner's ruling. Metal keeps a Managed buffer's two copies on a discrete Mac: a
kernel's write stays in the GPU's copy until a synchronize, and didModifyRange sends the CPU's
bytes over it. With one copy, a kernel's write reached the consumer's bytes, and a range named
with no CPU write left the kernel's value in place: a program could observe the difference.

Tests: tests::managed::every_device_keeps_metal_s_two_copy_rule_for_a_managed_buffer (every
device): a kernel takes each word x to 2x+1, the range is named with no host write, a second
kernel reads it. Where has_unified_memory is false the consumer's bytes keep the host's words
and the reader reads them, and the buffer's address is not its Shared range's; on a unified
device the reader reads the kernel's write. tests::spill: the same rule with the Private type's
allocations made to fail (the test seam core.fail_private) and the pool's Private blocks
spilled; on a device that is not unified the gauge counts the buffer's 256 bytes while it lives
and reads 0 after. The api signature table gains the gauge field.
2026-11-18 03:52:56 -08:00
Anees Iqbal 6ab8b5da26 matrix: a job's script travels in its environment, not on its command line
The UHD 630 leg's harness job has failed in three matrices (0bd215eee3 among them, job
m3-max-45587) with "bash: -c: line 49: unexpected EOF while looking for matching `''" before any
row ran. The Windows host starts a job's command through a command line cut at 8,191
characters. The harness leg's script carries every leg's per-row limits and grew from 3,271
bytes at aaf4d16993 (last good UHD harness run) to 12,837 at 0bd215eee3 and 16,075 at
b2e33dba6d. Byte 8,191 of the 0bd215eee3 script falls on its line 49, the line bash named.

The script now goes in the job's environment (M2V_JOB, read and unset before it runs), and the
command line is a fixed one-liner, on every node. A Windows variable holds 32,767 characters.

Verified: the 0bd215eee3 and b2e33dba6d scripts parse with bash -n on macOS (so the script itself
is whole); a test job on the mini with an 18,627-byte script in M2V_JOB, against the same script
as the argument (control), is in the landing message.
2026-11-18 03:39:53 -08:00
Anees Iqbal affea51d8a harness: the binary imports count_instructions, which it calls before it makes a device
The previous commit called it through a run:: path the binary does not have in scope, so the
harness binary did not compile (check job m3-max-45575, msi).
2026-11-18 03:31:27 -08:00
Anees Iqbal d2e5edbd60 harness and matrix: record the whole process's instructions per run and gate the frame and burst rows on them
The harness now counts each timed run's user-space instructions across the whole process. The
counts repeat run to run where the times do not: rt's p50 spread across processes was 0.16 to
0.27%. The matrix gates the frame and burst rows (WALL_ROWS) on those counts, beside the host-time
judgement and floors they keep under the GPU-p50 rule.

devtools: ProcessInstructions opens one user-space instructions counter per core type with
inherit set, so every thread started after it opens counts: the runtimes' and the drivers'
threads too. The harness opens it first thing in main, before any device starts a thread, and
each timed run records the counted delta. A node that refuses perf_event_open, and every
non-Linux host, records none.

harness: each row whose runs were not sized prints
`M2V-MATRIX instructions harness-<runtime>/<row>/per_run <p50>`.

matrix: a frame or burst row with a count on both runtimes passes the instructions gate as well as
its time's limit:
- it fails when rt's count is over old's;
- it fails when rt's count is past 1.03 times the stored count in scripts/matrix/instructions.tsv
  (one column per driver family, `all` where the legs agree within 3%);
- it is named when its count is more than 1% under the stored count, which then ratchets down;
- it is named when no count is stored, and is then gated against old alone.
The single-kernel rows stay judged on their GPU p50 as before, and every row's count is shown
beside its times. The old runtime's harness counts are parked from the per-record
instructions-versus-base check, like its times. instructions.tsv starts empty: a matrix run's
counts seed it. VALIDATION.md describes the time rules and the gate in one paragraph.

Verified: scripts/matrix tests (python3 -m unittest discover, 45 OK) on this Mac, over this rule
and the GPU-p50 rule together. Before the rebase, check m3-max-45591 on msi (at c597bb3603) passed
clippy x4, nextest for devtools, harness and rt (118 passed, with the process counter's test), and
the release harness build. Count job m3-max-45641 on the 2080's node recorded the per_run count of
every row on both runtimes except long_4cb, which is sized.
2026-11-18 03:31:27 -08:00
Anees Iqbal b2e33dba6d matrix: a harness row with a GPU time is judged on it against the old runtime's GPU-time floor
The planner's ruling on the old-against-old GPU-p50 floors. On the XTX, whose host-time floors
reach 1.2-1.3 on the shader rows (8 runs, m3-max-45546), the same runs' GPU p50 spreads 1.004 on
simd_reduce (36.96-37.12 us, host time 44.9-55.8 us), 1.008 on narrow_ints, 1.012 on image_filter
and 1.024 on constexpr_sampling: the host time's spread is the host's, not the card's. So:

- A row with a GPU time on both runtimes is judged on its GPU p50, new over old, against the old
  runtime's GPU-time floor on that leg (the new scripts/matrix/gpu-floors.tsv), with its host
  times shown beside it. A ceiling applies to the time its row is judged on.
- The frame and burst rows (WALL_ROWS) stay on their host time and its floor, with the
  instructions gate: their GPU time spans the gaps between their command buffers and spreads as
  widely on several GPUs (1.68 on the Iris Xe's frame_5cb, 1.43 on the UHD 630's
  burst_160_shared). gpu-floors.tsv lists no such row.
- CARD_VARIANCE names rows whose GPU time varies on the card itself: the XTX's sampling (GPU p50
  16.3-20.3 us over the 8 runs; 1.264 in the earlier 4-run set, m3-max-45424) and
  constant_managed (66.8-69.2 or 74.4 us). They are judged like any other row, never fail a leg,
  and are named on its line as the card's variance.
- A re-timed run keeps the row's GPU time too (RETIME_KEEP, harness-retime-gpu/), and the re-time
  selection chooses by the same measure (RETIME_SELECT with GPULIMITS and WALLRE), so a row judged
  on its GPU time is re-timed and judged on its re-timed GPU pairs.

gpu-floors.tsv comes from the runs behind floors.tsv, no new job: the harness of 4cc7963005, 4
runs of `harness --runtime old` per leg (8 on the XTX), jobs m3-max-45422 (1002:15bf), 45430
(1002:1900), 45423 (1002:699f), 45546 (1002:744c), 45425 (10de:1e87), 45426 (10de:2204), 45437
(8086:3e9b) and 45427 (8086:a7a0). Its header notes that the UHD 630's texture_read (1.075) and
the Iris Xe's wide_bindings (1.097) are those GPUs' floors, not reds.

Verified: the matrix's Python tests (42, 4 new: a row with a GPU time judged on it and a frame or
burst row on its time, the GPU floor and the re-timed GPU pairs, a card's variance named and
failing nothing, the re-time keeping both times), run locally; the harness runs' shell renders
and passes `bash -n` for a leg with limits.
2026-11-18 03:24:47 -08:00
Anees Iqbal ef181c884d Reflow the import lists the rebase resolution unioned 2026-11-18 03:17:11 -08:00
Anees Iqbal 4ac94af120 replay: a released buffer's place waits for the command buffers that named it and are not yet committed
The new runtime's backend gave a released buffer's place back after the commits made so far, free
once they completed. A command buffer that named the buffer before its release but is committed
after it was not among them: the place could go to a new buffer, whose bytes the stream then
writes, before that command buffer ran, which then read the new buffer's bytes as its own (a
dispatch's arguments among them). Metal keeps a released buffer for every command buffer that
names it.

Each uncommitted command buffer's encoders' named buffers are kept; a release waits for those
command buffers (Places::give's users) and goes to the commit count when the last of them is
committed or released uncommitted (Places::ended).

Verified: the unit test a_place_waits_for_its_uncommitted_users.
2026-11-18 03:17:00 -08:00
Anees Iqbal fa930a9793 runtime lane: the replay draw test's metallib holds one-entry modules
A metallib function's module declares that function as its one entry; the
translator's container cross-check refuses any other (ContainerMismatch). The
test put the whole render fixture, five entries, behind each function, so the
render pipeline state was refused and skipped on every device (job 45305 on
lavapipe: "skipped render states 1, the first #6: the translator made no
pipeline: invalid input: Abi(ContainerMismatch) at metadata").

Each function's module is now the fixture with its entry lists cut to that
function's own entry node, found by the node's `!{ptr @name, ...}` line, and
assembled in the test's scratch directory.

Verified: the next job runs the test on lavapipe, then the legs on every
device.
2026-11-18 03:14:48 -08:00
Anees Iqbal 73f24bed7a replay rt backend: the report names the first skipped render state and why
A render pipeline state the runtime answers with a typed gap or the translator
refuses is skipped and counted, and nothing said which one or why: the replay
device test's draw was skipped on every device (legs 45244, 45245, 45246) with
skipped_render_states=1 and no reason. The backend now keeps the first such
state's object id and the runtime's answer, and its lines print
`skipped render states N, the first #ID: WHY`. The device test prints the
backend's lines after the player's.

REPLAY-STREAM.md names the line.

Verified: the next job builds the validation crate in every cfg and runs the
replay test on lavapipe.
2026-11-18 03:14:48 -08:00
Anees Iqbal 39f79ecb8e replay rt backend: the pass setters reborrow the attachment they set
set_attachment! takes its attachment by value, so passing the `&mut`
binding moved it before the clear value was set. Lint 45173 caught it
(E0382, three times). Each setter now passes `&mut *a`, as the old backend's
setters do.

Verified: the next lint compiles the validation crate in every cfg.
2026-11-18 03:14:47 -08:00
Anees Iqbal 3e0df2df8c runtime lane: a draw into a pass plays through the replay player on the new runtime
A device test of the player's rt backend, the first one: a stream it writes
makes a render pipeline state of the render library's colored_vertex and
colored_fragment (a metallib of runtime_examples.ll), a 4x4 RGBA8Unorm
target, vertex buffers, and a pass whose setter records clear the target to
red. It draws one triangle over the whole target, green. A blit copies the
target to a Shared buffer, which the stream checks green. The play must
report no skipped encoder, render state, draw, call or object, and at least
one pass.

Without the render port it fails. The backend skipped the render encoder
whole (skipped_encoders 1), so the target stayed red and the check differs.

The new runtime's device is opened behind the hang tripwire, as every device
open in the crate is, and keeps its kernels in a cache the test owns.

Verified: the lane leg under --cfg m2v_gpu on the lab's devices and
lavapipe.
2026-11-18 03:14:47 -08:00
Anees Iqbal e8113811dd replay: the rt backend plays render pipeline states, passes and render encoders
The new runtime builds draws (its render encoder, render pipeline and
depth-stencil states), so the player's rt backend stops skipping render
encoders whole. It plays, on rt's API:

- newRenderPipelineStateWithDescriptor:error:, its constexpr samplers numbered
  as a compute pipeline state's are (one helper, `numbered`, for both);
  newDepthStencilStateWithDescriptor:; MTLRenderPassDescriptor.new and
  .renderPassDescriptor with their m2v.setPass, m2v.setColorAttachment,
  m2v.setDepthAttachment and m2v.setStencilAttachment setter records;
- renderCommandEncoderWithDescriptor: and the render encoder's calls the old
  runtime's backend plays, with the vertex stage's textures and samplers, both
  stages' bytes, cull mode, winding, blend color, and the draws' instance,
  base-vertex and base-instance forms.

What rt does not build stays skipped and counted, honestly: a render pipeline
state rt answers with a typed gap or the translator refuses
(skipped_render_states); a parallel render encoder, or a render encoder of a
pass that holds what rt's descriptor does not (resolve textures, depth planes,
store action options, a visibility result buffer, layered or tile rendering, a
skipped texture) or that rt answers with a typed gap (skipped_encoders); and a
draw whose pipeline state, bound buffer or texture, or index buffer is a
skipped object (skipped_draws).

The render pipeline, depth-stencil and pass-key parsing moves from the old
backend's descriptors.rs to replay/translator.rs, shared by both backends, as
the sampler's is. docs/REPLAY-STREAM.md says what the rt backend plays and
counts.

Verified: lint of the validation crate (clippy in every cfg, the replay
tests, rustdoc); the device test that follows plays a draw on every device.
2026-11-18 03:14:47 -08:00
Anees Iqbal ab6a03d765 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-18 03:14:35 -08:00
Anees Iqbal a5f404ed8d cache codec: the signed fixed-function vertex fetch has its tag
The codec's VertexFetch enum names every variant, so adding SignedFixedFunction failed the
compile (E0004 in the digest and put matches, lint 45478). Old artifacts hold no such tag, so the
encoding is unchanged for them.

Verified: the next lint compiles the translator and its tests.
2026-11-18 03:13:48 -08:00
Anees Iqbal 0d1a32436b vertex input under the identity domains: every attribute in fixed function, no pulled form
Planner ruling 11-18 (final): fixed-function vertex input for every attribute on every device,
the form native Vulkan uses and the fastest measured on every device, one form. Nothing of the
pulled form is taken on Device::from_queries' profile. Before this, the translator's
containment rule (contain::encoding is Check::InShader without buffer robustness) moved every
[[stage_in]] attribute into the shader, a form that reads through a descriptor the identity
domains refuse, so every rt render state with a vertex descriptor was refused as
Unsupported(IdentityDomains).

Translator (metal::vertex::fetch_as, pipeline::link::vertex::resolve), under the identity domains
only (lower::access::identity), so Device::new's profile and the old runtime are unchanged:
- the containment rule no longer moves an attribute: the device bounds the fetch as it bounds
  any (no buffer robustness: a fetch outside its buffer reads what the device gives);
- an unnormalized signed-integer format (Char*, Short*, Int*) is fetched in fixed function into
  a variable declared int, VertexFetch::SignedFixedFunction (new): Vulkan's numeric-type match
  lets a SINT format feed only a signed variable, and the device sign-extends as Metal does. The
  module reads the variable's bits by OpBitcast. Elsewhere such an attribute is still pulled and
  sign-extended in the shader;
- every case that pulled is a typed refusal by what it needs, never a second fetch form.

Metal's vertex descriptor on the rt floor:
- Maps directly:
  - formats: every Metal vertex format to the Vulkan format of its layout and conversion, by the
    device's VERTEX_BUFFER format query. 8/16-bit integer formats read into float attributes go
    through USCALED/SSCALED, signed integer formats into int variables, UChar4Normalized_BGRA is
    B8G8R8A8_UNORM, the 10:10:10:2 formats are A2B10G10R10, and FloatRG11B10 is
    B10G11R11_UFLOAT_PACK32. The validation crate's profiles of RADV (780M x2, RDNA3), ANV (Iris
    Xe, UHD 770), NVIDIA (Pascal, RTX 50) and lavapipe report VERTEX_BUFFER for all of them but
    FloatRGB9E5;
  - steps: PerVertex is VERTEX rate; PerInstance at rate 1 is INSTANCE rate;
  - offsets and strides: the descriptor's, baked into the VkPipeline.
- No fixed-function equivalent on the floor, so a typed refusal:
  - PerInstance rate > 1 and Constant: Unsupported{VertexStepRate}, by query. They need
    VK_KHR_vertex_attribute_divisor's vertexAttributeInstanceRateDivisor (plus ZeroDivisor for
    Constant) and supportsNonZeroFirstInstance, which the floor does not enable, so it is
    refused on every rt device today. Its needs name the missing feature, or the
    maxVertexAttribDivisor limit;
  - a format the device does not report for VERTEX_BUFFER: Unsupported{Format} with that format
    usage, by query;
  - FloatRGB9E5: Unsupported{Format}, not implemented, by need. Of the profiles above only
    lavapipe's reports it, and its fetch answers 0 for the fourth component, where Metal and
    Vulkan give 1;
  - an offset or stride off the format's component alignment (Metal takes any byte multiple on
    Apple5+), and an offset, stride, attribute count or layout count past
    maxVertexInputAttributeOffset, maxVertexInputBindingStride, maxVertexInputAttributes or
    maxVertexInputBindings: Unsupported{VertexInputLayout}, with the limit where one is passed;
  - PerPatch and PerPatchControlPoint: Unsupported{Tessellation}, as before.

rt: RenderPipelineKind::StepRate is deleted: the translator's VertexStepRate refusal comes first
on every rt device, so no pipeline states a divisor. README: the vertex input bullets, their
refusals, and the known gap that a vertex fetch outside its buffer returns what the device gives.
docs/API.md: the identity domains' vertex input. REFUSALS.md regenerated, with reach marks for the
two new features (VertexStepRate app, VertexInputLayout rare); api_signatures blessed.

Tests:
- engine_identity_render from_queries_fetches_every_attribute_in_fixed_function (lavapipe and
  moltenvk-m3 profiles with buffer robustness and the divisor withheld): ima_vertex's float2
  and short attributes are R32G32_SFLOAT and R16_SINT, nothing pulled, L3-valid; a rate-2 layout
  is VertexStepRate needing vertexAttributeInstanceRateDivisor. It fails without this commit (the
  attributes were pulled, then refused as IdentityDomains);
- rt draw every_device_fetches_a_signed_attribute_in_fixed_function: a short of -2 reaches the
  fragment's uint output as 0xFFFFFFFE on every texel; a rate-2 layout is refused as
  VertexStepRate. The existing stage-in test (vertex buffer and set_vertex_bytes) now makes its
  pipeline.

Verified: the next lint job and the device legs on every device.
2026-11-18 03:13:48 -08:00