Commit Graph
101 Commits
Author SHA1 Message Date
Anees Iqbal 8c3fae2243 replay: the rt arm plays guest-RAM copies in the host's one-copy form
The new runtime's backend played a copy back to the guest's RAM as one
buffer copy per run, word-widened, in the guest's own blit encoder, and a
copy from the guest's RAM as one copy per piece in that encoder. The host
does neither: on the new runtime every staged fill and download is one rt
buffer-to-buffer copy, since rt answers no linear row pitch. In f355 of
the syncview stream the per-run form made 8,029 copies from 28 calls,
with a barrier pair each, which the host never makes.

Now each call is one copy, in a command buffer of the backend's own on
the call's queue, through a Shared scratch of its own (new module
new_runtime/guest_ram.rs):
- copy back: one copy of the whole words the runs span, committed just
  after the call's command buffer; a wait for that command buffer waits
  for the copy too (the guest sees its RAM written when its command
  buffer completes), then the CPU copies each run out of the scratch;
- copy in: the pieces gathered on the CPU into the scratch laid out as
  the bytes they span (gaps and edges from the target's mapping), one
  copy committed just before the call's command buffer; into a buffer
  with no mapping, one copy per run of touching words, so no gap is
  written.
Surface texel copies stay in the guest's blit encoder. The work is
counted apart as the stand-in (guest_ram_* counters, guest_ram_gpu_nanos
for its command buffers' GPU time, outside gpu_busy) and the report's
"guest RAM: copy-back played in the one-copy form" line. The old arm is
unchanged. staged_guest_ram_bytes and copied_back_guest_ram_bytes give
way to guest_ram_fill_bytes and guest_ram_download_bytes.

Tests: the copy-back device test now expects one copy of 100 bytes and
two runs copied out; a new device test plays copies in to a Shared and a
Private buffer and reads both back. docs/REPLAY-STREAM.md section 10
describes the form.
2026-11-19 08:01:21 -08:00
Anees Iqbal 0e9889dfaa replay: the rt backend reads a Private buffer back through a blit into a Shared buffer of the play's own
The new runtime's player backend refused every read of a Private buffer
("a Private buffer": it has no contents). The gate's per-command-buffer
compare (`--dump-command-buffers`, `compare-dumps`) therefore read none of
them on rt: its play pair over glbench-780m-r2's command buffers
58254..58416 on the 3090 (m3-max-52237, development b8ea291aa5) left 41
dumps unread on rt, among them every buffer the probe gate had found
differing, and the compare said DIFFER for that alone. The probe had read
them through a blit of its own that never landed.

NewRuntime::read now copies a Private buffer's bytes with one blit into a
Shared block the play takes for the read and gives back, on a queue of the
play's own made at the first such read, and waits for the copy. The
player reads only after the work that writes the buffer completed. A
length that is not a multiple of 4 stays the copy's own refusal. The
stream's checks never named a Private buffer (a refused read ends a play),
so only the dumps change.

Test: rt_replay::a_private_buffer_reads_back_through_a_copy: a blit fills
a 16-byte Private buffer with 0x5a; the backend's read answers those
bytes. Before this change the read was refused.

Verified by the check named when this lands.
2026-11-19 07:02:13 -08:00
Anees Iqbal 905b16b79a command-replay: --gpu-wait-timeout bounds the play's device waits
The replay command took only the 10 s default for every device wait, so a play on a CPU
device (lavapipe) whose command buffer takes longer than 10 s ends with status 86 though
nothing hangs. It now takes --gpu-wait-timeout SECONDS (1..=600) as the other device-executing
commands do, applied before any device opens; a value outside the range is an error line and
status 2. Needed for the CPU-ICD repro of a GPU hang (docs/VALIDATION.md, the suspected-hang
protocol). Verified: clippy and the player build; the lavapipe play that uses it is the check.
2026-11-19 06:46:48 -08:00
Anees Iqbal ee1a8aee7c REPLAY-STREAM: the new runtime's player binds a range as the single-slot bind of each 2026-11-19 06:17:51 -08:00
Anees Iqbal d75eab9c2b validation: the per-command-buffer compare of two plays applies the cover rule, word by word
The 3090 chain gate compared rt's and the old runtime's plays command buffer by command buffer
through a probe that never lands: whole-object checksums of each buffer a command buffer named,
then a script that asked the probe's dumps of Covers. A whole-object checksum is no compare under
the cover rule: a buffer partly under a texture's write differs under the cover, and a word that
differs outside it shows only as the same mismatch. This lands the compare in the player's own
tooling, on the player's own Covers (94d7c1620c's rule, unchanged).

- Player::dumping(command buffers, dir): once each listed command buffer completed (its wait
  seen, before the next call plays), every buffer its encoders named is written into dir as
  cbC-objO.bin, with cbC-objO.cover holding the ranges of it the cover rule held covered then, or
  cbC-objO.unread where the backend could not read it. A write failure ends the play
  (PlayError::Dump). Off unless asked.
- compare_dumps(a, b) (replay/dumps.rs) compares two plays' dumps word by word, leaves out a word
  wholly inside a range either play held covered (the old runtime answers no slot access, so its
  plays cover less), and reports every other differing word per command buffer and buffer, a dump
  one play lacks, and a dump either could not read.
- command-replay: --dump-command-buffers FIRST..LAST --dump-dir DIR on play; compare-dumps --a DIR
  --b DIR prints a line per buffer that differs outside every cover and a summary ending agree or
  DIFFER, exit 0 / 1 / 2.
- Covers::ranges(object), read-only, for the dump.
- docs/REPLAY-STREAM.md, section 10: the options, the files and the compare's lines.

Tests (no GPU, the player on the test backend, two plays each that differ only in the words at
bytes 0x10 and 0x1800 of a 0x2000-byte heap buffer whose first 0x1000 bytes a texture's write
covers after the command buffer bound it):
- replay::tests::the_dump_compare_reports_a_differing_word_outside_every_cover: the dump's cover
  is 0..4096; the word at 0x10 is covered, the one at 0x1800 (word 1536) is reported; DIFFER.
- replay::tests::the_dump_compare_reports_a_word_whose_cover_the_buffer_s_last_write_voided: the
  encoder binds the buffer again after the dispatch (a binding counts as a write), the dump holds
  no cover, and both words are reported.
- replay::tests::the_dump_compare_agrees_on_alike_plays_and_reports_a_dump_one_play_lacks.
The test backend now keeps a heap buffer's bytes as it keeps a device buffer's, so a write into
one reads back.

Verified: the check job named at hand-over compiles it and runs the replay tests.
2026-11-19 06:06:56 -08:00
Anees Iqbal 0c36de79d9 replay: a surface's pictures fill its shapes at their first use, as the product's lazy fill does
m2v.externalWriteDone (a decoded picture landed in a receiver buffer) no longer refills the
buffer's shapes at once. As the product's per-shape form does after a video command buffer, every
shape of the buffer owes a fill from it, its own write lost; the first command buffer whose
encoders use a texture of the buffer (a binding, a pass's attachment, a blit, a useResource)
fills every owing shape of the buffers it uses before its commit, by blits in a command buffer of
the player's own committed then. A picture another lands over before any use is never copied.
The eager form copied every picture at its landing, so a burst of pictures landing at one present
was copied there whether used or not.

New counters: surface_pictures_filled (pictures a fill took) and surface_pictures_unfilled (those
another landed over before any use, or whose buffer went first); the surfaces line also gives the
pictures not used yet. The copy-from-guest-RAM comment now names the product's fill from the
pages, not a refill. docs/REPLAY-STREAM.md sections 4 and 10 say so.

Verified: the new device test a_surface_picture_fills_its_shapes_at_their_first_use (two pictures
land before a kernel reads the texture: one fill of one shape, the second picture read, the first
never copied) runs in the check that follows this commit; not yet run. The eager form fails it
(two refills).
2026-11-19 05:26:09 -08:00
Anees Iqbal a2576535bd replay: a plain surface shape takes shader read and render-target usage alone
The surface form's usage word, as ruled final. A shape no texture over it declares shader
write, shader atomic or Metal's unknown usage for (a plain shape) is made with shader read
and render-target usage alone: rt gives such a texture its format and that format's sRGB
sibling as views, and no storage view, so a plain shape's attachment reads are not refused
and its image carries the short view list. A shape shaders may write keeps the usage Metal
gives a texture whose use it does not know (shader atomic where declared), with the long
view list, so a storage plane's textures of other formats of the same bytes a texel stay
views of it with no copy.

A texture or view of a format other than a plain shape's own or that format's sRGB sibling
is refused (surface_format_refusals), and textures over a plain shape that declare
pixel-format-view usage are counted (surface_plain_format_views). docs/REPLAY-STREAM.md
section 10 says so.

Verified: the new test a_plain_surface_shape_views_as_its_format_and_its_srgb_sibling_alone
(a sibling view found, another format refused as a texture and as a view, counted) runs in
the device suite of the check that follows this commit; not yet run.
2026-11-19 04:51:43 -08:00
Anees Iqbal 0b8fe27977 replay: the surface form counts order-case shapes
surface_order_shapes counts the shapes shaders may write made over a plane that holds a shape
of their extent shaders may not write: the order case, which the storage bit makes another
shape. The doc's counter list reflows. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal a5f4f03a32 replay: the surface form counts the slot writes a pipeline state's interface declares
surface_declared_writes counts the draws' and dispatches' surface texture slots whose bound
state's interface writes them, beside surface_usage_writes, those taken as writes by usage
with no interface at hand: together they say which binds write a shape. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal 079fe12625 replay: a surface shape takes storage for shader atomic usage too; the shapes' sort and drop count as clippy and the type checker want
The planner's storage test is shader write, shader atomic or unknown usage (an image atomic is
a storage image's operation); a shape made for a texture that declares shader atomic carries it.
The idle shapes sort by recency with sort_unstable_by_key, and the overlap drop's count filters
by reference. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal aa8dd9f131 replay: surface textures play as the product's per-shape form, with the usage word
The rt player's surface form now mirrors the product's per-shape form (reims's
surface cache, shapes.rs): a shape is a plane's (receiver, plane, offset, pitch)
texture of one extent and texel size, and every shape is current over its whole
extent by the product's three rules. A new shape is filled from the buffer once
the dirty shapes are written back; a copy back to the guest's RAM first writes
every dirty shape back; at the end of an encoder that may have written a shape,
the write goes through the buffer into each other shape of its plane that a live
texture views or that is dirty, and the plane's other shapes go. Writes are noted
from pass attachments, blit destinations, the slots the bound pipeline state's
interface writes (texture_accesses), and by usage where no interface is at hand.
The newest-entry rule, its download at a new shape and the older-shape use
counter are gone.

The usage word: a shape is made with shader read, render-target and
pixel-format-view usage, and shader write (a storage view) only for a texture
that declares it or Metal's unknown usage; the shape key carries that bit. A
storage shape serves a later texture of its extent that does not declare it; a
declaring texture over a plane whose shape has no storage is another shape.

The report and counters give overlap copies and bytes, straddled texels,
unordered writes, usage writes and write-backs. The device test now checks a
copy from the guest's RAM reaching both shapes of a plane and a blit through one
shape reaching the other at its encoder's end. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal 9c2288b3ae REPLAY-STREAM: the refills' bytes and GPU time among the surface counters
681a736c40 added surface_refill_bytes and surface_refill_gpu_nanos and the longest refill
command buffer on the surfaces line; the doc's list of the counters now names them and says
which frame a refill's GPU time falls in. Doc only.
2026-11-19 03:18:35 -08:00
Anees Iqbal d95591c966 replay: the rt backend plays textures over a surface as views of one texture per receiver range and shape
The rt backend played newTextureWithDescriptor:iosurface:plane: as a substitute, an ordinary
texture whose texels are undefined, so two textures over one surface shared nothing and the
3090 chain's rt plays varied where the old arm, which plays the texture over its receiver
buffer, repeated.

It now plays it as the product makes it: one Device::new_texture_for_views texture (an entry)
per receiver range (receiver buffer, plane, offset, bytesPerRow) and shape (width, height,
bytes a texel), with shader read and write, render-target and pixel-format-view usage, and
every recorded surface texture a view of it at the texture's own index. The receiver buffer
holds the pages' bytes as the stream writes them:
- a new entry is filled from the buffer by a blit in a command buffer of the backend's own,
  committed at the making: after every earlier commit, with no wait;
- a new shape over a range first downloads the range's newest entry into the buffer at that
  entry's extent, then fills the new entry, so bytes map by byte offset; an older shape's entry
  goes once no texture of it lives and is not kept current, and the calls that name such a
  texture after a newer shape are counted (surface_older_uses), argument buffers unseen;
- a copy from the guest's RAM into a range also copies the range into its newest entry, and a
  copy back first copies the newest entry into the range, both in the copy's own blit encoder:
  replace_region would land ahead of the encoders already in the command buffer, and get_bytes
  would add a wait the old arm does not have;
- a recorded CPU write into a range uploads the texels it covers (replace_region) until the
  buffer's first m2v.externalWriteDone, the new record of another API's write landing (a
  decoded picture), which refills every entry of its buffer by a blit committed then; the old
  backend plays that record as nothing;
- another call naming a receiver buffer as a buffer is refused, and a texture of a format that
  reads across a surface's two planes is skipped (skipped_surfaces_across_planes).

The player leaves a receiver buffer's checks and snapshot ranges uncompared on every runtime
(verdict receiver, a receivers line), as the texels live apart from it; the rt backend reads a
texture back for a check, laid out as the old backend lays it out. The surface substitute key
goes; substitutes_read counts the tiled and gap substitutes (and their views) a call named, the
substitutes line naming the first, and the doc's claim that a substitute makes a play no gate
result, which no code made true, now says what holds. The surface record's keys move to args.rs,
shared by both backends.

Census before building (job 51225, gb-3090-r3): 653 entries made, none after an uncommitted
guest-RAM copy into their buffer, so a fill committed at the making misses no copy there.

Tests: the surfaces unit test (the texels a write reaches); the player's receiver test; the
device test of two formats over one surface, a new extent, a copy from the guest's RAM and an
older-extent use. To be run by the check job.
2026-11-19 03:18:35 -08:00
Anees Iqbal a615269526 replay: the covered line counts the covers a binding took off, as a binding may be a read
The stream carries no buffer access, so a buffer binding (set...Buffer...) or a useHeap: of the
object's heap counts as a write and takes a cover off. That errs toward comparing; a residual
difference in such an object's later compares may be the covering texture's bytes, not the
play's. The report's covered line now says how many covers a binding took off.

Verified: the covers unit test gains a fourth round (covered again, then bound) asserting
binding_uncovers 1 and the new line; to be run by its check job.
2026-11-19 03:17:36 -08:00
Anees Iqbal 0c00926c84 replay: the rt backend tallies the textures over buffers held in an image of their own by pixel format and usage
The known-gap line for the pool side's copy at commit wants the classes of the textures the
device's linear image does not take, per card; the report gave only their count. The backend now
keeps, for each texture over a buffer the runtime held in an image of its own (the gauge rose
across the making), its descriptor's pixel format and usage, and prints them, most first, on a
'textures over buffers in an image of their own, by pixel format and usage' line.
REPLAY-STREAM.md lists it.
2026-11-19 03:17:36 -08:00
Anees Iqbal 2385a0a489 replay: the rt backend counts the render encoders it skips by kind
The tessellation plays reported skipped_encoders=214 (and 205) with no kind, so whether a pass
met NoAttachment, a storage gap or a property the runtime's descriptor does not hold could not
be told from the report. The backend now keeps each skipped render encoder's kind with its count
and first frame and call, and prints `skipped render encoders KIND N, the first at frame F,
call C`: `ParallelRenderCommandEncoder`, `Unheld(KEYS)` for a pass whose descriptor sets
properties the runtime's does not hold, or the runtime's gap for the pass (Debug). The
skipped_encoders count is unchanged. REPLAY-STREAM.md lists the line.
2026-11-19 03:17:36 -08:00
Anees Iqbal 94d7c1620c replay: a heap texture write covers what it meets; the compares leave it out until written again
Metal leaves an aliased resource's contents undefined once another resource is written over
its memory. In a placement heap, a texture write over a buffer's (or another texture's)
recorded range leaves the recording holding its runtime's layout of the texels there, and the
play its own (rt shares the memory as a placement heap does; the old arm makes the heap's
buffers and textures apart and keeps the bytes from before). identity's liveness pass over u4
(to frame 315) found 16,942 covers of a heap buffer's range by a heap texture write and no
read through a covered buffer before its next write or release: the bytes are dead, and a
compare of them is no verdict.

The player now tracks, by structure alone (covers.rs), each object the stream places in a
placement heap (its heap, recorded offset, and length: a buffer's own, a texture's as the
runtime answers its size, read ahead) and the texture writes: a draw's or dispatch's to the
texture slots its pipeline state's interface marks written (Backend::texture_writes; the new
runtime answers from ComputePipelineState / RenderPipelineState::texture_accesses, the old
runtime answers no slot access, so on it only the following count), a render pass's to every
texture its descriptor names, a blit's to its destination, generateMipmapsForTexture:, a
useResource:usage: with write usage and replaceRegion:. A write of a texture over a buffer is
the buffer's. A texture write covers the bytes of every other object placed in its heap that
its range meets; the object is written again by the player's writes into it (m2v.write,
contents at creation, copies from the guest's RAM, a snapshot's bytes before), a blit into it,
and, as the stream carries no buffer access, any binding of it to an encoder, a write-usage
useResource:usage: or a useHeap: of its heap. A check of a covered object reports `covered`
and a snapshot range meeting covered bytes `covered`, neither compared; a `covered N: ...`
line counts the covers and what they left out. REPLAY-STREAM.md says so, and says
gap_pipeline_ids is bookkeeping: nothing is skipped for it.

