Commit Graph
6854 Commits
Author SHA1 Message Date
Anees Iqbal 323a60228e rt render docs: the replay streams' render contents counted with each function resolved at its creation
The step-1 docs said 1,641 render contents over gb and b2, 1,631 drawing only triangles. The census
behind them keyed contents on the recorded linked-function handles, which a stream reuses for later
objects once one is released, so one content counted many times. Resolved at each creation (job
m3-max-44425, render_cold over gb and b2): 537 contents drawn (gb 273, b2 264), 527 only triangles,
2 lines and triangles, 8 only lines, as before.

Verified: docs only; the counts are job m3-max-44425's.
2026-11-17 22:51:54 -08:00
Anees Iqbal 449794ae8d rt: the in-flight count's doc carries the RTX 3090's rows
The RTX 3090 with the split probe (b15b306d2f: development's merged entries plus per-command-buffer
timing, M2V_PROBE_IN_FLIGHT), IN_FLIGHT two against three:
- frame_5cb, eight alternating arms (m3-max-44546): mean commit-to-complete 183.2-187.9 us at two
  against 152.2-164.8 us at three, 13% less; wall p50 124.8-125.6 us against 127.5-136.0 us,
  +3.2% at the median, at the 3% line.
- long_4cb (m3-max-44525): mean commit-to-complete 44.3 and 67.2 ms at two against 32.6 and
  32.9 ms at three; wall p50 37.0-37.4 ms on both.
- burst_160 (m3-max-44525): 2891.4 and 2914.4 us at two against 2894.8 and 2912.1 us at three.

With the UHD 630, RTX 2080 and RX 550 rows already in the doc (m3-max-44424, 44423, 44437), three
is ahead on commit-to-complete on every device, the burst flat on each. The constant's doc gains
the 3090's line. Doc only: the branch's check (m3-max-44521) and legs ran at 136442db7a.
2026-11-17 22:50:50 -08:00
Anees Iqbal b2e62a98b5 rt: the in-flight count's doc and the README's lateness gap carry the RX 550's and the count of four's numbers
The RX 550's split at three (m3-max-44437, b15b306d2f) kept burst_160 at 879.7-881.9 us against
880.9-881.9 us at two, and frame_5cb's wall at 65.9-66.0 us against 66.8-70.3 us. It saw
long_4cb's second command buffer 0.9-1.4 ms after its end at the median, against 14.9 ms.
Four in flight lost on two rows. On the UHD 630, burst_160 took 2768-2839 us against
1850-1860 us at three (m3-max-44443). On the RTX 2080, long_4cb's mean commit-to-complete was
78.1-78.2 ms against 42.8-43.2 ms (m3-max-44442). So three is where the count stops, and the
constant's doc says why. The README's known gap gives the lateness measured at three on the 2080
and the RX 550.
2026-11-17 22:50:49 -08:00
Anees Iqbal 1d8b959f1b rt: a queue keeps three submissions in flight before it holds a group, not two
With two in flight, a queue's next command buffers wait in a group until a completion leaves
fewer than two. Whenever that completion comes late, the GPU idles between the group's end and
the next submission's start. Behind three it has one more submission queued.

Measured with the split probe (b15b306d2f: the merged entries plus per-command-buffer timing,
M2V_PROBE_IN_FLIGHT; order old, new, three, three, new, old; 200 runs a row):
- UHD 630 (m3-max-44424): frame_5cb 420-429 us of mean commit-to-complete against 895-1137 us
  at two (old 318-951 us), wall p50 278-303 us against 647-793 us. burst_160 1834-1849 us
  against 1840-1841 us. long_4cb's second command buffer seen complete 74.7 ms after its commit
  against 99.2 ms.
- RTX 2080 (m3-max-44423): frame_5cb 161 us against 148-181 us, wall p50 124.8-126.8 us
  against 124.7 us; burst_160 2814-2821 us against 2811-2820 us; long_4cb's second 76.5 ms
  against 96.8 ms, the row's mean 42.3-42.8 ms against 57.8-58.5 ms (old 76.8-77.8 ms).

IN_FLIGHT is the crate's constant for that count, and the tests take it from there:
behind_busy (was behind_two) commits that many busy command buffers. The new test
every_device_keeps_three_submissions_in_flight_and_holds_the_fourth pins the count. Behind two
running command buffers a commit goes at once, alone, and the next is held, both seen before
the first busy one ends on the GPU. With two or four in flight the test fails.

Docs: the constant's doc, the README's queue paragraph, the CommandBufferStatus::Scheduled,
abandon and send_now docs, and the across-queue metrics' docs say three.
2026-11-17 22:50:49 -08:00
Anees Iqbal 2ac0ea6799 replay: each frame's end says where its wall time went
A spike frame's wall time needs a split by cause before two runtimes can be compared on it. The
player now times, on its own thread, each kind of work: reading and decoding the stream and its
blobs, writing bytes into the runtime's memory, reading back, waiting for command buffers, the
calls that make or release resources (with the longest one), the calls that make libraries,
functions and pipeline states (with the longest one), every other runtime call, and reading the
runtime's counters; what is left is the player's own work. Beside them, a frame's GPU busy time
is the union of the GPU intervals of the command buffers it waited for, which a new Backend
method gives: both runtimes' GPUStartTime and GPUEndTime. The end line carries them, and the old
runtime's counters add its vkCreate*Pipelines and shader-cache nanoseconds.

