Commit Graph
7285 Commits
Author SHA1 Message Date
Anees Iqbal ebfc68ebb7 rt: a timestamp pair read as not available after its submission signalled is counted, and every play and suite leg reports the count
The read without the wait (f6906db61e) reports no times for a pair that is not available. Two
things leave a pair that way once its submission signalled: a submission the device cancelled
at a reset, which signals having run nothing, and a driver that makes timestamps available only
after the signal (MoltenVK 1.4.2 on an M3 Max did, for most command buffers, which is why the
read waited; MoltenVK is below the floor now). The second would zero GPU times with no other
sign, so each such read is counted: Metrics::stamps_not_available, through Pair::times, the
one counted read that CbInner::stamps makes.

Reported where the matrix records it:
- rt's device tests: `M2V-MATRIX metric <test>/stamps_not_available <n>` from each device the
  device loop opens (tests::command::on_device::on_each_device);
- the harness: `M2V-MATRIX metric harness-<runtime>/device/stamps_not_available <n>`, from the new
  Device::totals and Session::totals, before the session finishes (empty for the old runtime);
- the replay player: the `stamps_not_available` counter in each frame's executed counters.

The readback test now reads through Pair::times on counters of its own and checks that the read
counts one, so the device's record stays that of its real command buffers.

The specification read (Vulkan 1.4.366, sections 7.4 to 7.4.4, 23.2, 23.5 and the memory
model's system-synchronizes-with):
- "A query is made available by the operation of ... vkCmdWriteTimestamp2" (23.2);
- the signal's first synchronization scope "includes every command in the same batch that the
  signal operation is defined in, and all commands that occur earlier in submission order"
  (vkQueueSubmit2);
- "signal operations happening before host operations that wait on them" (memory model, the
  note under System-Synchronizes-With).
So a pair is available to a read made after a host wait (vkWaitSemaphores) that saw its
submission's value. The completion thread also retires values it learns from
vkGetSemaphoreCounterValue alone (after a wait that returned for an event, for its wake or for an
earlier value), and for that command the specification states no ordering: only that "the value
returned by this command may immediately be out of date". The count covers both.

Public surface: Metrics::stamps_not_available (api_signatures.tsv; signatures.py --check run
here and clean). Not yet compiled or run.
2026-11-18 16:32:06 -08:00
Anees Iqbal 3f59e7b0f9 rt: a command buffer's timestamps are read with no wait, so a cancelled submission's retire at once
On RADV a GPU fault's submission is cancelled at the ring reset, and its progress value is still
signalled then, so the completion thread retires it and reads its timestamp pair, which the device
never wrote. With VK_QUERY_RESULT_WAIT_BIT, RADV's vkGetQueryPoolResults checks for a lost device
once, then spins on the value for twice the kernel's 60 s compute timeout
(radv_get_rel_timeout_for_query) and returns VK_ERROR_DEVICE_LOST. For those 120 s the completion
thread ran nothing else: the buffer's completed handler waited, the guest's next commit waited
for it, and the loss reached the runtime at the next submission, about 123 s after the fault
(u3 play, job 48532 on a 780M: the completion thread in state R at every 1 s sample, the submit
thread idle, the next vkQueueSubmit2 failing at once 120.02 s after the reset).

The read no longer waits. The spec, read whole (Queries: Query Operation, vkGetQueryPoolResults,
Timestamp Queries; Synchronization: semaphore signaling and waiting, vkQueueSubmit2; the memory
model's system-synchronizes-with):
- "The first synchronization scope of each semaphore signal operation defined by this command
  includes every command in the same batch that the signal operation is defined in, and all
  commands that occur earlier in submission order." The progress signal's stage mask is all
  commands.
- "This covers all Vulkan synchronization primitives, including ... signal operations happening
  before host operations that wait on them": the completion thread's host wait that sees the
  value happens after the signal.
- "A query is made available by the operation of ... vkCmdWriteTimestamp2", and with the wait
  bit the read "defines an execution dependency with any earlier commands that write one of the
  identified queries": the host wait already gives that dependency.
- "If VK_QUERY_RESULT_WAIT_BIT is not set, vkGetQueryPoolResults may return VK_NOT_READY if
  there are queries in the unavailable state."
So a pair of a submission that ran is available to a read with no wait, which is what the runtime
already relied on (the caller reads only pairs of submissions it saw complete), and a pair a
cancelled submission never wrote reads as not ready at once: that buffer's GPU times are 0, as for
a driver that reports neither. The wait was there for MoltenVK 1.4.2, which made timestamps
available only after the signal; MoltenVK is below the floor. No retry, no timer.

Test: tests::readback::a_pair_no_submission_wrote_reads_as_no_times_at_once (the commit before)
fails with the waiting read on RADV and passes with this one; on lavapipe it passes either way.
Expected, not yet run: the matrix jobs named in the hand-off.
2026-11-18 16:32:05 -08:00
Anees Iqbal 080965f430 rt test: a timestamp pair no submission wrote reads as no times, at once
The state a submission the device cancelled at a ring reset leaves: its progress value signalled,
its timestamps never written. The completion thread reads such a pair when it retires the
command buffer. The read must report no times and return at once; this test bounds it by the
tests' patience (60 s), so a read that waits for values that never come fails it. On RADV the
waiting read (VK_QUERY_RESULT_WAIT_BIT) spins for twice the kernel's 60 s compute timeout
(radv_get_rel_timeout_for_query) before it returns VK_ERROR_DEVICE_LOST, so with today's read
this test fails there. On lavapipe a query no command wrote reads as not ready with or without
the wait flag (lvp_GetQueryPoolResults), so there it passes either way. The fix follows.
2026-11-18 16:32:05 -08:00
Anees Iqbal 6605f18ddf harness, matrix: the frames' commit-to-complete row is gone after its one round
The planner's frame ruling showed the frames' old figure, their last command buffer's
commit-to-complete time (`<row>/commit_to_complete`), beside the new throughput row for one round,
unjudged, then deleted. The round at 5f2494bfc5 is that round. The harness no longer prints the
record, the matrix no longer has a shown-rows table (its one row was this), and the docs and
the frames test lose it. The frames' latency from idle stays a row of its own.

Verified: the harness gate in the job named in the landing message (clippy plain, m2v_gpu and
m2v_cpu_icd, rustdoc, unit tests, the matrix's Python tests).
2026-11-18 16:28:03 -08:00
Anees Iqbal 32df0845b6 harness: the first state's threadgroup size is the harness's Size 2026-11-18 16:27:00 -08:00
Anees Iqbal ca92b2aa9e harness: a compute state row's first dispatches 64x1x1, the streams' commonest size; one thread beside it
The create_state row's first dispatched one thread (1x1x1), a size of few dispatches: 3.9% of the
compute dispatches in the discrete replay recordings (from 3 to 5 kernels) and at most 0.5% in the
unified ones, by identity's census of every stream's threadsPerThreadgroup. A runtime that
compiles its pipeline for the dispatch's size (the old runtime) compiled the first at 1x1x1, where
a program's first dispatch runs at its own size. The first now dispatches one threadgroup of
FIRST_THREADGROUP, 64x1x1: the commonest size over the five streams of record, 24.1% of their
compute dispatches (41.7% of the unified recordings', 7.1% of the discrete ones', where 128x1x1
leads with 39.3%; 128x1x1 is 23.3% overall). Each thread's 16 bytes are checked.

Today's form stays beside it, shown and never judged: another content's first (the kernel with
other constants) dispatched as one thread, create_state/first_one_thread
(CreateReport::one_thread_first_us; results.SHOWN_FIRST). The name has no digits so the matrix's
FIRST_KEEP keeps it from every creation process, which a results test holds. The warm-up stays at
one thread. docs/VALIDATION.md and the crate doc say it; the authored device test asserts the
compute row has the one-thread first.
2026-11-18 16:27:00 -08:00
Anees Iqbal c1bd2d46d6 replay: a report of a stream recorded before the completion fix says so on its first line
The recorder's completion fix marks a stream with header flag bit 1,
FLAG_COMPLETION_BYTES_RECORDED (value 2): at each command buffer's
completion the stream holds every chunk the buffer's work could store to
as the GPU left it, before any later CPU write, on all four late routes
(signalled event, final status read, refused hook, released command
buffer). Fixed streams read flags 3; every stream recorded so far reads 1.

- The reader takes bit 1 (it refused any bit but 0 before), so a fixed
  stream plays.
- command-replay play writes "recorded before the recorder's completion
  fix: the stream may differ from what the program did" by itself as the
  first line of report.txt for every stream without bit 1, so no table
  relayed from a report loses it. The stream is now read before the
  device type is parsed, so even a report that stops there carries it.
- docs/REPLAY-STREAM.md: section 1 names the bit, section 6 replaces the
  rule that described a stream without completion writes as allowed with
  the completion invariant and what a stream without the bit may miss,
  and section 10 names the line and its place in report.txt.

Tests: replay_completion_mark (integration) runs the player binary on a
one-call stream with flags 1 (the report begins with the line) and flags
3 (it does not), with a device type no device has so no device opens;
the header flags test now reads flags 3 and refuses bit 2.
2026-11-18 16:24:06 -08:00
Anees Iqbal 4dc00c65b1 conformance: the rt side's trait answers name texture_facts and reflection_is_the_consumers without linking them
Rustdoc of the conformance crate (job m3-max-48531, -D warnings) refused seven doc links: each
answer is a public trait method's, and both functions are private (rustdoc::private_intra_doc_links).
The names stay, in code spans.

Verified: nothing yet; the next check job documents it.
2026-11-18 16:18:07 -08:00
Anees Iqbal 77e5554af0 conformance: pipeline reflection and the named options are the consumer's own
The planner ruled pipeline reflection and options the consumer's: rt's API has no reflection
item and acts on no pipeline option, and its consumer builds reflection from the library's AIR
(the host never sees the options or the reflection pointer).

- known_gaps: ConsumerObject::PipelineReflection, the closed list's fifth object. Its name lists
  MTLComputePipelineReflection, MTLRenderPipelineReflection and the four options one by one
  (FailOnBinaryArchiveMiss, ArgumentInfo, BufferTypeInfo, BindingInfo), as the ruling asks.
- rt_side answers the consumer's own for compute_pipeline_bindings,
  compute_pipeline_under_options, render_pipeline_under_options,
  compute_pipeline_reflection_under and pipeline_both_paths' compute forms, only for an options
  word within the three named bits. A word with any other bit stays the call's Unavailable, so an
  option the reason does not name is never counted the consumer's. Both-paths' render, tile and
  mesh forms stay Unavailable.
- rt's README: the object in "What the consumer implements", and the contract line beside each
  "without reflection" line of the compute and render pipeline sections.
- tests: only_the_named_pipeline_options_are_the_consumer_s_own; the README and reasons tests
  cover the fifth object through ConsumerObject::ALL.

Verified: nothing yet; the step-2 check job compiles and tests it.
2026-11-18 16:18:07 -08:00
Anees Iqbal 488180f7bf conformance: the rt side makes heaps as rt's consumer does; MTLHeap's own calls are the consumer's
R3 (job 48327) refused 117 rows at "heap", most of them cases that go on to ask the heap's own
getters. The heap calls now answer as follows:
- Side::heap takes a block of the heap's size and storage, as rt's consumer makes a heap. rt
  has no heap object; its blocks are the memory the consumer places resources in.
- heap_buffer places a placement heap's buffer at its offset in that block (Device::new_buffer,
  not zeroed, as heap memory is not). That is rt's own answer.
- An automatic heap's suballocation, and a heap buffer with no offset, answer TheConsumers.
- heap_own_facts, heap_max_available_size, set_heap_label and heap_purgeable_state answer
  TheConsumers.
"MTLHeap and its getters" is one of the planner's closed objects of the consumer's own, named
in rt's README.

rt_side/work.rs's heap maker is now heap_of, which both callers share.

Verified: nothing yet; the next check job compiles it.
2026-11-18 16:18:06 -08:00
Anees Iqbal f98a38eda1 conformance: the consumer's own reason takes the planner's closed list of objects, counted apart
The planner approved the third reason with conditions (11-18), and this commit applies them:
- The object is one of a closed list, ConsumerObject: the render pass descriptor's read-back,
  MTLHeap and its getters, the encoder's dispatchType, and MTLTexture's cpuCacheMode,
  hazardTrackingMode and allowGPUOptimizedContents. A row naming any other object fails to
  parse. Adding a variant is the planner's ruling.
- A row takes the reason only where rt's public API has no item that could answer it. The
  device's size and alignment of a resource in a heap stays rt's.
- rt's README names each object as the consumer's, in a new section "What the consumer
  implements", and a test holds the two together.
- The count prints on a line of its own, outside the cutover's count.

Verified: nothing yet; the next check job runs the conformance tests.
2026-11-18 16:18:06 -08:00
Anees Iqbal 13997a4888 conformance: the ledger's third typed reason, "the consumer's own (<object>)", counted apart
Some Metal objects and getters have no rt counterpart by design: rt's RenderPassDescriptor is
a value its consumer fills, its memory blocks are no MTLHeap, and an encoder keeps no
dispatchType getter. A row for one of those now states it as a typed reason,
Reason::TheConsumers { object }, under the head "refused: the consumer's own (<object>)".
The replay's count line prints those rows apart, by object. This is the third reason beside not
built yet and no stream uses it yet. It is written ahead of the planner's ruling, at main's ask,
so a yes lands without rework. No row states it yet.

The reasons test parses one such row, counts it on the line, and refuses the head with no object.

Verified: nothing yet; the next check job runs the conformance tests.
2026-11-18 16:18:06 -08:00
Anees Iqbal b62863b786 conformance: every draw-forms case declares device-point-size, a static note of its state
The family's vertex function, icb_merged_vertex, writes [[point_size]]. A device whose largest
point is below Metal's notes that, and the cases declared the notice only where they draw
points: the old runtime announces it at a draw of points. rt's render state carries it as a
static note of the state, whatever primitive the draw takes, as rule 1 asks. So on rt,
render-draw-forms-lines announced it with every draw site matching Metal (R3, job 48327), and
its notices site diverged as undeclared.

Every case of the family now declares it. The family test holds each to the declaration and to
its count. On the old runtime, the triangles and lines declarations never fire, which counts
and fails nothing.

Verified: the lines case's divergence in 48327; the next check job runs the family test and
the slice.
2026-11-18 16:18:06 -08:00
Anees Iqbal 67fd507159 conformance: the rt side answers a render pass descriptor's read-back as the consumer's own
pass_descriptor_facts (357 rows in R2b, job 48281) asks what Metal's MTLRenderPassDescriptor
answers of its fields after a sequence of setters. rt has no descriptor object: its
RenderPassDescriptor is a value its consumer fills. The call now answers TheConsumers, saying
so, in place of Unavailable. The read-back is one of the planner's closed list of objects of the
consumer's own (Reason::TheConsumers) and is named in rt's README. Its rows wait for that
reason's landing.

Verified: nothing yet; the next check job compiles it.
2026-11-18 16:18:06 -08:00
Anees Iqbal d9adf23f72 conformance: rt_side/work.rs names the blocks a buffer or heap holds alive
Made::Buffer and Made::Heap held their blocks in tuple fields that nothing reads, which rustc's
dead-code lint names. They are now named fields, _blocks and _block, beside the buffer and the
range the steps read.

Verified: nothing yet; the next check job's clippy covers it.
2026-11-18 16:18:06 -08:00
Anees Iqbal 8578f925ce conformance: the rt side reads back the textures it makes; three getters are the consumer's
BufferTextureFacts' cpuCacheMode, hazardTrackingMode and allowGPUOptimizedContents are now
each the Value a side recorded, not a bare integer or bool. The Metal side and the old runtime's
side record what they read, as before, so the sites keep the same names and values. The rt side
records its refusal at those three sites alone: TheConsumers, the planner's closed object for
the three texture descriptor fields. rt's TextureDescriptor states none of them, and its README
names them as the consumer's.

With that, the rt side answers two calls through rt:
- queried_texture_facts (201 rows refused in R2b, job 48281): Device::new_texture of the query,
  read back from its descriptor;
- buffer_texture (23 rows): Buffer::new_texture on a buffer of the request's length and storage,
  made as rt_side/work.rs makes one (buffer_of).

Verified: nothing yet; the next check job compiles it on Linux. metal_side.rs, which compiles on
macOS alone, changes three field expressions and needs a macOS build.
2026-11-18 16:18:06 -08:00
Anees Iqbal 80c0e1d72a conformance: the rt side's render target over a buffer is the buffer's texture
A render case's target over a buffer (TargetSpec::over_buffer) answered Unavailable
(newTextureWithDescriptor:offset:bytesPerRow:, 12 rows in R2b, job 48281). It is now the buffer's
Buffer::new_texture of one level of 2D, at the next texture index where a shader reaches it. As
the old runtime's side makes it, the storage is the buffer's, and a stride that would end Metal's
process is refused before anything is made.

Verified: nothing yet; the next check job compiles it.
2026-11-18 16:18:06 -08:00
Anees Iqbal 99ddc603f6 conformance: the rt side runs copy-and-fill programs (Side::work)
rt_side/work.rs runs a Work program on rt as runtime_work.rs runs it on the old runtime. The
resources are made in order. The steps go into one blit encoder at a time, and the reads are
answered after a bounded wait. R2b (48281) refused 253 rows at "work". The previous commit
names this module, which lands here.

The side is rt's consumer and places memory itself:
- a buffer takes a block of its own, zeroed as newBufferWithLength: is;
- a Managed buffer takes a Shared block for its bytes, plus a Private block for the device's
  copy where the device keeps one;
- a placement heap is a block of its storage, and its buffers (not zeroed, as Metal's are not)
  and textures are placed in it.
A texture a shader reaches takes the next texture index.

The steps rt has no counterpart of answer Unavailable with their Metal call:
- the two fills, which are Apple SPI with carried Metal answers;
- the whole-texture and slice copies;
- generateMipmapsForTexture: and the two optimize calls;
- synchronizeTexture:slice:level:;
- a copy with a depth, stencil or PVRTC blit option.
A heap of Managed or Memoryless storage and a Memoryless buffer are unavailable too. Metal
makes neither.

Verified: nothing yet; the next check job compiles it and runs the whole set.
2026-11-18 16:18:05 -08:00
Anees Iqbal 6be9bce5ba conformance: the rt side makes whole texture requests and answers the texture queries it has
The rt side answers through rt's own calls:
- Side::texture: Device::new_texture, Buffer::new_texture or Texture::new_texture_view, each at
  the next texture index where a shader reaches the texture, then the request's uploads. R2b
  (48281) refused 198 rows of 143 cases at "texture".
- read_texture_over (62 rows).
- heap_texture_size_and_align (850 rows).
- makes_texture (500 rows).
- minimum_linear_texture_alignment (16 rows).

rt's descriptor has no allowGPUOptimizedContents. The flag permits a device layout and leaves
the texels Metal answers unchanged, so the request's flag asks rt nothing. A view with a
swizzle other than the identity stays unavailable, because rt's view call takes none.

makes_texture answers true for a texture made. Every rt error is recorded as our failure, because
none of rt's texture errors is one Metal answers nil for. The query descriptor states each field
as the query does, zeros included.

RtDevice::texture_index is the one rule for which textures take an index: shader read or write,
or no bit, which rt takes as every usage.

Verified: nothing yet; the next check job compiles it and runs the whole set.
2026-11-18 16:18:05 -08:00
Anees Iqbal 03c7594c97 rt tests: the extensions test counts the tests' own driver's extensions and direct loading
Through direct driver loading (the M3's suite, M2V_DIRECT_DRIVER naming Mesa's Mac driver), the
instance enables each extension the loader or the given driver lists, then
VK_LUNARG_direct_driver_loading; the loader does not list a direct driver's instance
extensions. The extensions test built its expectation from the loader's list alone, so it failed
there (job 48614: 284 of 286 passed, this test and the expected timestamp red). It now adds the
tests' driver's own list where one is given, and expects direct driver loading last.

Verified: the jobs named in the landing message (the M3's suite through the driver, and the
Linux gate on the loader's route).
2026-11-18 16:16:23 -08:00
Anees Iqbal f1f846e636 rt docs: the consumer's own drivers in the guide, the validation ladder and the surface table
`Instance::with_drivers` and `Error::NoDirectDriverLoading` are public: the runtime's guide
says what the call does, what it refuses and what it leaves to the consumer (loading the
library and keeping it loaded); docs/VALIDATION.md says how a job runs the device tests through
it (`M2V_DIRECT_DRIVER`) and what shows the path ran; the signature table takes the two records
(scripts/api-signatures/signatures.py --bless). docs/REFUSALS.md regenerated unchanged: the
variant refuses nothing Metal accepts, it says the host's loader lacks an extension.

Verified: the generators' output; the build and the tests in the jobs named in the landing
message.
2026-11-18 16:16:23 -08:00
Anees Iqbal 7043d1a290 rt: an instance takes the consumer's own Vulkan drivers, through direct driver loading
A consumer that ships its own Vulkan driver (on macOS, Mesa's Mac driver in its own bundle) has
no way to give rt that driver but the loader's variables, which rt never reads. `Instance::
with_drivers(extensions, drivers)` takes the drivers' `vkGetInstanceProcAddr`s (for a driver
built for the loader, the `vk_icdGetInstanceProcAddr` it exports). Given any, the instance
enables `VK_LUNARG_direct_driver_loading` and chains the list in its exclusive mode, so the
loader loads those drivers alone; where the loader does not offer the extension, it refuses with
the typed `Error::NoDirectDriverLoading`. The loader does not ask such drivers for their instance
extensions, so an optional or requested extension is enabled where the loader or one of the
drivers lists it. With no driver it is `Instance::new`, which now calls it: nothing changes for
a consumer that gives none, on any host. rt itself searches for nothing, reads no variable and
names no driver.

The device tests' instance (tests/validation.rs) loads the library a job names in
`M2V_DIRECT_DRIVER` and gives it through `with_drivers`, so the M3's device suite runs through
it; elsewhere the job's `VK_DRIVER_FILES` stays the route.

Verified: rustfmt; the build, clippy and the tests in the jobs named in the landing message.
2026-11-18 16:16:23 -08:00
Anees Iqbal 97b5f53b2c validation: the unmarked-completion test asserts the order and an exact account of M
runtime_lane::joined_completions::an_unmarked_command_buffer_is_seen_complete_at_its_own_end
failed in the lavapipe leg of the b7c5a59920 round (m3-max-48393, msi, the loaded suite) with
Moved { grouped: 0, closed: 0, submissions: 3, unkept: 1, grouping: true }. The order it names
held (at U's completed handler, M complete and L still running). The old runtime groups U behind
M only where its scheduler's pass finds U ready with M (command_buffer/group.rs, Alone::Unkept),
which a loaded host may not, so grouped >= 1 && closed >= 1 was a timing result.

The test keeps the order assert and states M's fate exactly: three kernel submissions, or two
with M and U in one (submissions + grouped == 3); where they grouped, U closed M's group with
two batches; where M went alone on a grouping device, one reason counted it (unkept or run
long). The old runtime is unchanged. That M and U group on an idle device is a rate for an
exclusive job, not the shared suite.

Verified at this tree (m3-max-48575, msi, lavapipe as the leg builds it: --cfg m2v_cpu_icd,
LP_NUM_THREADS=1): validation clippy clean; the joined-completions module's 5 tests pass alone;
the order test passes 3 of 3 rounds under 48 busy loops on 24 CPUs, each with M and U grouped
(grouped 1, batches 2, closed 1) and (M, L) completed (true, false) at U's handler. The leg's
failing account (grouped 0, submissions 3, unkept 1) meets the alone branch.
2026-11-18 16:11:52 -08:00
Anees Iqbal aedf88330e translator tests: the lockstep step-cost tests judge work and ledger, under no deadline
tests::engine_simd_lockstep::the_authored_4096_step_kernel_compiles_inside_the_budget failed
in the lavapipe leg of the b7c5a59920 round (m3-max-48393, msi, the loaded suite) with
"4096 steps inside the standard budget: Budget(Time)" after 27.0 s: 11,747,827 work units,
ledger peak 161,960,281. Its own doc says its work stands for its time (2.4 s in release on the
slowest CPU measured); the 20 s deadline of Budget::standard() is a wall-clock threshold, and a
debug build beside other jobs crossed it.

steps_cost, which all three step-cost tests use, now meters under Budget::default(): the
standard work and ledger caps (Meter::new), no deadline. The asserts on work units and the
ledger peak are unchanged. The 20 s ceiling is release-mode timing's, in an exclusive job.

Verified at this tree (m3-max-48575, msi, built as the lavapipe leg builds: --cfg m2v_cpu_icd):
clippy of the translator and validation clean; the three step-cost tests pass alone (4096
steps: 14,218,766 work units, ledger peak 207,901,502); the 4096-step test passes 3 of 3 rounds
under 48 busy loops on 24 CPUs, taking 29.5 to 32.2 s, past the 20 s the old deadline allowed.
2026-11-18 16:11:52 -08:00
Anees Iqbal 695b31f1c7 validation: a cache run returns once its device's entries are on disk
runtime_lane::cache::a_second_process_reads_the_first_ones_translations failed in the matrix
round at 795c834ded (lavapipe leg, m3-max-48283: the second process hits=0 misses=1 writes=1)
and passed alone there 3 of 3 (m3-max-48401). The test took the first device's entries to be on
disk once its drop of the device returned. The old runtime's cache thread writes each entry
after the making hands it over (ShaderCacheStatistics::writes counts the hand-over, before the
file exists), and writes the rest when the device's last handle goes (shader_cache/worker.rs).
That handle may be another thread's: a command buffer a completed handler's thread lets go of
after the test's drop (device/holds.rs). Under the leg's load the second process could start
before the cache thread wrote an entry, and compiled it again. A probe of the files the cache
held as the child started found one missing in 2 of 12 loaded rounds (m3-max-48434).

cache_run now returns once the run's entries are on disk: the translator's artifacts
(M2VARTF\0) up to writes, and the makings' records up to driver_saves where the driver's data
is kept, waiting at most a minute (a watchdog). It prints how many were on disk as the drop
returned. Every cache_run caller had assumed the same; the collision test reads the artifact
file at once.

No test here fails without the wait on demand: the cache thread's timing is the runtime's, and
unloaded it writes each entry before the run reads its statistics. A test where a buffer of the
device went a second after its drop passed with the wait taken out (m3-max-48509), so it is not
kept. The evidence for the race is the probe's count above.

Verified at this tree (m3-max-48556, msi, lavapipe as the leg builds it: --cfg m2v_cpu_icd,
LP_NUM_THREADS=1): validation clippy clean, the cache module's tests pass, and the second-process
test passes 5 of 5 rounds under 48 busy loops on 24 CPUs, each printing its run's entries on disk
as the drop returned (1 of 1 functions; lavapipe keeps no driver records).
2026-11-18 16:09:42 -08:00
Anees Iqbal 35478ab1dd rt README: on lavapipe a completion waits for the device's later work, a known gap
lavapipe's vkGetQueryPoolResults begins with a vkDeviceWaitIdle of the whole device, with or
without VK_QUERY_RESULT_WAIT_BIT (lvp_query.c:122 in 26.3.1 and on Mesa's main branch). The
completion thread reads each command buffer's two timestamps there, so on that driver a
completion waits for everything submitted after it, on every queue: the reason the cross-queue
timestamp test runs on GPUs alone. The gap goes where a reader of the runtime's guide finds it,
in the queues' known gaps, beside the Apple driver's timestamp gap.

It is a delay, never a hang. The runtime holds on the host a segment whose wait only the host
can meet, and submits a semaphore wait only once its signal is submitted, so no submitted work
waits on the host and the device always reaches idle. A probe (queue A's command buffer waiting
on a shared event that queue B's completed handler sets, A committed first) completed on
lavapipe 2.2 ms after its commit, B's handler at 1.4 ms.

Verified: job 48578 (ms01, lavapipe 26.2.6: a standalone Vulkan repro read completed timestamps
500.4 ms late, three runs alike, once a later batch waiting on a host-signalled semaphore could
run) and job 48567 (the probe, under the validation layer). The probe was not committed here.
The upstream draft is staged for the owner.
2026-11-18 16:07:44 -08:00
Anees Iqbal 5ca131f173 rt README: on Mesa's Apple driver a timestamp reads the end of its encoder, measured
The known gap said a command buffer with no render pass reports its GPU start equal to its end.
A Vulkan-only repro (two timestamps around a 16 ms compute dispatch, recorded six ways, under the
validation layer and without it, Mesa 26.3.1 on an M3 Max) shows the rule behind it and one more
case a program reads:

- one command buffer of stamp, dispatch, stamp: 0 µs apart; the same with a pipeline barrier, a
  buffer fill or a second dispatch and stamp between: 0 µs, every stamp one value;
- an empty render pass after the dispatch: 43-56 µs apart, with the first stamp 16.1-16.3 ms
  after the submit, so the start stamp reads the end of the compute encoder holding it;
- each stamp in a command buffer of its own: 16.06-16.15 ms, against 16.3-16.5 ms from submit to
  fence;
- the end stamp, placed on the host clock by a calibration taken as the fence wait returned:
  51-213 µs before it (calibration deviation 1-4 µs), so the end is not late.

KosmicKrisp writes each stamp into the open compute encoder with
MTL4TimestampGranularityRelaxed (kk_query_pool.c, bridge/mtl_encoder.m), and its compute encoder
holds the compute and blit work up to the next render pass or the command buffer's end. Mesa's
main branch at 69489e21 still writes them the same way. So the gap now says what a program
reads: the start is the end of the work before the first render pass, the end is right.

Verified: jobs 48534 and 48548 on the M3 (the repro; validation clean); the facts above are
from 48548's two runs of three rounds each.
2026-11-18 16:00:33 -08:00
Anees Iqbal fea5d3a53b rt tests: the cross-queue timestamp test runs on GPUs alone
On lavapipe a query pool's results are read only once the whole device is idle:
lvp_GetQueryPoolResults waits for the device, with or without VK_QUERY_RESULT_WAIT_BIT. A
completion that reads its command buffer's GPU times there waits for every queue's work, and the
test's short command buffer completes only once the long one ends. That is the driver's, and
the CPU device cfg is not where this test's claim is checked, so the module compiles under
--cfg m2v_gpu alone, with the reason in its doc.

Verified: the GPU legs named in the landing message.
2026-11-18 16:00:33 -08:00
Anees Iqbal 84e2f01b61 rt tests: the cross-queue timestamp test names the probe's times and status where it has no GPU time 2026-11-18 16:00:33 -08:00
Anees Iqbal 6a66ea744e rt tests: a short command buffer reports its GPU times while another queue's long one runs
The old runtime carried a driver fact that timestamps wait for every queue (MoltenVK), and the
tree had no test of what it guarded: a command buffer whose completion, with its GPU times, waits
for another queue's work. The new runtime holds no driver facts, so the device suite now checks
the behaviour on every device it runs on.

The test commits a short stamped command buffer on one queue, then a long one (sized from a probe
to about 250 ms of GPU time, at most 20,000 dispatches) on another, both submitted before either
runs: behind the tests' batch that waits for a timeline semaphore the host signals (Busy, whose
wait's second scope holds every command later in submission order). Each must be Scheduled
before the host opens it. The short one runs first; its completed handler, which reads its GPU
times, must run before the long one's GPU end and before the long one's handler. A driver whose
timestamps become readable only once every queue's work (or all the work submitted after them)
completes would hold the short one's handler until the long one ends: a guest-visible stall of
one queue behind another's frame. No timing threshold decides it: the short one's handler time
against the long one's GPU end, both on the host clock.

Verified: (the jobs named in the landing message: lavapipe and a GPU on Linux, and the M3 through
Mesa's driver).
2026-11-18 16:00:33 -08:00
Anees Iqbal 5f2494bfc5 replay: the player opens the new runtime's GPU only while the hang tripwire is absent
The old runtime's device opener refuses a GPU while ~/.cache/m2v-gpu/hang
exists (command-replay prints "error device: ..." and exits 2), but the
new runtime's path opened its device without looking, so rt plays in a
job that followed a hang ran anyway. docs/VALIDATION.md already states
the contract: every GPU open is refused while the file exists.

open_rt now checks the tripwire once, before it makes the instance, for
a GPU only (a CPU device never checks it), as
candidate::runtime_case::open_device does; the refusal takes the same
"error device" line and exit 2. The guard test
gpu::tests::device_opens_exist_only_behind_the_tripwire_check now
counts the new runtime's device opens too (the player's and the replay
tests' rt_device) and fails where a file opens one without the check
before it.

Verified: see the check job (clippy in both configs, the gpu and
replay unit tests, and a negative control: the player without the check
fails the guard test).
2026-11-18 15:57:02 -08:00
Anees Iqbal e56b590a5d harness: the idle latency method takes clippy's naming, no from_ on a method of self
Clippy's wrong_self_convention refused `Handled::from_idle_us(&self)` (job 48452: CLIPPY,
CLIPPY_GPU and CLIPPY_CPU_ICD 101 on aa23f46303), so the method that gives each run's time from
its first commit to its last completed handler is `idle_latency_us`. The report's field keeps
its name, `Report::from_idle_us`.

Verified: rustfmt --check on both files; clippy in the gate job named in the landing message.
2026-11-18 15:51:28 -08:00
Anees Iqbal 43809bcc09 matrix: the Windows build is sized from its measured runs, 10 GiB and 15 minutes
Its jobs reserved 16 GiB for 60 minutes. Measured on the mini: a peak of 6.7 GiB and 29 s, 4m02s
and 3m45s a run (m3-max-48387, -48266, -48124); the longest cargo build of the 50 runs the
matrix keeps took 6m45s (29 crates compiled). 10 GiB is 1.5 times the peak, and 15 minutes over
twice the longest build, for a cold one. The minutes stay the floor of the measured sizing, and
a run that wants more RAM still runs again with twice its room, up to the default.

Verified: test_matrix (the sizing and retry tests at the new defaults).
2026-11-18 15:51:27 -08:00
Anees Iqbal d3bfe3815d harness, matrix: a frame row is its throughput, and its latency from idle a row of its own
The planner's metric for the frame rows. A frame row's time was its runs' last command buffer's
commit-to-complete time with two runs in flight, which mixes the time a frame adds with how long
it waits behind the one before. Now `frame` and `frame_5cb` (Plan::frames) carry two figures,
each the steady time (best window of ten) of the harness's own completed-handler times:

- THROUGHPUT, the row of record (matrix_time): two runs in flight, from one run's last completed
  handler to the next's. The pairs around the waits that read the gauges after runs 100 and 200
  (GAUGE_RUNS) are left out, as an untimed run sits between them.
- LATENCY FROM IDLE, the row `<row>_from_idle` (FROM_IDLE): as many runs again after the timed
  ones, one in flight, each committed once the one before it completed, from just before its first
  commit to its last completed handler.

The completed handlers now report the time of their commit and of their own run against one
origin (Completions, Handled), so the commit-to-complete times, the throughput and the latency
come from one record. The frames' commit-to-complete time is still printed, as
`<row>/commit_to_complete`, which the matrix shows and does not judge (SHOWN_ROWS) for one round.
Each latency row takes the ceiling and floor its workload's row has (listed_row), in the budget,
the over table and the re-time selection, and is re-timed through its workload's runs. Other
workloads are unchanged, long_4cb's commit-to-complete time included. The shape follows core's
one-run-in-flight probe (3eaec97076), without its environment gate.

Verified: test_results (a new test: a latency row past its workload's ceiling and the budget,
the commit-to-complete row shown and never judged, the over table and the re-time selection
choosing the latency rows); the harness's unit tests gain the throughput and latency arithmetic
(the gauge pairs left out) and matrix_time's frames case; the harness gate job named in the
landing message runs clippy, rustdoc, the unit tests and the authored workloads on lavapipe.
2026-11-18 15:51:27 -08:00
Anees Iqbal 0835986c12 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 15:51:07 -08:00
Anees Iqbal f850bceecd rt tests: the base-instance draw reads its texels as arrays, as clippy's as_chunks asks
R3 (job 48327) failed clippy on the cpu_icd build: chunks_exact_to_as_chunks at draw.rs:885. The
texels and their words are now read through as_chunks, which needs no unwrap.

Verified: the lint's line in 48327; the next check job runs clippy again.
2026-11-18 15:50:12 -08:00
Anees Iqbal aaa851abd4 rt: a draw takes the translator's base-vertex fact, the floor's own built-ins
With shaderDrawParameters in the floor, the translator reads a vertex function's [[base_vertex]]
and [[base_instance]] from Vulkan's BaseVertex and BaseInstance and still states
RuntimeFact::BaseVertexInstance (its mechanism is the built-in). The render state's draws()
refused every fact it did not name as DrawInput, so the five draw-form cases that the floor change
moved past IdentityDomains stopped at DrawInput instead (R2b, job 48281:
render-draw-forms-{points,triangles,lines,empty} and primitive-type-restart-indices). The fact is
now accepted; the push field the translator places without the feature stays a push field the
encoder does not fill, refused as before.

A device test draws icb_merged_vertex (which reads [[base_instance]]) from base instance 3 into an
RGBA32Uint target and reads the mark, instance ID and base instance at every texel. Without this
change the state is DrawInput and the test panics at state().

Verified: the DrawInput rows in 48281; the test runs in the next check job.
2026-11-18 15:50:11 -08:00
Anees Iqbal 3a776e04d0 rt tests: the floor's fixture device offers shaderDrawParameters
The previous commit put shaderDrawParameters in the floor, and the floor tests' at_the_floor
device did not offer it, so every test built on that device read it as below the floor (16 of the
floor tests in R2, job 48262). The fixture now offers it beside multiview.

Verified: the 16 failures and their panics (floor.rs:205 and :123, below the floor) in R2; the
rerun is the next check job.
2026-11-18 15:50:11 -08:00
Anees Iqbal 526674b96c rt: shaderDrawParameters joins the floor, so a vertex function's draw bases are SPIR-V's own
Five sites of the rt conformance side refused under the identity domains: render-draw-forms (four
draws) and primitive-type-restart-indices. Each reads `[[base_vertex]]` or `[[base_instance]]`.
Without `shaderDrawParameters` the translator lowers those to `PushField::BaseVertexInstance`,
which the binder writes per draw. The identity domains admit no such field, so the pipeline was
refused.

The floor now requires and enables `shaderDrawParameters` (VkPhysicalDeviceVulkan11Features).
`Device::from_queries`' profile then has `draw_parameters`, and the translator reads SPIR-V's
`BaseVertex` and `BaseInstance` built-ins (stage_io's existing structural rule), with no push
field. Vulkan 1.1 requires the feature of a device that lists VK_KHR_shader_draw_parameters, and
Roadmap 2024 of every device. The survey of the cluster's devices found it on every one: NVIDIA,
RADV, ANV, lavapipe, the M3 under KosmicKrisp, and the UHD 630 on Windows.

- rt-only. `Device::new` is unchanged, and so is the old runtime's push-field form.
- floor.rs: REQUIRED gains the feature. tests/floor.rs: the missing-feature cases are 38, and the
  enabled set holds it. README: the floor table's row.

Verified: the change's check job and the conformance run of the five sites, both named in the
report to main.
2026-11-18 15:50:11 -08:00
Anees Iqbal cc2d0fde45 translator tests: the old runtime's render descriptor key under semantics version 2183
The key hashes SEMANTICS_VERSION, which the snorm note bumped to 2183, so its pinned value
moves, as it did at 2181 (727df9b7ed) and 2182 (d6a1a86d98). The fixture's bytes are unchanged.

Verified: m3-max-48429 printed the new key (93a63310...) as the test's left side, at the snorm
note's tip with the series beneath it.
2026-11-18 15:50:11 -08:00
Anees Iqbal f18934e3c2 translator: the snorm note bumps SEMANTICS_VERSION to 2183 and ARTIFACT_FORMAT_VERSION to 538
The previous commit appends PrecisionNote::SnormMinimumKept to the codec's note list and records it
on a Device::from_queries profile's render pipelines into a single-sampled snorm attachment. That
changes the artifact format and the artifact under an unchanged source and profile, so both
versions go up. Identity's group 4 (d6a1a86d98) took 2182 and 537. Its change (the lockstep
barriers' one-row variant) touches compute kernels and no render pipeline note, so this note's
semantics do not depend on it.

Verified: the change's check is named in the report to main.
2026-11-18 15:50:11 -08:00
Anees Iqbal 6d4ca09039 translator: a render pipeline into a snorm attachment records SnormMinimumKept on Device::from_queries
metal2vulkan-rt's conformance side ran the six snorm-store cases on lavapipe (job 48051). Each
diverged where Metal's tile store writes a loaded minimum code (-128, or -32768) back as the code
above it, and the device's pass keeps the bytes. The old runtime announces that as
`snorm-minimum-kept` at the draw, from its encoder (render/tile_store.rs). The new runtime has no
such encoder step, and the translator recorded no note, so the answer went unannounced. A missing
static note is a bug (rule 1: a static note fixed per operation).

- `PrecisionNote::SnormMinimumKept` (appended): the note of a render pipeline that draws
  single-sampled into a color attachment of R8Snorm, RG8Snorm, RGBA8Snorm, R16Snorm, RG16Snorm
  or RGBA16Snorm.
- `pipeline::private_state::note_snorm_minimum` records it on the fragment stage (the vertex
  stage where there is none), whatever the pass loads. That is static, so it may over-announce
  a cleared pass.
- It is recorded only where the profile's new fact says `SnormMinimumNote::Noted`. That is
  `Device::from_queries` (ProfileFacts::EVERY); `Device::new` (ROWS) stays `Announced`.
  `Device::new`'s modules, keys and the old runtime's announcement are unchanged.
- The old runtime maps the note to its existing `Degradation::SnormMinimumKept` (an explicit
  `from_precision_note` arm). Validation's comparison allowance is Unbounded, as for the other
  device-answer notes. The codec takes the variant, and ARTIFACT_FORMAT_VERSION goes from 536 to
  537. fast_paths lists the note under Elsewhere. api_signatures gets the two variant rows and the
  macro row. docs/API.md's `snorm-minimum-kept` entry says where the static note is recorded.

Test: engine_private_render_state's
a_snorm_attachment_notes_the_minimum_code_metal_s_pass_rewrites. On lavapipe and moltenvk-m3, for
each of the six formats, the note is on the fragment stage alone through Device::from_queries and
on no stage through Device::new. No stage records it at four samples, or into RGBA8Unorm or
RGBA16Float. The six conformance cases on the rt side are the end-to-end test (the check job's
replay, named in the report).
2026-11-18 15:50:11 -08:00
Anees Iqbal 2cf3e3732c conformance tests: the only-ours refusal test names its site from the transcript's root
a_failure_only_ours_records_is_a_refusal asserted the refusal at "row/pass". A transcript's
root is the node "case", so compare names the site "case/row/pass", as every other path test
here does. R3 (job 48327) failed the test there, the only failure in the conformance suite's 1056.

Verified: the FAIL line in 48327; the next check job runs the test.
2026-11-18 15:50:11 -08:00
Anees Iqbal ac2b7d185c conformance: the typed reasons' parser names its head and name without a complex table type
R2's clippy (job 48281) refused Reason::of's table of heads and constructors as a very complex type
(clippy::type_complexity, -D warnings). The parser now reads each head through named_after, which
answers the name in parentheses after a head, None where the field does not start with it, and
why where the parenthesis is missing or empty. The test of the typed reasons is unchanged.

Verified: the clippy error in R2; the rerun is the next check job.
2026-11-18 15:50:11 -08:00
Anees Iqbal 8151b862f6 conformance: a failure only our side records reads as a refusal, not as a site only ours observed
Twenty-five render cases record a piece of work's failure where it failed, as a leaf beside the
row's answers: the pass, the read-back. Metal's piece does not fail, so Metal's transcript holds
no such leaf. The cases' comments say the leaf "compares against Metal answering and reads as a
refusal rather than a divergence", but the comparison read any site only ours holds as
"only ours observed this site". On the rt side, point-viewport-coverage's 439 divergent rows were
of that kind: each row's refused draw of points ("a draw with Points is not built") read as a
site only ours observed beside a coverage of DrewNothing.

compare's walk now reads a site only ours holds whose value is our typed error as a refusal at
that site, through the same refusal path as an error where Metal answered. A site only ours holds
whose value is an answer still diverges. The old runtime's ledger lists no "only ours observed"
row, so its runs hold the same rows.

Test: a_failure_only_ours_records_is_a_refusal. A refused leaf only ours holds is one refusal at
its site and no divergence, and an answered leaf only ours holds is one divergence and no
refusal.
2026-11-18 15:50:10 -08:00
Anees Iqbal 659bde1fb4 conformance: the rt compute pass shares render's held_sampler and names its step compute_step
ec54e48751's compute module defined held_sampler and step on RtSide, which render.rs defines too
(E0592, duplicate definitions, in R2's clippy: job 48262). The compute pass now uses render's
held_sampler, made pub(super), and its own step is compute_step. The offer test named
VkExtension::KhrShaderDrawParameters, which the translator's VkExtension does not have; it
names ExtShaderStencilExport.

Verified: the three compile errors in R2's clippy; the rerun is the next check job.
2026-11-18 15:50:10 -08:00
Anees Iqbal 96bb2b8fe1 conformance: the ledger's typed reasons, "not built yet" and "no stream uses it yet", counted on every replay
The planner allows two reasons for the rt ledger's refusal rows, provided they are the ledger's own
vocabulary and not text typed per row:

- `refused: not built yet (<lane>)`: a feature the streams use that a lane is building (multisample,
  depth attachments, tessellation, ICB pipeline states, points, the identity refusals). The lane is
  named on the row, and the landing that builds the feature deletes it.
- `refused: no stream uses it yet (<census run>)`: a call that replay's census found no stream
  using. The row names the census run. The day a census finds a use, the reason becomes "not
  built yet" with a lane.

known_gaps::Reason holds them. A row states one at the head of its waiting-on field.
KnownGap::reason reads it, and parse refuses a head that names the vocabulary without its lane or
census run. Every other row's reason stays its own words. known_gaps::open_work counts the rows by
lane and by census run, and `conformance replay` prints that line on every run, green or red:
the not-built-yet count is the cutover's remaining work, and it must be zero at the cutover.

Test: the_ledger_s_typed_reasons_parse_and_count. Both reasons parse with their names, a row in
words stays words, the count line sums by name, and a head without its name, or with an empty one,
is refused.
2026-11-18 15:50:10 -08:00
Anees Iqbal 4e10f26894 conformance: the rt side runs compute passes, and a refusal of what the device offers is the runtime's
Two changes toward a ledger-clean whole-set replay of the rt side.

- compute_pass, ported (rt_side/compute.rs). It runs one encoder of the case's steps on rt's
  ComputeCommandEncoder, then commits and waits as the render work does. The range setters set
  their slots one by one, which is what Metal's range calls do. Both barrier forms are rt's one
  memory_barrier, and useResources is a loop of useResource. The steps rt has no call for answer
  Unavailable with their Metal call and the pass goes on: the attribute-stride setters,
  setStageInRegion, the LOD-clamped samplers, and useHeap(s). The encoder's dispatchType answers
  TheConsumers, as the command-buffer facts do: rt takes it as the encoder's argument and keeps no
  getter. Before this, vector-word-phases-{0,4,8,12} and buffer-bind-off-alignment, among 13
  cases, were refused at compute_pass.
- A translator refusal that names capabilities read as the venue's lack (lacks-feature) even where
  the device offers them. On lavapipe, "the venue lacks SampleRateShading" was printed with
  sampleRateShading = true. The rt side now reads what the physical device offers
  (DeviceDescription::query at the floor's version, once, when the device opens). A refusal is the
  venue's lack only where the device offers none of its alternatives. Otherwise the capability is
  one rt's floor leaves off, a typed refusal of the runtime's, and the case reads as refused. That
  is 130 cases on lavapipe, which the ledger then has to name: SampleRateShading 72,
  FramebufferFetch 45, StageStoresAndAtomics 6, StencilExport 2, AlphaToOne 2, one each of the
  rest.

Test: a_refusal_of_what_the_device_offers_is_the_runtime_s (rt_side::offers_one): an alternative
offered whole makes the refusal the runtime's; one offered in part, one not offered, and a refusal
naming no alternative do not. The whole-set run is the check job named in the report to main.
2026-11-18 15:50:10 -08:00
Anees Iqbal 58229ccd71 replay: a copy back to the guest's RAM plays as buffer copies into a sink
The new runtime's backend skipped m2v.copyToGuestRam and counted it, so
every play's verdict ended at the first one (u2 frame 97, u3 frame 99),
though nothing in a play reads that RAM. The planner ruled it does not
end the played range, and that work the recording host did live plays
as the runtime's, cost included.

It now plays as the old backend's does: each run copied by the blit
encoder, in its order, into a Shared place of the play's own that
nothing reads, each run widened to the whole words it touches within
the buffer (a buffer copy takes whole 4-byte words). The place is given
back at the command buffer's commit, as a copy from the guest's RAM
gives back its staging. The report counts the bytes
(copied_back_guest_ram_bytes); skipped_guest_ram_reads is gone.

Verified: see the check job (a new rt_replay device test: nothing
skipped, the widened bytes counted, the buffer's bytes kept).
2026-11-18 15:47:00 -08:00
Anees Iqbal 18c9247943 rt tests: a store's settle joins its removal thread, the last look for a dead generation included
tests::cache::a_torn_or_missing_state_is_rebuilt_from_the_generations failed in the matrix round
at 795c834ded (lavapipe leg, m3-max-48283: "rebuilt from one listing", left 0, right 1) and
passed alone there 3 of 3 (m3-max-48401). The cause is the test helper, not the store and not
the range 140714ceae..795c834ded: Store::settle waited only for `removing` to clear, which the
removal thread does before its last look for a dead generation. That look reads the state
(Store::dead calls Store::current) and rebuilds one that does not check. Under the leg's load
the thread of the test's first store made that look after the test had torn the state for its
reopen, so it rebuilt the state itself and the reopened store found it whole and listed nothing.

settle now joins the removal thread (Store::join_removal), as its doc says it waits for the
thread to end. A test-only pause before the last look (LAST_LOOK_PAUSE) makes the race
deterministic: a_settled_stores_removal_reads_the_state_no_more tears the state after settle and
checks that nothing listed or wrote it 400 ms later, with the last look 200 ms behind.

Verified (m3-max-48462, msi, at the fix's tree): rt clippy --all-targets --all-features clean;
the 18 tests::cache tests pass; under 48 busy loops on 24 CPUs both state tests pass 10 of 10
rounds. Control, the old settle with the new test: it fails 7 of 7 runs (listings 2, wanted 1),
6 of them under load.
2026-11-18 15:41:40 -08:00