Test (replay::tests): a placement heap with a buffer and two textures at offset 0; a dispatch
whose state writes slot 0, which holds the first texture, covers the buffer and the second
texture; their checks are `covered`; the buffer written whole is compared again, the second
texture stays covered; a dispatch of a state that only reads the slot covers nothing.
2026-11-19 03:17:36 -08:00
Anees Iqbal c9637b0d08 replay: a descriptor-form no-copy buffer is a pool buffer; only the bytes form imports
The planner ruled the mapping: the player plays every descriptor-form no-copy buffer
(newBufferWithDescriptor: with noCopy) as a pool buffer, a buffer of a recorded block where
its recorded range lies in one and a place of its own elsewhere, and imports only the bytes
form (newBufferWithBytesNoCopy:length:options:deallocator:, the host's own in the recordings).

The recordings do not tell the program's own no-copy memory (an import in the product) from
the host's pool buffers, so that memory plays as a pool buffer too: a known gap. The host's
recorder makes a buffer over the program's memory only with a pinnedGpuAddress and no
zeroFrom (zeroFrom and unpinned buffers are always the host's own), so the report's gap line
bounds the gap by those outside every block, with their bytes. REPLAY-STREAM.md states the
mapping and the gap.

The test plays three descriptor-form buffers outside every block (one pinned with no
zeroFrom, one unpinned, one pinned with zeroFrom), a texture over the first read through a
blit, and checks the counts line, the gap line's bound of 1, and that the imported side
counts only the bytes-form buffer's texture copy.
2026-11-19 01:07:23 -08:00
Anees Iqbal c8e65bd9cb REPLAY-STREAM.md: the report's textures over buffers line 2026-11-19 00:49:43 -08:00
Anees Iqbal 01d40ad5fc replay: a descriptor-form no-copy buffer inside a recorded block is a buffer of it; others import
The product's no-copy buffers are not all imports. A newBufferWithDescriptor: with noCopy whose
recorded address and length lie inside a live block's recorded range (m2v.newBlockWithLength:
storageMode:) is the program's buffer in that block's storage, a pool buffer on rt; it now plays
as a buffer of that block at that offset, as m2v.newBufferInBlock:offset:length:options: does
(the in-block buffer path is one method both use), its bytes at its making put there first. Only
a descriptor-form one outside every block (the program's own no-copy memory) and the bytes form
(the host's own buffers in the recordings, never the program's) go through the import.

The backend keeps each live block's recorded range (imports::NoCopies) and counts the three
kinds; the report's no-copy buffers line replaces the no-copy imports line. REPLAY-STREAM.md says
which plays how. The no-copy device test adds a block recorded at an address and a
descriptor-form buffer recorded inside it: it reads the bytes written into the block there, and
the line counts it in the block, beside one descriptor-form and one bytes-form import. Verified
so far: nothing; the build and tests run in the check job.
2026-11-19 00:49:42 -08:00
Anees Iqbal 5250b8dd7b rt: the over-copies over imported blocks are counted on their own side
Metrics::over_copies_imported and Metrics::over_copy_bytes_imported count the copies between a
texture over a buffer and its image of its own where the bytes shaders reach are in an imported
block (host memory or a dma-buf), beside over_copies and over_copy_bytes, which still count every
such copy; the rest are over the runtime's own blocks, where the device's linear image does not
take the texture. One mechanism: OverCopy carries whether its buffer's bytes are imported, and
Counters::over_copied adds the imported side where it is. A first-boot report can then read the
imports' copies alone, and a play the pool buffers' copies (total less imported).

The api_signatures rows, the doc lines (Metrics, over.rs, the README) and the player's per-frame
counters carry the two. Tests: copy_over's device test asserts its texture over a buffer in a
taken block moves neither imported counter; the import test asserts every copy of its texture
over an imported block counts on the imported side, its texels' bytes each; the player's no-copy
device test asserts its one copy is imported. Verified so far: signatures.py --check; the build
and tests run in the check job.
2026-11-19 00:45:36 -08:00
Anees Iqbal 324cfb72cf replay: the new runtime's player imports no-copy buffers' memory; rt counts over-copy bytes
Both no-copy creators (newBufferWithBytesNoCopy:length:options:deallocator:, and
newBufferWithDescriptor: with noCopy) now make their buffers over zeroed host pages of the
player's own, each imported as a block of its own through rt's import_host_memory, as the
product imports the program's pages; the import's release frees the pages once the runtime has
freed the import. A texture over such a buffer is then the runtime's counted copy, so a play's
frames count those copies. A device without host-memory import refuses a no-copy buffer by name.
Two-copy forms keep their second copy: the import holds the CPU's copy where the runtime keeps a
GPU copy, and the copy shaders reach where the player keeps the second copy itself. Release and
command-buffer use tracking now cover a buffer with no place of its own but a device copy or an
aside.

rt gains one deterministic metric, Metrics::over_copy_bytes: the bytes of the copies between a
texture over a buffer and its image of its own, still counted in bytes_copied
(Counters::over_copied adds all three; the now unused Metric::OverCopies is gone). The player's
per-frame counters carry it, its drop gauges and live gauges carry rt's imports gauge, and its
report gains a no-copy imports line.

Tests: rt's copy_over device test checks each copy adds the texture's bytes to both byte
metrics; a new rt_replay device test plays both creators, a texture over the first, a blit of
the texture checked against the stream's bytes, one over-copy of 64 bytes, the imports line and
the imports gauge at zero at device drop. Verified so far: signatures.py --check passes; the
build and tests run in the check job.
2026-11-19 00:14:01 -08:00
Anees Iqbal 2db8331d56 command-replay: the new runtime's gauges at device drop go out as the matrix's lines
After the play, the new runtime's backend ends its device (NewRuntime::end) and now hands back
what it read once the device dropped (Ended: every rt::Gauges field by name, threads as the
slots still held, whether all read zero, whether it quiesced). command-replay writes one line per
gauge into the report, "M2V-MATRIX gauge replay-rt/device/GAUGE@drop N", the matrix's own record
form (scripts/matrix/results.py's RECORD pattern; its rule fails a gauge not 0 at @drop), so any
play job's output can be checked by that rule. The teardown error now names only the gauges not
at zero. The old runtime's counts end with its device, so its plays print none.

Tests: a unit test of the lines' form and the error's naming; the rt device test of a play that
ends with a command buffer held asserts every line is "M2V-MATRIX gauge KEY@drop 0". The stream
guide's report section says so. Checked by the lane's check job (named in the report to main).
2026-11-18 23:41:05 -08:00
Anees Iqbal bc6dc40a14 player: the old runtime plays a recorded heap as its buffers and its textures apart
On the old runtime's player, a heap with a recorded range is now made by what the stream places
in it (read ahead), whatever its type:
- its buffers go in a heap at the recorded address and of the recorded size, each at its
  recorded offset, never laid out again (a pinned span never grows);
- its textures go in a heap outside the pinned space, laid out for the runtime's sizes as the
  texture-only rule did. It is one heap, so textures placed at one offset still share.
Buffer-only = the pinned heap alone, texture-only (or nothing placed) = the outside heap alone,
mixed = both. Backend::holds_no_buffer becomes Backend::split_heap(heap, HeapSplit); the old
backend holds a split heap as Object::Heap(buffers' heap, textures' heap), and useHeap: uses
both. A buffer the runtime refuses at its recorded offset in its heap now stops the play typed
(PlayError::Unpinned with the runtime's reason) instead of as a Runtime error.

Why: u4's old arm stopped at f1033 on mixed heap #188906 (4 MiB placement, 2600 buffers and 1000
textures over its life): the relayout grew it for the runtime's texture sizes, and the pinned
heap's grown span met #188909, recorded 0x8968 bytes past the heap's Metal span. u2 and u3 carry
the same heap twice each, u4 again at f1059.

The report line becomes "pinned N of N; K heaps' textures outside; S textures whose recorded
range (by the runtime's texture sizes) met a live buffer's". S comes from the read-ahead: a
texture's range is the heap's recorded address plus its offset for the runtime's size answer
(the stream holds no texture size), a buffer's its recorded range; reported, not a stop. The
heap code moves to replay/heaps.rs (relay, placement helpers, HeapSplit, Overlaps).

Safe by census (jobs 50282-50286, every stream on five nodes, 29 names): every heap is a
placement heap; no call takes a heap as receiver except the placements, none names a heap as an
argument, and no heap or size getter is recorded; the only calls on heap resources are
m2v.privateBytes on heap buffers and texture views of heap textures, neither compared. The
automatic-heap half rests on its unit test, as REPLAY-STREAM.md now says.

Tests: unit tests for the three shapes (textures alone, buffers alone with an alignment that
would move them, mixed with a larger texture and a met buffer) and for automatic heaps; a
lavapipe device test of a mixed heap whose texture the runtime makes larger, with a buffer
pinned right past the heap's recorded span that keeps its address. The negative control (no
split told, the whole heap relaid) must fail them; the check job and its inner codes are named
in the report to main.
2026-11-18 23:34:38 -08:00
Anees Iqbal 1ee16e6a0f command-replay: every report line, the frame lines among them, goes to the standard error too
identity's scripts lost 50152's record when they deleted the job's temporary directory, where
report.txt lay. The planner ruled that the player prints each report line and each frame-end line
to stderr as well as to report.txt, so no script can lose them.

ReportFile, the one writer of report.txt, now implements Write. Each write goes to the file and
then to stderr, and the player's frame lines go through it (with_frame_lines takes the report
rather than its file). A failed stderr write never fails the file's. REPLAY-STREAM.md section 10
and the binary's docs say where the lines go.

Test: the range test's helper runs command-replay and asserts that its stderr carries every
report.txt line, in order. All its plays stop before a device opens, so no device is needed.
2026-11-18 22:53:43 -08:00
Anees Iqbal 331ff7bcba player: the old runtime makes a heap the stream places no buffer in outside the pinned space
glbench-3090-r4's old arm stopped at f198: buffer #22759, pinned at 0x4020086d8000 (32 KiB past
heap #22754's recorded end), met the span the old runtime held for #22754. #22754 is a placement
heap that holds six RGBA16Float textures and no buffer. The player lays placement heaps out again
for the runtime's texture sizes, and grew it from 2 MiB to about 2.5 MiB; pinned at its recorded
address, the grown heap held #22759's pages. In Metal the two never meet.

The rule (the planner's): on the old arm a heap is pinned only where the stream places a buffer
in it. A texture has no address and a heap answers none, so no address the program holds lies in
a heap without buffers, and pinning it buys nothing. The read-ahead finds those heaps from the
stream alone, never from the runtime's size answers or what the space holds, so the old arm's
address layout is the same on every card. The player tells the backend before the making
(Backend::holds_no_buffer). The old backend makes the heap outside the space, and the address map
keeps its recorded range at its recorded address, so the address census is unchanged. A heap that
holds a buffer keeps its recorded address and the typed stop where its grown span meets another
pin.

The report's pinned line now says "pinned N of N; K heaps without buffers outside: ...".
REPLAY-STREAM.md sections 5, 9 and 10 say so.

Tests:
- a_heap_without_buffers_is_made_outside_the_recorded_addresses (player, no device). The test
  backend pins. A texture-only heap is told and made outside; a heap with a buffer, and its
  buffer, are made at their recorded addresses. A word into the outside heap's range is still
  counted, and no word moves.
- a_heap_without_buffers_leaves_the_next_pin_its_address (old runtime, device). A 64-KiB pinned
  heap holds only a 256-KiB texture, and a buffer is pinned at the first granule past the heap's
  recorded span. Without the fix the grown heap's span holds the buffer's and the play stops.
2026-11-18 22:52:47 -08:00
Anees Iqbal a3ff94f510 replay: the escape note (m2v.bufferEscaped) and a stop on a written word into a noted buffer
The recorder will note a buffer whose address may escape into the program's memory: once in the
buffer's life, at the first gpuAddress read (kind 0), argument-encoder write (1), gpuResourceID
read of a texture over it (2) or residency-set add (3); the whole buffer escapes. No stream
carries the note yet.

The player now reads m2v.bufferEscaped: the receiver must be a made object and the one argument
a kind from 0 to 3, else the stream is invalid. Once a buffer's note is read, a written word that
looks like an address (the census's aligned words) whose value lies in that buffer's recorded
range stops the play with PlayError::NotedWord {target, offset, value, buffer, kind}. Moving such
a word is not built: no stream exercises it, and the move gets built with the first stream that
does. AddressMap::noted_word finds the word at any nesting level. The lookup runs only once a
note was read, so a stream without notes pays nothing for it.

The report counts the notes (Report::escape_notes); the addresses line ends "the stream predates
the escape note" where there are none, "escape notes N" otherwise.

Test (unit, a synthetic stream): a note, then a write of a word into the noted buffer stops,
naming the word; the same kind of word into a buffer with no note played as written before it;
a kind past 3 and a note of an unmade object are invalid streams. docs/REPLAY-STREAM.md section 5
holds the record and the stop, section 10 the line.

Verification: the replay checks run as a potluck job on this commit.
2026-11-18 22:02:15 -08:00
Anees Iqbal d2834389c7 replay: written words play as recorded on both runtimes; a census counts the address-looking ones
The player rewrote every 8-byte word of written bytes whose value lay in a live recorded range.
On a stream recorded before the escape note a word's value cannot tell an address from data,
and on u4 that rewrote two 32-bit indices of an index array into an address of the play, which a
kernel later read through out of bounds (the rewrite-off control played u4 whole with no fault).

Now no written word moves on its value, on either runtime:
- The address map's word pass is a census that writes nothing (AddressMap::census). It counts
  address_looking_words (aligned 8-byte words in a live range) and misaligned_address_words in
  the same bytes as before: writes, copied contents, guest-RAM copies and Private bytes before a
  dispatch into objects that answered a gpuAddress, and set*Bytes data. Both are stream-fixed,
  equal on both runtimes.
- What moves are typed address arguments (tag 8), through the map: relocated_words now counts
  only those that moved, so it is zero on the old runtime, whose ranges are at their recorded
  addresses.
- unrelocated_writes is deleted: no written word is relocated anywhere, so it meant nothing.
- A Private range's bytes after a dispatch are compared as recorded.
- The report's relocation line becomes "addresses address_looking_words=N
  misaligned_address_words=N address_arguments=N relocated_words=N differing_ids=N: written
  words play as recorded; the stream predates the escape note".

Tests:
- unit: written words play as recorded and are counted; a typed address argument moves with its
  object (and one in no range stays); guest-RAM copies and copied contents play as recorded;
  the census counts by alignment.
- device, rt: a data word in a live range plays as written (sha check); the census is the same
  on the old and new runtimes (and the old pinned both objects).
- The rt granule test read the runtime's addresses through relocated words; it now checks the
  places line's slack (each place spans its length rounded up to its recorded granule).
docs/REPLAY-STREAM.md sections 5 and 10 and docs/VALIDATION.md say the new form.

The escape note (m2v.bufferEscaped) and the stop on a word into a noted buffer follow in their
own commit.

Verification: the replay checks (clippy in three configurations, replay unit tests, the replay
device tests on lavapipe, rustdoc) run as a potluck job on this commit.
2026-11-18 22:02:15 -08:00
Anees Iqbal 16f750a424 replay: the old runtime's player makes every recorded range at its recorded address
The player's old backend made each object where the runtime had room and relocated every
8-byte word that lay in a live recorded range. A data word whose value happened to lie in one
(two 32-bit indices in a pixel-sized index array) was rewritten into an address of the play,
and a later kernel read through it out of bounds.

Now the old backend makes every object that answered a gpuAddress at that address
(AddressPlacement::At): device buffers of every making form, blocks and heaps, the
descriptor's pinnedGpuAddress aside, so heaps take their answer too. Every other object, and
the player's own staging, readback and host buffers, go Outside ([2^47, 2^48), past every span
a pin can take). A refused pin, or an object made at another address than it recorded, stops
the play with PlayError::Unpinned naming the object; no other placement is tried. The address
map still runs, with each range's base its recorded address, so it moves no word, every
address argument plays as recorded, and relocated_words and the other stream-fixed counts stay
equal across runtimes. The report adds "pinned N of N".

The new runtime's backend is unchanged (Backend::places_at_recorded defaults to false).

Tests (device, old runtime): the pointer-chain test now also asserts its four objects pinned;
a data word in a live range plays as written; a pin inside another's span stops typed.
docs/REPLAY-STREAM.md sections 5 and 10 describe the form and the report line.

Verification: the replay checks (clippy in both cfgs, the replay unit tests, the replay
device tests on lavapipe, rustdoc) run as a potluck job on this commit.
2026-11-18 21:52:44 -08:00
Anees Iqbal 2e1b543f1b rt: patch draw device tests; the address form reads no word past the factors; the player gives the recorded tessellation state (work in progress)
The address form read one word past a patch's factors where they start at a
multiple of 4; it now reads the first word again there, so every word it
reads holds a factor's byte (the interpreter test trapped on the over-read).

The players gave the recorded tessellation state only where the vertex
function's patchType was not None. The glbench streams' patch functions
answer None (their container has no TESS tag) while their AIR is
post-tessellation, so the state was dropped and the translator drew their
patches under Metal's defaults. The state now goes to every pipeline where it
differs from the defaults; the translator decides from the AIR and ignores it
for a plain vertex function, as Metal does.
2026-11-18 21:04:27 -08:00
Anees Iqbal 4df69ca062 rt: generateMipmapsForTexture:, the device's linear blit of each level, under a static note
web3d calls generateMipmapsForTexture: once in each stream, which the player skipped and counted
(mipmaps 1). It is built as Apple defines the call: each level below the texture's first made
from the level above it, over each slice, a view's levels and slices its own.

- BlitCommandEncoder::generate_mipmaps: one vkCmdBlitImage a level with VK_FILTER_LINEAR, the
  first level read and the rest written whole (their old contents discarded) behind the copy's
  first barrier, one barrier between each level and the next, and the last bringing every level
  home, the last level's writes visible to every later command. A texture of one level records
  nothing.
- Refusal::MipmapFormat for a format Apple defines no mipmaps of (a depth or stencil, compressed,
  YCbCr or integer one: not colour-renderable and filterable); Gap::MipmapFilter where the
  device's format query lacks blits from and to the image's format or its linear filtering,
  where the image holds the pixel format through a conversion, and for a view in another format
  than its image's, whose blit would filter the image's.
- PrecisionNote::DeviceFilteredMipmaps, the static note BlitCommandEncoder::GENERATE_MIPMAPS_NOTE
  carries: the filter is the device's, where Apple states none. The old runtime announces it as
  its existing device-filtered-mipmaps kind; validation allows it unbounded; codec and
  ARTIFACT_FORMAT_VERSION 541, fast_paths' list, API.md's catalogue entry.
- The conformance rt side plays Step::GenerateMipmaps and announces the note; the replay player
  plays the call and its skipped_mipmaps counter is gone (REPLAY-STREAM.md).
- Test: an 8x8 RGBA8Unorm texture of four levels, each level below the first within one code of
  the box of the four texels it halves in the level above as the device left them, its first
  level kept, one submission and the chain's four barriers besides the segment's end; one level
  records nothing; RGBA8Uint is Refusal::MipmapFormat. REFUSALS and api_signatures regenerated.
2026-11-18 19:10:22 -08:00
Anees Iqbal 8f720744ce replay: render encoders' sampler binds with LOD clamps play through the runtime
The runtime binds a sampler state with LOD clamps whose samples read as its own (b7ef04ae97:
each clamp held to [0, 15] equals the state's own held the same way) and answers any other with
Gap::LodClamps, binding nothing. The player now plays the four render clamp selectors (vertex
and fragment, one sampler or a range) through set_vertex_sampler_state_with_lod_clamps and
set_fragment_sampler_state_with_lod_clamps. A bind the runtime answers with the gap is skipped
and counted (skipped_clamped_samplers), and draws are skipped while the slot holds it.

Every clamp bind the census found (both web3d streams: the sampler's own (0, FLT_MAX) and
(0, 1000) over (0, FLT_MAX)) reads as its own, so they all bind. Before this, the player refused
setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange: (web3d-780m-r1 stopped at frame
391, web3d-3090-r2 at frame 0); the probe players carried a stopgap that skipped any clamp other
than the sampler's own, which this replaces. The compute encoder's clamp selectors stay refused:
no stream calls them.

Test a_sampler_bound_with_lod_clamps_plays_where_the_runtime_takes_them: (0, FLT_MAX) and
(0, 1000) bind and the draw is checked green; (0, 2) is the gap, counted, its draw skipped.
2026-11-18 18:52:40 -08:00
Anees Iqbal 8cb034077c replay: a compute encoder's setStageInRegion: plays on the new runtime
The runtime's compute encoder takes setStageInRegion: (59bb3634d1): it changes nothing a dispatch
of a kernel without a stage-in argument does, the only kernel it builds. glbench-780m-r1's all8
play (m3-max-49209) stopped at frame 438, call 593644, on the player's refusal of the selector;
the census found 158,349 such calls there and 300,832 in glbench-3090-r2, every one on a kernel
with no stage-in argument. The new runtime's backend now plays it through
ComputeCommandEncoder::set_stage_in_region; the old runtime still refuses it.

Test a_stage_in_region_plays_on_a_compute_encoder: an encoder's region plays, nothing skipped.
2026-11-18 18:52:40 -08:00
Anees Iqbal 39e9e52726 replay: an index is owed only to command buffers that named its object while it held the index
Reims's read of glbench-780m-r1 (frame 381): the guest gives index 1459 to one swizzled view
after another, and the host releases each about 700 records after the next took the index, so
two views are live at 1459 for that span. The player took an object's index from the placement
alone and kept it until the object's release, so a command buffer that named a displaced view
owed 1459, and the placement of view #71001 waited for (then counted) command buffer #70944,
which names no object holding 1459.

Indices now records, per command buffer not yet committed, the index each named object holds at
the naming (it is the object placed there last), and owes those indices at the commit; a command
buffer released uncommitted owes nothing. The released-object bookkeeping (pending users) goes:
a naming already holds its index. The backend's users map keeps buffers only, the one thing
still read from it (Places).

Tests: the Indices unit test gains two live objects at one index (a naming of the earlier one
owes nothing, of the later one owes); device test
a_command_buffer_naming_an_object_after_a_later_one_took_its_index_owes_it_nothing plays the
shape (two live holders, release after reassignment) and expects no wait and no count.
2026-11-18 18:52:40 -08:00
Anees Iqbal 1fe1d69fc0 replay: an ID's low word is compared with the recording's, its high word with the documented word
The planner's ruling on resource IDs: the new runtime's layout stands (index | word << 32,
docs/RESOURCE-ID.md). A recording made on the old runtime holds that runtime's high word, so a
whole-ID comparison reported every texture whose word is not 0 as differing.

Backend::resource_word gives the high word RESOURCE-ID.md's own functions give the descriptor the
backend made the object of: TextureWord::of(pixel format, swizzle) for a texture, SamplerWord::of
for a sampler state. Where a backend gives one (the new runtime's), the player compares the ID's
low word with the recording's and its high word with that word, never with the recording's high
word. Where it gives none (the old runtime's), the whole ID is compared as before. A differing
ID's line carries the word: 'id #N RECORDED PLAYED word WORD'.

Test a_resource_id_s_high_word_is_checked_against_the_documented_word: an ID with the recorded
index and the word passes over a recorded high word of 0 or 1; another index or another high
word is reported with the word.
2026-11-18 18:52:39 -08:00
Anees Iqbal 37fffd39fc replay: the display library line names the sidecar by SHA-256 and git blob id
The planner's condition on the display sidecar: every play states which
display library it ran. The report's display library line now gives the
sidecar's length, its SHA-256, and its git blob id (the SHA-1 of
"blob LENGTH\0" and the bytes). The blob id names the file in the host's tree:
every stream so far holds blob b1aea1f0, 47,426 bytes. The doc also says the
sidecar holds the host's display shaders alone, and that a player makes only
the device's library from source of no arguments from it.

The validation crate takes sha1 0.11 (RustCrypto, MIT OR Apache-2.0; the same
digest family as sha2 0.11) for the blob id.

Test: the integration test expects the 5-byte sidecar's SHA-256 and the blob
id `git hash-object` gives for the same bytes (8d7ffd7e). Verified by the lane
check named in the hand-over.
2026-11-18 18:07:35 -08:00
Anees Iqbal 0ee01c4eda replay: the host's library from source is made of the stream's display library sidecar
webdiv-780m-3's record 11498, newLibraryWithSource:options:error: on the
device with no arguments, is reims's host loading its own display shaders.
The players skipped every library from source, and with it the host's 773
present draws, so both plays of webdiv-780m-3 ended as no verdict. A
program's own libraries reach the stream as data, never as source.

The decided form is a sidecar beside the stream, NAME.display.metallib, like
NAME.range:
- command-replay reads the sidecar (replay::display_library) and gives it to
  either backend (with_display_library).
- The report says so in the line after `range`: `display library the
  stream's sidecar, N bytes`, or `display library none: the host's library
  from source is skipped`.
- Both players make a library from source of no arguments from the sidecar,
  as from data. Any other library from source, or one without a sidecar,
  stays skipped and counted.
docs/REPLAY-STREAM.md sections 1 and 10 state the sidecar and the line.

Tests:
- An integration test reads the line without the sidecar and with a 5-byte
  one; the range test's line positions follow the new line.
- A device test makes a function of the host's library with the display
  library and skips both without it.
Verified by the lane check named in the hand-over.
2026-11-18 18:07:35 -08:00
Anees Iqbal d7156b3ca7 replay: a placement owed to a held commit takes the index without waiting, counted
A placement whose index is owed to a command buffer that no record played so far lets
complete (its event wait is signalled only by a later record) stopped the play with
PlayError::Held. In the recording that order proves the recording device gave the index to the
new object before that command buffer completed: that is its index policy. The player now plays
what the device did: it takes the index without waiting and counts the placement on its own
report line ('indices given while a commit they owe is held N: ...'). The index stays owed to
the held commit. Where the owed commit is not held, the player still waits for it.

PlayError::Held, held_error and HeldBuffer's queue and unmet waits are deleted: nothing reads
them now. Backend::held takes the held command buffers' stream ids.

The rt_replay test that pinned the stop now expects the index taken (16) and the count of 1.
Verified by the check job named in the hand-over.
2026-11-18 18:07:35 -08:00
Anees Iqbal 1ba761329c replay: a render pipeline record's tessellation state and call-stack depths are read
reims's recorder (descwire) now writes three keys at the end of each
newRenderPipelineStateWithDescriptor:error: map, always:
- `tessellation`, a map of the seven tessellation properties as Metal's raw
  values;
- `maxVertexCallStackDepth`;
- `maxFragmentCallStackDepth`.
The players refused any key they did not know, so every pipeline of such a
stream would have been refused. A stream without the keys means Metal's
defaults (0, 16, false, 0, 0, 0, 0; depths 1 and 1): the device built those
before the recorder carried them. There is no header bit, and the host's
short display map is unchanged.

Both players (translator::render_pipeline) now accept the keys:
- The depths always go to the descriptor.
- The tessellation state goes to it only where it differs from Metal's
  defaults and the vertex function is a post-tessellation one (patchType not
  None). Any other vertex function ignores the state, as Metal does, so a
  plain pipeline is never handed tessellation state the new runtime would
  refuse.
docs/REPLAY-STREAM.md section 9 states the keys, their defaults and the
names that differ from Metal's.

Test: a unit test parses the recorder's pinned record (partition 3, factor
32, scale on, half, uint32 indices, per-patch, counter-clockwise; depths 2 and
3) to those values, a record without the keys to the defaults, and refuses an
unknown key at the top and inside the tessellation map. Verified by the lane
check named in the hand-over.
2026-11-18 17:40:11 -08:00
Anees Iqbal 57272b7db9 replay: a compute pipeline state the runtime does not build is skipped and counted
A per-gap play counts the gaps, but a compute pipeline state that the runtime
answered with a typed gap, or that the translator refused, stopped the new
runtime's play at once. glbench-3090-r2 stopped at frame 0 on an
IdentityDomains refusal, and nothing after it was counted.

Compute pipeline states are now skipped and counted the way render pipeline
states are (c027cc2cfa): by the runtime's gap, or `Translation` for the
translator's refusal, together with the first state's object and the runtime's
answer. They appear as `skipped_compute_states` and the report line
`skipped compute states GAP N, the first #ID: WHY`. A dispatch of a skipped
state is skipped and counted (`skipped_dispatches`), and the play goes on. Any
other error still stops it. Render and compute share the counting
(Skips::skipped_state). docs/REPLAY-STREAM.md section 10 says so.

Test: a device test plays a state made for indirect command buffers. The
runtime refuses it as IndirectCommandBuffers; the test expects it counted,
its dispatch skipped and the play ended normally. The rt_replay library
helper takes any of the runtime examples' functions, a kernel among them.
Verified by the lane check named in the hand-over.
2026-11-18 17:39:03 -08:00
Anees Iqbal 96ef4a692e replay: a buffer's linear texture plays as the texture over it where 2D
The SPI newLinearTextureWithDescriptor:offset:bytesPerRow:bytesPerImage:
stopped the new runtime's play of webdiv-780m-2 at frame 0 ("not played on a
buffer"): the stream makes one such texture, a 2D one over a no-copy buffer.
Neither player knew the selector.

The old runtime measured the SPI as newTextureWithDescriptor:offset:bytesPerRow:
for a 2D descriptor, plus 2D arrays whose slices Metal lays out itself
(bytesPerImage ignored; Buffer::new_linear_texture). The old player now calls
that. The new runtime has no form of the array layout, so its player plays a
2D descriptor as the public texture over the buffer (its resource index
included) and refuses any other type, "a linear texture of a type other than
2D". docs/REPLAY-STREAM.md section 5 names the selector.

Test: a device test plays a 2D linear texture with nothing skipped and gets
the refusal for a 2D array. Verified by the lane check named in the hand-over.
2026-11-18 17:29:04 -08:00
Anees Iqbal c027cc2cfa replay: skipped render pipeline states are counted by the runtime's gap
The report gave one line for every skipped render pipeline state, its
total and the first one's answer, so a stream's states refused for a
depth attachment, for framebuffer fetch or by the translator read as one
number. The planner's census of what the new runtime refuses needs the
count of each kind per stream.

The backend now keeps the skipped states by the gap as Rust prints it
for debugging (Translation where the translator refused), with the
first one's object and answer, and the report gives a
"skipped render states GAP N, the first #ID: WHY" line for each, as it
does for render commands; skipped_render_states is their sum.
docs/REPLAY-STREAM.md describes the line.

Verified: see the check job (a new rt_replay device test: a state with
a Depth32Float depth attachment is counted under
RenderPipeline { kind: DepthAttachment }).
2026-11-18 16:57:09 -08:00
Anees Iqbal a314b75ee6 replay: a play ends at the stream's recording range unless --past-range yes takes it past
A known-bad tail cost a ring timeout on a shared card and a wrongly
bounded play. The player now ends every play at the recording range by
default:
- the stream's sidecar, NAME.range beside NAME.0000.m2vr, one line:
  "last-frame F" or "whole";
- else the player's table RECORDED_RANGES for the streams recorded
  before sidecars, found by the first segment's file name and byte
  length: u2 1128, u3 1178, r3 1137, r4 1099, b3 whole;
- else the whole stream (the 3D streams until their ranges are stated).

--past-range yes plays past it; without it --until-frame F stops at the
earlier of F and the range. Every report says which range the play
used, where it came from and whether the play ends there, on a range
line after the completion mark; a sidecar of neither form is a harness
error (exit 2). docs/REPLAY-STREAM.md: section 1 names the sidecar,
section 10 the default, the flag and the report line.

Tests: replay::tests a_recording_range_comes_from_the_sidecar_then_the_table
(sidecar over table, table row by name and length, no row, bad sidecar);
integration replay_range runs the binary over a synthetic stream with no
sidecar, a last-frame sidecar, the flag and a bad sidecar (no device
opens); replay_completion_mark now expects the range line second.
2026-11-18 16:47:13 -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 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 40e135c308 replay: the new runtime's backend rounds each buffer's place to its recorded granule
The backend packed buffers first fit at Metal's 256-byte alignment, so a program's write past
a buffer's end landed in the next buffer. A recorded stream's program did that: an append
list of 4000 records took about 870 more on one play, and the overrun went 17340 bytes into
twelve 4-byte counters and the start of a 48000-byte buffer that the player had packed behind
it. The recording had given each of those buffers its own 32 KiB-granular range, so the same
overrun landed in the list's own slack there. The clobbered counters then feed the next
rounds; a 780M page fault past a 64 MB buffer and a hang on a 3090 follow them (expected, the proof plays pending).

Each buffer's place now spans its length rounded up to its recorded granule: the largest
power of two that divides its recorded gpuAddress, from 256 bytes to 64 KiB, and 256 bytes
where the stream records no address (the player's own staging included). Both copies of a
two-copy Managed buffer take it. A buffer past the class's block length takes a block of its
own of the rounded span. The backend's new "places by recorded granule" line counts the
places by granule and gives the most bytes of slack held at once.

Test: rt_replay's buffers_keep_the_slack_of_their_recorded_granule plays two 4-byte buffers
recorded at addresses of 32 KiB and 64 KiB granules and reads back their relocated addresses
from a third: they lie apart by at least the lower one's granule (256 bytes apart before).
docs/REPLAY-STREAM.md says how the backend places buffers.
2026-11-18 14:53:10 -08:00
Anees Iqbal 051236c0c2 replay: a placement over an equal sampler state's index does not wait, and one a held commit owes stops the play
u3 stopped at player frame 259: the placement of a sampler state at index 16 waited for commit
1614 (#20713), which rt held at Committed because it waits for event #35 to reach 309, which only
command buffer #20439 signals, encoded 20 records later. The program had released #10401 (index 16,
bound directly by #20713) and made #20822 with the same descriptor the next call; Metal gave it ID
16 again. Nothing changed for the work in flight, and the original run did not wait (it could not:
#20713's signal was not yet encoded).

- A sampler state whose recorded descriptor is the one placed last at its index takes the index
  without waiting, counted on the indices line; the index stays owed for another sampler state.
- The player tells the backend, at each look for command buffers to wait for, the committed ones
  no record played so far lets complete (Backend::held: their unmet event waits, or a held one
  ahead on their queue). A placement owing its index to one of those stops with PlayError::Held
  naming the chain, instead of waiting for ever.
- docs/REPLAY-STREAM.md says what record order does not promise (a committed buffer may wait on a
  later record's signal) and what the indices line and the stop say.

Tests: a unit test of the equal rule in Indices; rt_replay device tests of our own sequence: an
equal sampler state at an index a held commit owes plays through without a wait; another
descriptor there stops with Held naming #6 and its unmet wait. Check follows.
2026-11-18 14:25:12 -08:00
Anees Iqbal 1e8e5974fc REPLAY-STREAM: section 6 names the writes at a completion
The comparison point takes the GPU's bytes at a completion only for 4 KiB chunks wholly inside
GPU-only ranges, and a recorder may record what a command buffer's GPU work stored in memory the
CPU shares as writes after its commit: which chunks are compared, the Managed rule, why the
player's waits make them change nothing, and the restore they let a stream carry. The planner's
text, verbatim, for the recorder change that lands with it.

Doc only; no test reads this section.
2026-11-18 10:57:59 -08:00
Anees Iqbal f811e7cc2d replay: delete the unbound-buffer-read counter, whose reflection decoded each pipeline state's AIR again inside the play's pipeline time
The counter (74fe5e67ca) asked the translator for each pipeline state's reflection to learn its
used buffer arguments. From a Function source that reflection decodes and specializes the
kernel's AIR a second time, inside the backend call the player books as pipeline cost, so every
play paid it: on b3 on the 780M, pipeline time 11.9 s against 1.5 s at f0df30b6ba with the same
403 translations (exclusive A/B, 47329). Its follow-up is dropped, so the count, its report line,
its per-frame counter, its test and its paragraph in REPLAY-STREAM.md go.

Verified: see the exclusive A/B in the hand-over (b3, 780M, development's tip against this).
2026-11-18 10:15:38 -08:00
Anees Iqbal 0463eb6d2d replay: a placement waits for the commits that named its index's holders, which count once retired
Under the owner rule the runtime gives a held index to the newer object, so a placement while
an earlier holder's work runs takes the element from under that work, which Metal leaves the
program never to do (docs/RESOURCE-ID.md); the program's own timing kept that duty, and the
player, the runtime's consumer here, now keeps it. Each index is owed to the last commit that
named an object holding it, live or released (a released one's uncommitted users owe it at their
commit; a command buffer released uncommitted owes nothing), and a placement there, named, lowest
or highest, first waits for that commit. The `indices named` line counts the waits and their
time.

A commit counts done once its completed handler has run: the runtime sets a command buffer's
status before it drops what the command buffer held, and runs the handlers after, so the status
alone could find the work done while the runtime still held the old holder.

Verified: the ledger's unit test an_index_is_owed_to_the_commits_that_named_its_holders (to run
in the lane's check). The device test that holds work in flight comes after the reruns.
2026-11-18 09:01:28 -08:00