A test plays three command buffers, two of them overlapping on the GPU, and checks the frame's
GPU busy time counts the overlap once and the end line holds the times.
2026-11-17 22:35:04 -08:00
Anees Iqbal e886ee4c74 rt tests: the held-group send test checks the rise only where the fill was held, so a fast GPU does not wait out its patience
On the RX 7900 XTX (44448) the test timed out after 60 s waiting for a submission. With 16 fills
the busy work ended before the fill was staged, so the fill went alone and no group was held.
The empty or abandoned command buffer behind it then took no submission, as it should, and the
test waited for a rise that could not come. The test now reads whether the fill was held (two
submissions since the busy commits) before it commits the command buffer behind. Where the fill
was not held, the test waits for the fill and tries again with more busy work. The rise is
waited for only behind a held group, which goes at once under the rule and only after a
completion without it, so the test still fails without the rule.
2026-11-17 22:10:50 -08:00
Anees Iqbal 0c01a5294f rt tests: the mixed group's empty command buffer comes after the signal, since one committed while a group is held sends it
Since 4eb40a7e9e, a command buffer with nothing for the GPU that finds its queue holding a group
sends the group at once. The merged-entries test, written before that rule, committed its empty
command buffer between the Shared fill and the signalling fill. Landed together (5345d32f34), the
empty one sent the held first and Shared fills as a submission of their own. So the mix passed
three submit infos in groups, not two, and the test failed on lavapipe (check m3-max-44453).

The empty command buffer now comes after the signal, which has already sent the group. It takes
no submission and joins no group, and the three fills share one info as the test means.
2026-11-17 22:09:40 -08:00
Anees Iqbal 5345d32f34 Reflow the import lists the rebase resolution unioned 2026-11-17 21:57:37 -08:00
Anees Iqbal 55fab4cfa5 rt: a command buffer without a submission of its own sends the group its queue holds, so its completion waits only on submitted work
A command buffer with nothing for the GPU, or one ended with an error (an abandon, a commit
after its end), that found its queue holding a group joined that group and retired with it. The
group went only when a completion left fewer than two submissions in flight, or at a host wait
for one of its command buffers. So that command buffer's completion waited on something not yet
submitted: a later completion or a wait. The planner's rule: nothing on the completion path
waits on a condition that something already submitted does not guarantee. Such a command
buffer still joins the group and retires in its place, after the command buffers before it as
Metal orders them. The group now goes at once, as a host wait for it would send it
(Fifo::behind_held raises send_through to the group's first place), and abandon wakes the
submit thread to send it. Nothing changes for one that finds no group held. The 10,000 empty
commits still take no submission.

The timestamp read's contract is unchanged, and its doc says why it holds.
Pending::stamps_written counts the segments the submit thread staged into its queue's group.
That group is always submitted, before any later one. At a loss or a failed submission the
command buffer ends DeviceLost, and its timestamps are never read. So the completion thread's
waiting read of a command buffer that completed with both stamps counted only waits on queries
written by a submission it saw complete.

Tests: every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind.
Behind two busy submissions a fill is held. An empty command buffer, then one ended NotRun by
abandon while it waited behind the group on an event never set, each has the group submitted
before the first busy one ends on the GPU. Without the change the group goes only once that one
completes, so no try checks and the test fails.
every_device_retires_a_group_in_commit_order_each_with_its_own_times now commits the ended one
after the three it groups with, since it sends the group.
README: the queue section says so.
2026-11-17 21:57:21 -08:00
Anees Iqbal f5696e8556 rt tests: every chain of empty, fence-only and event-only command buffers retires, each wait bounded
A play hung with the main thread in a wait and every rt thread idle, on a build with today's
empty-command-buffer path (59f4094a65), the two-value timestamp read (0383fdbded) and the fence
type (9a9135b4c9). This test commits the chains those paths take and waits for each with
wait_until_completed on a thread of its own, failing at PATIENCE where a wait does not return,
then reads the GPU times as a consumer does:

- an empty command buffer committed while its queue holds a group (behind_two);
- an empty one as the last commit before a wait;
- a fence-only one between two that fill (update, then a wait and a fill);
- two empty ones on a queue that never submitted, then behind work that completed;
- empty ones and a fence-only one with a second queue's commits between them;
- one ended NotRun after its first segment was submitted (an event wait the host never meets,
  then abandon);
- one whose only segment signals an event, then one whose only segment waits on it.

Every completed handler must run.

Verified: on lavapipe and the device legs, in the jobs that follow.
2026-11-17 21:57:10 -08:00
Anees Iqbal 8fa569e62d harness, matrix: each runtime keeps its pipelines in a store of its own, fresh for the matrix's main run and warm for its warm run, so create_state and the first uses compare like for like
The old runtime's shader cache defaulted to the per-user ~/.cache/metal2vulkan, which every earlier
run on the node had filled, while the new runtime's harness device kept no store: create_state's
first state and the first-use rows timed old warm against rt cold (jobs 44170, 44171: old's first
on the 2080 2.9-3.2 ms on its warm cache, 8.9-9.7 ms on a fresh one).

- old::system_default and rt::system_default take the store (None: the runtime's default, for the
  tests).
- The command takes --store DIRECTORY: each session keeps its pipelines in
  <DIRECTORY>/<place>-<runtime>; without it, a directory made for the run under the OS temp
  directory and removed when it ends. Each runtime's line and each create_state row say
  "store fresh" or "store warm, N files".
- The matrix gives each runtime's main run a fresh empty store beside its fresh driver cache, and
  its warm run the same store; a re-timed row's runs take the harness's own fresh store.
- VALIDATION.md and the harness docs say so.

Verified: the matrix's harness script, rendered and run against a stand-in harness, passes a fresh
--store to each runtime's main run (cygpath'd on Windows); the build, clippy and the authored tests
in the check job.
2026-11-17 21:56:01 -08:00
Anees Iqbal c159a2004d harness: the completions' times by place are a type of their own, for clippy's type_complexity 2026-11-17 21:55:45 -08:00
Anees Iqbal e0f76d7836 harness: a multi-command-buffer row is judged by its last command buffer's commit-to-complete time, and each command buffer's lateness is a column
The planner's ruling on long_4cb's red: rt reports the command buffers committed while an earlier
one runs complete together, at the group's last end, which the owner accepted. The mean over a
run's places counted that lateness: on the 2080, long_4cb's #2-#4 came at 96.2-97.3 ms where the
old runtime's came at 71.7, 83.7 and 95.6 ms, while the last's own (96.6-97.2 against 95.6-95.8
ms) is not late (jobs 44196, 44197). The rule holds for every row of several command buffers, so
frame_5cb's too.

- run::matrix_time is the steady time of each run's last command buffer's commit-to-complete
  time.
- The harness's completed handler is given its lateness, from the command buffer's GPUEndTime to
  the handler's start on the runtime's host clock (rt::host_time, the old runtime's host_time);
  Report::late_us holds it by place, and the table prints late_us_p50 and late_us_p99 beside the
  c2c columns, with a line by place. It is no record: no ceiling until the first host-time matrix
  shows it on every GPU.
- The rt README's queue known gaps carry the measured lateness; VALIDATION.md and the harness
  docs say the last command buffer's time.

Verified: the matrix_time unit test asserts the last place's time where the mean differs; the
check job builds and runs it.
2026-11-17 21:55:45 -08:00
Anees Iqbal 22df87dd5c rt tests: the mixed group's submit infos are counted from once the busy submissions are, and are two
The test read its baseline as soon as behind_two had committed the two busy command buffers. The
submit thread may not have submitted and counted them by then. So the count in groups took the
busy submissions' two submit infos too, and read 4 on every device and on lavapipe. A probe of
each submission (d6bab091f4, job m3-max-44367 on lavapipe) showed it. The mix went as one
submission of one info holding the first fill, the Shared fill and the signalling fill (the
empty one took none), then the wait's own info: two. The busy ones went alone, one info each, and
were counted after the baseline. The merge rule does not differ by device, and neither does the
count.

The baseline is now read once both busy submissions and their infos are counted (the infos
against those counted when the last try's work completed). The test then holds the count to
exactly two, not fewer than four.
2026-11-17 21:55:45 -08:00
Anees Iqbal 04154a6a17 rt tests: the burst's submissions hold sixteen at most, and the mixed group is counted behind work that still runs
Groups hold sixteen now, so every_device_runs_a_burst_in_submissions_of_four_at_most (which asserted
at least count / 4 submissions) failed on the XTX, the 780M Phoenix, the 3090 and lavapipe; it
is every_device_runs_a_burst_in_submissions_of_sixteen_at_most, bounded by submit::GROUP.

The mixed-group test committed its mix behind two command buffers of 16 fills and counted it
whether or not they still ran: on the XTX, the 2080, the 3090 and lavapipe the busy work had ended,
nothing was held, and the mix passed four infos (legs 44213, 44214). It now runs behind_two, as
the cross-queue test does: more fills each try, counted on the first try where both busy command
buffers still ran once the mix was committed.

Verified: in the device legs that follow.
2026-11-17 21:55:45 -08:00
Anees Iqbal c65a4fb740 harness: each row prints the submissions and submit infos a timed run made
The runtime's submissions and submit infos (Device::submit_infos, Metrics::submit_infos on the
new runtime, none on the old) over the timed runs, two in flight, per run: what grouping and
shared submit infos made of a run, where the row's submissions column counts one run done alone.
2026-11-17 21:55:44 -08:00
Anees Iqbal 45d18535d3 rt: a group's command buffers share one submit info where no event wait or signal separates them, and a group holds sixteen
The planner's ruled form. A submission's segments go in as few VkSubmitInfo2s as its event waits
and signals allow: a segment that waits on nothing joins the info before it where that one
signals nothing (submit::infos), the upload with the first. Each command buffer keeps its own
timestamps and its commands, barriers and completion are unchanged: only the info boundaries
move. The UHD 630's driver paid about 160 us for each info (probe 06860a3848, job m3-max-43935:
burst_160 at a group of eight 1.9-2.9 ms merged against 28-30 ms in separate infos and
11.6-25.8 ms on the old runtime); the 2080, RX 550 and 3090 ran merged within 1% of separate.

A group holds sixteen command buffers, by the ruled rule (no bound if the UHD without one is
within 3% of its best arm, else sixteen): on the UHD, merged burst_160 ran 1.85 ms at sixteen
and 3.6-4.1 ms unbounded (job m3-max-44105).

Metrics::submit_infos counts the infos passed, so the merged path shows it ran.

Tests: tests::submit_infos (the merge rule: shared until an event wait or signal, a signal-only
info, one segment, none); every_device_shares_submit_infos_within_a_group_and_records_what_it_
records_alone (a group mixing a Private fill, a Shared fill whose end barrier reaches the host, an
empty command buffer, an event signal and its wait: barriers, passes, bytes copied and the words
equal to the same command buffers committed one at a time; fewer infos than command buffers in
groups, one each alone).
2026-11-17 21:55:44 -08:00
Anees Iqbal 1d460b2efd translator: the from_queries path keys a render descriptor by fixed-width words (queried_render_descriptor_key)
The new runtime keeps its map of contents under the key of a render descriptor, and a seen
render state cost 2.4 us (harness m3-max-44304, create_render_state p50 at aacdf481ce) against a
compute state's 0.8: render_descriptor_key took 2.27 us of it (bench m3-max-44376 at 7c9918994d,
32.8k instructions against compute_pipeline_key's 7.2k), most in writing the descriptor's fields
in their Debug form (0.41 us for the eight colour attachments alone).

Device::queried_render_descriptor_key keys the same fields as render_descriptor_key, each stage by
its compile key under the default inputs, the profile and SEMANTICS_VERSION, but writes every other
field as fixed-width little-endian words, tags and counts before optional and repeated parts,
under its own domain. Every field of the descriptor and of each struct it holds is destructured,
so a new field does not compile until the key writes it. metal2vulkan-rt keys render contents on
it. render_descriptor_key, the old runtime's (which keeps answers in its cache directory under
its values), is not touched and goes at the cutover.

Tests: the old key of one known descriptor is pinned to its value at 7c9918994d
(9d941806..., read by the bench m3-max-44376); the new key differs from the descriptor's for a
change in each field group and on another profile, and the old key tells each apart too.

Verified: cargo fmt; api_signatures blessed. Lint, the bench and the harness follow as potluck
jobs.
2026-11-17 21:50:59 -08:00
Anees Iqbal d3adc366cf harness: a render state's first creation is its first_create_us too
time_states timed a render state's first creation as first_us and left first_create_us None, so
the row printed no first and first_create_us's doc (the part of first_us the creation paid) held
for compute alone. A first creation time_states times itself is now both; the row prints it as
the creation alone. Render's first gets its first draw with the draws.

Verified: cargo fmt; lint and the harness rows follow as potluck jobs.
2026-11-17 21:50:59 -08:00
Anees Iqbal 30985352a4 rt tests: the pooled-take-beside-a-kept-dedicated-block test releases the block by its handle
The deadlock fix's test (8f4d6a1066) was written before the block handle (6dab612810) landed
and still called release_block with a BlockId, so rt's lib tests did not compile under
--cfg m2v_gpu or m2v_cpu_icd (quick check m3-max-44401). It now keeps the dedicated block's
number, gives the handle to release_block, and holds each pooled take's handle to the end, as
the numbers were held before, so the second take still waits for the block maker instead of
taking the first take's block back.

Verified: cargo fmt; clippy for both device cfgs and the lavapipe run follow as a potluck job.
2026-11-17 21:50:33 -08:00
Anees Iqbal 8f4d6a1066 rt: the block-maker thread makes a class's next pooled block whatever dedicated blocks it keeps idle
Since given-back dedicated blocks are kept idle (208887e13a), a class's
idle list holds pooled and dedicated blocks, but the block-maker thread
still judged a class ready by the idle list's length. Pool::take hands
out only pooled blocks, so once a class kept READY or more dedicated
blocks and no pooled one, the maker slept while a pooled take waited for
it forever: replay's play of a recording stalled in Device::take_block
(job m3-max-44321, gdb stacks from the replay lane).

The maker now counts only the class's idle pooled blocks (State::ready),
as does the tests' Pool::idle, which waits for the ready ones. Take,
keep (the ready block is the latest pooled one), take_held and remaining
already told the two apart.

Test: every_device_makes_pooled_blocks_while_it_keeps_dedicated_ones
keeps a dedicated Shared block idle beside the ready block, then takes
two pooled blocks, each under a 30 s timeout; without the fix the second
take waits forever.
2026-11-17 21:44:43 -08:00
Anees Iqbal 363088e6c4 rt README: a kernel observing its partition pays the UHD 630's address penalty in narrow square workgroups
A kernel that observes its threadgroup partition keeps its own threadgroup size as the Vulkan
workgroup. On Intel's Windows driver (101.2145) for the UHD 630, a per-thread buffer access
through a device address is about twice as slow in 16x16 workgroups as in the 256-thread tiles
or in 128x2 workgroups, and storage-buffer descriptors remove the difference. Descriptors are not
taken: the runtime binds buffers by address alone, so this is recorded as a known gap of pipeline
states.

Measured on a probe build (4f8a9df6b5, on development 80bd8ca764, post-pace), potluck jobs 44328
and 44329 on the UHD 630, the median over two rounds of 100 runs' GPU time (p50):
- texture read + 16-byte buffer store, 2048x2048: tiles 3,721 us, 128x2 3,735 us,
  16x16 7,775 us, 16x16 through descriptors 3,585 us;
- 16-byte buffer read + texture write, 2048x2048: tiles 4,634 us, 128x2 4,735 us,
  16x16 6,554 us, 16x16 through descriptors 4,605 us.
The share of threads (2.0% and 3.4%) is the replay count of observing kernels at threadgroups 32
threads wide or narrower that store to device memory, over the two recorded streams.

Docs only; nothing built or run for this commit.
2026-11-17 21:40:17 -08:00
Anees Iqbal 4c5257d3ec replay: the report's first line names the runtime and whether the play took snapshots
A timing table must never come from a snapshotting play unnoticed: the device line reads
device NAME runtime old|rt snapshots yes|no for both runtimes.

Verified: cargo fmt only; clippy, replay tests and the release build next.
2026-11-17 21:38:16 -08:00
Anees Iqbal fd0f8fcaef replay: --snapshots no plays every m2v.privateBytes dispatch as it is on either runtime, so old's and rt's plays do the same work
Old's play of gb on the 3090 with snapshots read 0.54 of 1.9 GB of stream in about 5 minutes
(m3-max-44322, cancelled before its 15-minute limit): the player's own splits and readbacks around
12,000 dispatches dominate it, and rt declines them, so their frame times and memory would not
compare. Player::without_snapshots takes none on any backend.

Verified: cargo fmt only; clippy, replay tests and the release build next.
2026-11-17 21:38:16 -08:00
Anees Iqbal 6dab612810 rt: take_block returns a Block handle, and dropping a block's last handle gives the block back
A block was plain data (BlockInfo) owned by the device's claims map until release_block(id) or
the device's teardown, so a block whose number the consumer lost was held until the device died:
memory unreachable but held, a leak by construction, which the "zero at device drop" gauges do
not see (the player's play ran out of memory at frame 1074). The planner ruled the handle as
proposed:

- take_block returns Block, rt's own handle with no Metal counterpart, which derefs to the
  block's BlockInfo. Clones share one claim (Claim); the drop of the last handle runs what
  release_block ran: the device forgets the block's number and the work's pending upload counts
  it, and the block is zeroed and kept or freed once no buffer, command buffer or upload uses it.
- The device keeps claims by number as weak references, now in the core (Core::claims), so every
  call that takes a block number still does (new_buffer, new_managed_buffer, heap ranges); a
  number whose handles are all gone answers Error::NoSuchBlock.
- release_block(block: Block) consumes a handle: the drop made explicit; another device's block
  is Refusal::OtherDevice.
- The device's teardown frees every block still claimed after halt, that is after the consumer's
  BlockMappings::unmap returned for each handed block (contract 6A's order: the claims' slots are
  emptied only then); a handle dropped after the teardown finds its slot empty and does nothing.

The harness keeps each pooled block's handle and gives a dedicated block's to its buffer; the
replay backend keeps a stream block's handle in its object and a dedicated place's in the place.
rt's tests hold their handles where they used to hold numbers.

Tests (device cfg, command.rs): a dedicated block whose last handle drops with no release_block
while a held command buffer uses it answers NoSuchBlock for its number at once, stays live
(Gauges::blocks one up) until the command buffer completes, and is then freed (back to where it
was); of two clones, dropping one gives nothing back and the number still names the block,
releasing the other frees it; a handle that outlives its device finds every gauge zero after the
teardown, and its drop does nothing. README, the BlockInfo, NoSuchBlock and OtherDevice docs,
docs/REFUSALS.md and api_signatures.tsv follow.
2026-11-17 21:36:45 -08:00
Anees Iqbal 7c9918994d rt render: a state keys the device's map of contents on its descriptor's key, as a compute state does
A seen render content cost 220.9 us a creation (harness 44254, create_render_state, p50 at
80b8705d4f) against compute's 0.8 us: the map's key was Device::render_variant_key, which decodes
and specializes both functions on every creation. Compute keys the same map on
Device::compute_pipeline_key, which reads no function. Render now keys it on
Device::render_descriptor_key (every field, each function by its compile key under the default
inputs; the old runtime's memo key too), and decodes, keys for the compile and lowers only on a
miss. The one map stays bounded at 1,024 entries; a device test fills it past a cap of 2 with
render contents and checks the gauges and the frees. The cost: two descriptors that differ only in
a field their compile does not read compile apart (README, module doc).

Verified: cargo fmt; lint, device tests and the harness rows follow as potluck jobs.
2026-11-17 21:32:51 -08:00
Anees Iqbal 5abc08895a harness: the creation test takes render states as it takes compute states 2026-11-17 21:32:51 -08:00
Anees Iqbal 7abf8df6a3 rt render step 1: fix forward the lint (PipelineKey is Copy, CREATES holds five, a harness doc link as plain code) 2026-11-17 21:32:44 -08:00
Anees Iqbal 11b77a466e rt: render pipeline states on the content key, sharing the device's map of contents
Device::new_render_pipeline_state(&RenderPipelineDescriptor) is
newRenderPipelineStateWithDescriptor:error: without reflection. A state's content is the
translator's render_variant_key of its descriptor; render contents and compute kernels share the
one bounded map of 1,024 contents (kernel_map::Content), so a state of a held content costs the
key and a lookup. Each content lowers its vertex and fragment functions through the cache
directory's translations, and makes its triangle-class VkPipeline at creation through its own
pipeline file (the per-pipeline cache use is now one helper, made_through_cache, shared with the
compute path, and the layout's words one function, layout_words). A point or line class's
VkPipeline comes with the draws. Everything Vulkan 1.3 leaves dynamic is dynamic state; the
pipeline renders dynamically into the attachments' formats.

Built: one vertex and at most one fragment function, colour and stencil attachments, one sample.
Refused by Gap::RenderPipeline with a RenderPipelineKind: depth, multisample, amplification,
tessellation, synthesized stages, framebuffer fetch, imageblock, shader stencil, alpha to one,
step rate, numbered samplers, constant data, other specializations, dynamic state beyond 1.3,
and a feature or extension device creation does not enable. Gauges::render_contents counts the
contents alive.

The harness gains create_render_state, create_state's render twin: colored_vertex and
colored_fragment of the public examples fixture into one BGRA8Unorm attachment, the first
creation (a content unseen) timed apart, then 1,000 of the seen content, on old and new.

Tests (tests/render.rs, every device of the cfg's kind): a second state of a content lowers and
makes nothing and shares the first's; another format, a blended attachment and a stencil
attachment with two colours are contents of their own; depth, four samples and a constexpr
sampler are refused by kind with no pipeline; a device on a cache directory a device before it
used reads both lowerings and writes nothing.
2026-11-17 21:32:33 -08:00
Anees Iqbal 21b5fb6c3d replay: the rt backend's counters add dedicated blocks taken again and dispatches without effects, and its frame ends the idle Shared and Private bytes the pool keeps 2026-11-17 21:14:28 -08:00
Anees Iqbal 27b870d2af replay: old's allocation and free counts are its ObjectChurn's, the process's vkAllocateMemory and vkFreeMemory calls 2026-11-17 21:14:04 -08:00
Anees Iqbal c2ab6cc79a replay: the rt backend times each compute pipeline state's making and says whether its kernel was new, on a pipeline line of the report
The planner asks whether NVIDIA's first-pipeline cost is paid once per process or once per
kernel: each state's making's wall time, in order, with whether another specialization of its
kernel (a library's function by name) was made before. Backend::lines carries the backend's own
report lines; command-replay prints them after the player's.

Verified: cargo fmt only; build, clippy and replay tests next.
2026-11-17 21:14:04 -08:00
Anees Iqbal 1a615bd802 replay: old's executed counters add its vkAllocateMemory and vkFreeMemory calls 2026-11-17 21:14:04 -08:00
Anees Iqbal dbe3450966 replay tests: the frame-end test reads the line's end with ends_with 2026-11-17 21:13:05 -08:00
Anees Iqbal 9ab646922d replay: the rt backend gives the stream's blocks and heaps back at their release; old plays what only the scratch player did; each frame's end reports wall time, resident memory and the backend's gauges
- The rt backend dropped a released m2v block or heap without Device::release_block, so every
  block gb made and released stayed allocated; the 3090 play stopped at frame 1074 on
  vkAllocateMemory (m3-max-44161).
- The old backend skips a library from source (no device here compiles Metal source), what is
  made of a skipped object, and the draws of a render encoder whose pipeline state is one, all
  counted; it takes MTLRenderPassDescriptor.renderPassDescriptor and the copyFromBuffer:...
  toTexture: form without options. Those were the scratch player's alone, so old could not play
  gb from development.
- Each frame's end line: wall nanoseconds, VmRSS, and the backend's gauges as they stand (rt's
  live blocks, buffers, textures, pipelines, kernels, command buffers, spilled bytes and the bytes
  of the blocks the backend holds by class; old's live, empty and dedicated memory blocks). Old's
  counters add device memory allocated and pooled blocks made and freed. The skipped and gaps
  lines are printed for both backends, before ok or error as documented.

Verified: cargo fmt only so far; build, clippy and the replay tests run next on msi.
2026-11-17 21:13:05 -08:00
Anees Iqbal c64e299830 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-17 21:12:53 -08:00
Anees Iqbal 9769864acf translator: the identity gate counts descriptors, not a fragment function's colour attachments 2026-11-17 21:08:25 -08:00
Anees Iqbal aeea5f1721 translator: vertex and fragment functions lower under the identity domains on the floor's push window
identity_admits took kernels alone. On Device::from_queries' profile (PushWindow::Floor) it now
takes a vertex or fragment function under the same conditions as a kernel: every buffer slot
reached through its pushed device address (SlotGuestBase), textures and runtime samplers by
resource ID, constexpr samplers by pushed index, no descriptor, no unsourced fact. Device::new's
profile refuses them as before (Unsupported{IdentityDomains}, not implemented), so its output is
unchanged. The stages keep their fixed windows (vertex [0, 64), fragment [64, 128)) until the
render push layout is ruled.

Test (tests/engine_identity_render.rs, no GPU): colored_vertex and colored_fragment of the owned
examples fixture compile on from_queries' lavapipe and moltenvk-m3 profiles, the vertex function
pushing its two buffer addresses in its window with no descriptor, root table or parameter
block, both modules passing L3; Device::new's profile still refuses them.
2026-11-17 21:08:25 -08:00
Anees Iqbal 208887e13a rt: given-back dedicated blocks are kept idle with the pooled ones, up to a byte bound per class
A block given back, pooled or dedicated, is now zeroed by the block-maker thread and kept as
its class's latest idle block. It keeps its number, address and mapping, so the consumer's
mapping stays too. Each class keeps at most a bound of idle bytes, MemoryClass::idle_bound:
256 MiB Shared and 128 MiB Private. The class's ready block (its latest idle pooled block) is
a reserve outside that bound. Past the bound, the oldest kept block is freed through
BlockMappings::unmap, whether it is pooled or dedicated. A block longer than the bound, or a
spilled one, is freed at once. This byte bound replaces the count IDLE_MAX = 2.

A take past the pooled length first takes the shortest kept dedicated block that it fits
and fills at least half of (memory::fits), and only allocates when none does. Each reuse
counts in Metrics::dedicated_blocks_reused. Gauges::shared_idle_bytes and
private_idle_bytes count what is kept, the ready block included, and read zero after
teardown.

Why: a program that makes and releases large buffers frame after frame paid a fresh
vkAllocateMemory each time, and the driver's hold on the device's other calls with it. On an
RTX 3090 (NVIDIA's Linux driver, probe ecb66a34eb, job 44126) a 32.6 MB Managed buffer's
dedicated Shared block cost 8.3-10.8 ms in the call and held submissions for up to 7-19 ms.
Old took 1.6-1.8 ms for its second such buffer, a range in a 64 MiB block it already had.
Under the hold, only the first pair pays. Probe 4b48aa5c9b (jobs 44208-44210) made the pair,
gave it back and made it again. The second pair took 0.01-0.02 ms with no submission held
(longest round trip 0.10-0.19 ms, against 0.09-0.11 median), and dedicated_blocks_reused
went 0 to 2 with no block made. That held on the RTX 3090 and the RTX 2080. On the RX 550
the first pair took 3.8-4.6 ms and the second 0.01 ms. On that probe a fresh block's
create, bind, address and map took 18-75 us, the allocation 6.0-11.1 ms and the zeroing
1.2-1.7 ms. Under the hold the zeroing runs on the block-maker thread at give-back.

Tests: a_kept_dedicated_block_serves_a_request_it_fits_and_that_fills_half_of_it (the rule).
every_device_keeps_given_back_dedicated_blocks_for_requests_they_fit: of three 100 MiB
Shared blocks given back, two are kept beside the ready block and the oldest is freed
through the hook. A 60 MiB request takes a kept one, zeroed, as it was, with nothing made;
40 MiB and 101 MiB requests make their own. A dedicated Private block is kept beside the
Private ready block and taken again. Gauges read zero after teardown.
every_device_keeps_idle_blocks_up_to_the_bound_and_frees_the_oldest replaces the two-block
test: 18 Shared blocks given back leave 16 kept beside the ready one, and the oldest is
freed. The hand-out test's dedicated block is past the bound, so it is still freed on
release. API table re-blessed.
2026-11-17 21:02:00 -08:00
Anees Iqbal 32d511d17d harness, matrix: long_4cb runs one size on both runtimes: --size gives a sized row its size, the matrix passes the first runtime's to the later runs, and a row run at two sizes fails uncompared
A workload whose size follows the device (long_4cb) was sized by whichever runtime ran it first in
its process. The matrix times each runtime in its own process, so each sized it from its own base
time, and they could run different work: the RX 550's long_4cb ran at different sizes on the two
runtimes at 594b86d1f2, and its ratio compared unlike runs.

- run_each takes the size where the caller gives one (ScaledTo::base_us is then None) and times no
  base; a size for a workload of one size is an error.
- The command takes --size NAME=N (repeatable; a name it does not know is an error) and prints each
  sized row's size as an `M2V-MATRIX size harness-<runtime>/<row> <size>` record.
- The matrix reads the first runtime's "sized to" lines and passes them as --size to every later
  run: the main run, the warm run and the re-timed pairs.
- results.harness_budget fails a row whose two runtimes' size records differ (or only one has
  one), uncompared; `size` is a record kind.

Verified: python3 scripts/matrix/test_results.py, 29 OK; with the size check removed, the new test
fails (negative control). The matrix's harness script, rendered and run against a stand-in harness,
passes `--size long_4cb=4096` from the first runtime's line to the second's run. Harness unit test
a_scaled_workload_given_its_size_runs_at_it_and_times_no_base: build and run in the check job.
2026-11-17 20:57:07 -08:00
Anees Iqbal b96e61afa3 docs: VALIDATION.md's matrix says a harness time is host time and a ceiling is only ruled
The `time` record kind is what a program waits on, timed on the host (commit-to-complete where the
workload times it, else the wall time a run adds), since the harness's matrix_time change on this
branch; the harness budget lists no ceiling now, and one is given only by a ruling after the work
on its row. The doc said GPU time and measured-ratio ceilings.

Verified: the text only; python3 scripts/matrix/test_results.py, 28 OK on this branch.
2026-11-17 20:55:18 -08:00
Anees Iqbal a1a5ada454 matrix: the harness budget lists no ceiling: a ceiling is ruled after the work on its row, never taken from a measured ratio
The 2080's frame_5cb ceiling of 1.166 was its measured commit-to-complete ratio at 594b86d1f2,
which turned a red into a budget without a ruling. The GPU-time ceilings dropped earlier on this
branch were ratios of another measure. With none listed, every row over HARNESS_BUDGET fails its
leg until a ruling, made after the work on that row, gives it a ceiling.

Verified: python3 scripts/matrix/test_results.py, 28 tests OK.
2026-11-17 20:55:18 -08:00
Anees Iqbal 8b8e9e5475 harness tests: frame times its command buffer's commit to completion too
The matrix judges frame by its commit-to-complete time now (check job m3-max-44116 failed on the
old assertion that frame does not time it).
2026-11-17 20:55:18 -08:00
Anees Iqbal b74e1a50b9 harness, matrix: a row is judged by host time: commit-to-complete where the row times it, else the wall time a run adds; the GPU time is a diagnostic
The matrix judged every plan row by its GPU time (first command buffer's GPUStartTime to the
last's GPUEndTime), which is not what a program waits on, and whose placement changed between
builds. The harness's matrix time is now run::matrix_time: the steady time of each run's mean
commit-to-complete time where the plan times its command buffers' (frame, frame_5cb, long_4cb;
frame now times it too), else the steady time of the host wall time each run adds
(Report::wall_us, the timed loop's period with two runs in flight). The GPU time stays in the
table as a diagnostic; a new line per row prints the matrix time, what it is, and the wall p50.

results.py's ceilings were GPU-time ratios. They are now host-time ratios: frame_5cb on the 2080
keeps a ceiling of 1.166, its commit-to-complete ratio at 594b86d1f2; the others are dropped, and
the first matrix on host time sets the ceilings of the rows still over the budget.

Re-judged from the 594b86d1f2 matrix's harness output (c2c p50 of every command buffer, new over
old; the records hold no host wall time, so the burst rows and frame cannot be re-judged):
- frame_5cb: 780M Phoenix 0.671, 780M HawkPoint 0.693, RX 550 0.820, XTX 1.003 (pass, as on GPU
  time); 2080 1.166 (GPU 0.928: now over the budget, its ceiling 1.166); 3090 0.760 (its GPU
  ceiling 1.137 leaves the list); UHD 3.535 (GPU 2.395; fails either way).
- long_4cb, both runtimes at one size: 780M Phoenix 1.273, 780M HawkPoint 1.309, XTX 1.291,
  2080 1.345, 3090 1.266, UHD 1.154: pass on GPU time (0.99-1.01), fail on host time: a group's
  first command buffers are seen complete with its last. RX 550: the runtimes ran different sizes
  (1024 and 2048), so its ratio (1.014) is not comparable until both run the same work.

Test: tests::a_row_is_judged_by_host_time_never_its_gpu_time (wall time without commit-to-complete,
the mean of a run's places with it, the steady time of those means, none without host times).
scripts/matrix/test_results.py passes (28 tests).
2026-11-17 20:55:18 -08:00
Anees Iqbal 80bd8ca764 rt: pooled blocks are 16 MiB of Shared memory and 64 MiB of Private
A pooled block's length is now per memory class, MemoryClass::block_len: 16 MiB Shared and
64 MiB Private on every device. It replaces the one 256 MiB BLOCK_LEN. take_block gives a
pooled block up to the class's length and a dedicated one past it. Textures are placed in
texture blocks up to the Private length. The harness and the replay player's places take
blocks of the class's length.

Why: a driver may hold the device's other calls for the whole of a block's
vkAllocateMemory, and the hold grows with the bytes, so the length sets how long one hold
lasts. On an RTX 3090 (NVIDIA's Linux driver, probe at 70d7cae48e, jobs 44050 and 44053
with the RTX 2080), a pipeline creation beside a Shared block's making took 40-45 ms at
256 MiB and 6-8 ms at 16 MiB (3-4 ms settled). 16 MiB is the largest piece a guest's
allocator takes. Private holds less: 3.4-4.6 ms beside a 64 MiB block, at most 1 ms more
than beside a 32 MiB one. At 64 MiB, a texture or a Managed buffer's device copy of 32 MiB
takes a pooled block.

Tests: every_device_pools_16_mib_shared_and_64_mib_private_blocks covers the lengths, the
dedicated block past each, and a 32 MiB texture placed in a texture block. The memory,
command, places, spill and upload tests use the class's length. The memory test reads a
Private block back a Shared block's length at a time. API table re-blessed (the BLOCK_LEN
const goes, MemoryClass::block_len comes).
2026-11-17 20:51:54 -08:00
Anees Iqbal 9dada05c84 Re-bless the golden hash table after SEMANTICS_VERSION 2170
The pinned-subgroup-size change (48833908aa) bumped SEMANTICS_VERSION and
changed the simdgroup fixtures' modules; golden_hashes_match_the_table failed
with it, and AGENTS.md re-blesses on development after the merge. Blessed by
job m3-max-44193 at 1cd01ce3d7 (inventory, golden hashes and printouts all
exit 0; only golden_hashes.tsv changed, 280 rows); the commits since touch rt
only.
2026-11-17 20:50:16 -08:00
Anees Iqbal 50a09b553a rt README: the Managed copy form's known gap: a write reaches a texture over the device copy from the next submission
A command that writes a Managed buffer, or another texture over a range that meets the texture's,
reaches a texture over the device copy in an image of its own only from the upload that leads the
next submission: later commands of the same command buffer, or of a command buffer submitted with
it, read the older texels. A command buffer that wrote such a texture and is never committed
leaves its entry with the buffer until the buffer is released. Both were in the code's docs; the
known gaps of textures now say so where a user reads them.
2026-11-17 20:49:10 -08:00
Anees Iqbal 0277ef8dfe rt README: an M3 Max shows a texture over a Managed buffer an untold host write; the documented contract stays the rule
The probe managed_texture_stale_write.m (job m3-max-44076, macOS 27.0.1): after a host write with
no didModifyRange:, the texture over the Managed buffer shows the written bytes, as after a told
write; the macOS 27 SDK marks Managed storage as having no effect on Apple silicon. The runtime
keeps Metal's documented contract (copies in only at Managed events), which leaves the untold
write's visibility undefined.
2026-11-17 20:47:55 -08:00
Anees Iqbal 23633ab1f1 conformance probes: what a texture over a Managed buffer shows after an untold host write
The stale case of Metal's Managed contract (a host write with no didModifyRange:), run on a Mac
only to record what Metal does there, beside the told write as its control. Apple GPUs may alias
Managed memory, so the documented contract, not this answer, is the runtime's rule.
2026-11-17 20:47:55 -08:00
Anees Iqbal 4b88203551 rt: a texture over a Managed buffer's device copy that the device's linear image does not take is copied at Metal's Managed events
Where the device's linear image does not hold a texture over a Managed buffer's device copy in
place (another pitch, an offset off the image's memory alignment, a format or usage the linear
tiling lacks), the texture was refused (Gap::TextureOverBuffer). It is now an optimal image of
its own, copied from and to the device copy only at Metal's own Managed events, with no tracking
of commands:

- in, from the device copy, by the upload that leads the next submission using the texture,
  where a did_modify_range met its range (after the upload's copy of that range) or submitted
  device work wrote the buffer (a binding whose compiled interface writes it: the translator's
  uses, not the declared access; a blit or fill into it) or another texture over a range that
  meets its;
- back, where device work wrote the texture, before the next reader of the device copy (a
  binding that reaches the buffer, a blit from or into it, a copy into another texture over a
  range that meets its, a synchronize_resource, a did_modify_range over it). A reader recorded
  after the write takes it in its own commands; the upload that leads a submission, which runs
  before the submission's commands, takes it only once the write's segment was submitted
  (Segment::managed_wrote; the segment's submission settles each write it made).

The buffer keeps each such texture's entry (ManagedOvers). A texture released while its copy
back is owed leaves its image with the buffer until a reader takes it or the buffer is released;
a lookup by id skips a released entry, whose id a texture made since may hold. The Shared rules
(crate::over's per-submission copies) now apply only to textures over a buffer of no device copy
(copied_shared). The planner ruled that Managed keeps its device side; this is that side's copy
form.

Tests (device cfg): the Managed device test (100 uses copy in once; a modify over the range
copies once, one outside it not at all; a kernel's write owes one copy, a read none; a written
texture read through its buffer by a blit; a synchronize; two textures over one range; a
released texture whose buffer goes copies nothing back and frees its image; one released before
a kernel reads its buffer goes back first), and a kernel that declares a Managed buffer
read-write and never touches it owes no copy. README, Gap::TextureOverBuffer's doc and
docs/REFUSALS.md follow.

Verified: lint m3-max-44117 and device legs m3-max-44136 (780M HawkPoint, 3090), 44137 (RX 550),
44138 (XTX, 2080, 780M Phoenix, lavapipe), 85/85 each with the validation layer on, on the same
tree based on ed6d11d477. The Managed tests ran on the six GPUs and took the Shared rule on
lavapipe. An earlier form, which marked a write's copy back owed at its encoding, failed the last
step on five GPUs (m3-max-44101, 44102, 44103): the upload leading the write's own submission
took it before the write ran.
2026-11-17 20:47:55 -08:00