A workload's time was the lowest nearest-rank median of its timed runs' windows of 10. Where a
runtime reports two runs' completions together, one run's wait takes both runs' GPU time and the
next run's wait returns at once, and the nearest-rank median of 10 such alternating runs is the
5th sorted value: the short wait's. On ms01's Iris Xe the old runtime's grouped submissions did
this in whole-harness runs: zero_products recorded 174 us while every run's GPU time was 4367 us
and its 200 timed walls had p10 174, p50 4388, p90 9454 (job m3-max-45343, probe f5be885e3f);
narrow_ints, constant_private and image_filter likewise, on the old runtime only. A window's mean
is the time its 10 runs took over 10, which the pairing does not move; the lowest window still
leaves out a window a clock drop or a hiccup slowed. Fewer than 10 runs take their mean.
Every matrix time record goes through steady (matrix_time, the creation rows), and the matrix's
re-timed pairs are the same records, so one statistic serves both.
Verified: the new unit test's alternating 9454/174 runs give 4814 where a window's nearest-rank
median is 174; the existing cases keep their values. Build, clippy and the harness's tests in the
check job named in the report.
The index arrays had no fill-past-capacity test. On every device of the cfg's
kind, one grant of the sampler class's whole range takes a sampler state at
each of its 3,999 indices, and one grant of the storage-capable class's whole
range takes a 1x1 shader-write texture at each of its 4,095. Then 128 of each
are dropped one at a time and made again at the index they left, as a
consumer reuses an index: 4,127 sampler states and 4,223 storage-capable
textures in all. Every make is unwrapped, so an index refused as in use
fails the test. The descriptor-slot gauge counts the class's capacity while
the arrays are full and the reuse runs, is zero once the objects are gone,
and the grants are released; after the device, the sampler, texture and
descriptor-slot gauges are zero.
Verified: the next job runs it on lavapipe, then on um790's GPUs from the
archives.
The new runtime's backend skips render pipeline and depth-stencil states, so nothing in its play reads their IDs; b3's play counted 8,082 of them as differing. It now counts them (skipped_resource_ids) and command-replay leaves them out of differing_ids, as it leaves the compute pipeline states' typed gap. The id lines stay.
The --only/--skip selection tests in src/bin/harness.rs never compiled:
the bin target set test = false, which its manifest comment justified by
the command having no unit tests. It has them now, so the bin builds its
test harness under cargo test, nextest and clippy --all-targets.
The test named its list of workloads after workloads(), which its last loop calls: the test
target did not compile (clippy, m3-max-45303). Verified by the check that follows.
The planner's timing rule for the matrix's harness legs:
- The harness takes `--skip NAME,...`, and a name ending in `*` in `--only` or `--skip` names
every workload it starts. A name that names no workload is an error.
- Each runtime's harness run skips the creation rows (`--skip 'create_*'`); they then run alone
(`--only 'create_*'`) in five processes per runtime, each with a fresh driver cache and store,
so no row before them moves their times. The first process's records are kept whole, its
device's gauges at drop renamed to harness-<runtime>/creates/device/... so every key is
recorded once; the later processes keep only the creation rows' first samples, as
harness-first/<row>/<n>/<runtime> (parked records).
- A creation row's first sample (/first, /first_take, /next_take, /first_allocation_total) is
judged by the ratio of the medians of its five processes; a single first sample is never red.
- A row's limit is 1.03 times the greater of its ceiling and its floor: the widest ratio between
two of the old runtime's own runs of the row on that GPU (scripts/matrix/floors.tsv, seeded
from store2's noise table's "widest" column; 1002:1900 has no column there, so its floors are
1). Ceilings are unchanged.
- A row past its limit is re-timed once, A B B A (two pairs), and fails only if the median of
the pairs' ratios is past the limit too.
Deterministic counts are untouched. docs/VALIDATION.md describes the new runs and rule.
Verified: scripts/matrix/test_results.py, 33 tests OK locally (new: a row within its floor
passes, past it but back within on its re-time passes, past both fails; first samples by the
median of five, never one alone; the creation processes' sed programs record each key once; the
floors table reads). The generated harness_runs shell passes bash -n for a Linux and the Windows
leg. The harness's selection tests and lint run in the check job.
new_texture refused both textures the test made without a granted index (legs m3-max-45324,
45325, 45326 failed at the first one). The test now grants eight texture indices first, as the
upload bound test does. Verified by the legs that follow.
capture_bytes counts the Managed capture ring and its overflow staging; the staging of copies
between textures and the CPU (replace_region, get_bytes) had no bytes gauge, only its
allocations in `blocks`. staging_bytes now counts the 16 MiB staging region once a copy made it
(Work::stage installs it; the device's teardown frees it), and each staging buffer of its own a
copy larger than the region takes, from its making until it drops with the upload that copies
through it. The replay's new-runtime report lists it, and the API signature table has the field.
Test: upload.rs's every_device_counts_its_staging_bytes reads 0 before any copy, the region after
a 256 KiB copy, the region plus 21,233,664 bytes after a copy of 2304 texels square, the region
again once that upload is gone, and zero after teardown.
The planner ruled that the RX 550's (1002:699f) constant_managed row shares constant_private's
ceiling of 1.20: the two rows run the same constant-table kernel, the table Managed in one and
Private in the other, and the cost is the same GPU cause, tiles over a grid one high and one deep
and the RX 550's 64-bit address per read. Matrix cbd4644463 timed constant_managed at 1.180 (the
median of three re-timed pairs) next to constant_private at 1.193. The rt README's known gap now
names both storage modes.
Verified: scripts/matrix/test_results.py, 29 tests OK; HARNESS_CEILINGS reads both rows for
1002:699f.
What: Metrics gain capture_copy_nanos (host time a capture spends copying Managed bytes into
the ring and into staging blocks of its own) and capture_wait_nanos (host time it waits: for a
submission's completion for room in the ring, for its own ring-full from its flush to its
completion, and for command buffers committed before to be submitted). The replay's per-frame
counters carry both, the API signature table is blessed, and the runtime's README names them.
The streaming test runs its three-ring commit twice (the first touching the ring and the device
copy first) and prints each commit's time split into host copies, waits (and a stream's mean)
and the rest, then times a ring-full's copy from a Shared buffer into the device copy alone on
the GPU, twice: the link a stream's copy crosses.
Why: the planner asked for the 44-92 ms 192 MiB streamed commits split into host copy, submit
and wait for the GPU copy, by timers and counters: whether the wait is the link's transfer rate
or a round trip of ours.
Tests: device legs to follow.
The allocator's contract now says where a large take's allocation is made: the pool keeps
8 MiB ahead per class, and a take larger than what it has kept (the very first 64 MiB take,
or a large take on a cold device) allocates on the calling thread. The planner accepted this
cost for create_64MiB/first_take and create_private_16MiB/first_take, which get per-device
ceilings in the matrix. Docs only.
The pool kept a class's idle allocations while they and its allocations in use stayed within
the most bytes in use over the last 10 seconds, and within an eighth of the heap of the class's
memory type. The window is now 3 seconds, and the heap-share cap (IDLE_SHARE, the pool's caps,
surplus's cap argument, the heap lookup in Device::new) is deleted.
Why 3 s: in the compute harness's full run plus a 15 s idle tail, rt at 3 s made no more
allocations on the consumer's threads than at 10 s, on every GPU measured, and 1 s made more
(rt's consumer_allocations, all rows):
GPU w10 w3 w1 job
RX 550 13 13 15 m3-max-45119
Iris Xe 14 14 16 m3-max-45120
RTX 2080 13 13 14 m3-max-45121
and on the 780M a replayed desktop session (1047 frames, rt; the player skips its render
encoders on every sha today, so this is its compute, blits and syncs) made the same number at
3 s as at 10 s, played twice alternately: w10 20 and 21, w3 20 and 21, the same frames, the
same 3 frees and the same idle bytes throughout (m3-max-45172).
Why the cap goes: no run reached it. The most idle bytes in any run were 153 MiB Shared and
176 MiB Private (167 MiB Private in the replay), against the smallest caps of the lab's GPUs
(heap / 8 from each device's vulkaninfo, jobs m3-max-44935 to 44940): 512 MiB Private on the
RX 550 and 0.73 GiB Shared on the 780M; the 2080's are 1.00 and 2.73 GiB, the Iris's 2.90 GiB
each. With no device bounded by it, it was a second rule that did nothing.
Host memory (the process's VK_EXT_memory_budget usage of the system-memory heap, MiB): the
most in the run, then each second of the idle tail after the last row:
GPU arm peak tail 0s 1s 2s 5s 10s
RX 550 rt w10 198 160 160 160 70 70
rt w3 182 86 86 86 86 86
rt w1 176 86 86 86 86 86
old 448 409 409 409 320 320
Iris Xe rt w10 341 267 267 267 178 114
rt w3 341 178 178 114 114 114
rt w1 325 98 98 98 98 98
old 691 691 691 627 448 384
RTX 2080 rt w10 174 101 101 101 101 37
rt w3 174 101 37 37 37 37
rt w1 174 37 37 37 37 37
old 307 163 163 99 99 99
rt peaks at about half of old's and is at its floor within 2 s of going idle at 3 s; old holds
320 and 384 MiB after 10 s on the RX 550 and the Iris, 99 MiB on the 2080. Arms: rt and old
at the probe stack on 84ff56eb79 (the take fix), window only changed: w10 f3801fa006, w3
9092445857, w1 f588d03c9e; the old rows ran the w10 build with --runtime old. On the 2080 the
old arm's process segfaulted at exit after its idle tail (exit 139, a probe build, cause not
examined); its rows and tail are complete. The replay arms: w10 9970821a68, w3 83cbb9d6cf.
The window's unit test and the idle device test follow 3 s (2 s within the window, 4 s past
it, 2 s more for the peak to fall); release_block's doc, the idle gauges' doc and the README
state the window and the 20 ms quiet test, one sentence each.
gpu::tests::device_waits_exist_only_in_the_bounded_wait_module reads every source of the
validation crate as text and fails on a Metal or Vulkan wait spelled outside gpu/wait.rs, comments
included. 48f7079244's module doc for the Managed-texture write count spelled the Metal wait's
selector, so the test failed on lavapipe in matrix cbd4644463 (job m3-max-45191). The doc now says
the same in words.
Verified: git grep for the five spellings over the crate's src and tests finds them only in
gpu/wait.rs and the test itself.
The translator's shaders take a form of their own where each of these is
enabled, and the floor enabled none of them, though Vulkan requires each of
every device the floor admits (spec 55.1):
- multiview (Vulkan 1.1): the translator's multiview forms;
- shaderSubgroupExtendedTypes (Vulkan 1.2): SIMD-group operations on 8-, 16-
and 64-bit values (lower/simd);
- shaderDemoteToHelperInvocation (Vulkan 1.3): a discarded fragment demoted
to a helper (lower/fragment/discard), which the render census finds 102 of
gb's 267 render pipelines and 97 of b2's 259 take where it is enabled;
- shaderTerminateInvocation and shaderZeroInitializeWorkgroupMemory
(Vulkan 1.3).
The planner ruled that features 1.3 already requires are used. No device
drops: every device at the floor's Vulkan 1.3 reports them. The README's
floor table names them. The floor test's at-floor device reports them; the
test refuses a device that lacks any one (cases 31 -> 36) and checks that
device creation and the translator's enable set include them.
Verified: lint (floor tests, golden hashes); harness rows of this commit
against development on the 2080, XTX, Iris, RX 550 and UHD 630.
The planner set the RX 550's (1002:699f) constant_private row a ceiling of 1.20 in
HARNESS_CEILINGS, based on the row's measured median. The matrix's limit is that ceiling times
HARNESS_BUDGET (1.236). The pushed-flag branch for 256x1x1 tiles was tried and dropped under the
planner's time box.
- v1 (probe a29d4d4fde): 0.884 of tiles on the RX 550, but the untaken branch cost 6.7% on the
UHD 630's grid3l (m3-max-45077) and 1.6% on the RX 550's (m3-max-45076).
- v2 (probe 559c61a305), where the branch covers the extent test too: 0.954 of tiles on the RX
550's constant_private (m3-max-45131), under the 5% bar.
The README bullet now says what was measured, not the earlier attribution:
- On the RX 550 the row runs at 0.90 of tiles in 256x1 workgroups, 0.89 through storage-buffer
descriptors, and 0.89 with both (probe 4f8a9df6b5 on 80bd8ca764, m3-max-45027).
- The decode's instruction count does not explain it: the decode's masks as constants gave 1.000
of tiles (m3-max-45076).
- The 64-bit address per read is from the ISA (m3-max-44342).
- The Iris clause is corrected. In an exclusive 7-round run (m3-max-45057) the Iris Xe took
1.027 of the old runtime's GPU time, with 0.999 in 256x1 workgroups and 1.002 through
descriptors. It pays neither cause, and it has no gap (under 1.03).
Verified: scripts/matrix/test_results.py, 29 tests OK, including
test_every_ceiling_is_over_the_budget. README lines are 100 columns or fewer.
A kernel that does not observe its threadgroup partition and is not image-only takes the remap
over the pushed tile on every grid. On a grid one high and one deep, its prologue still decodes
the position in all three dimensions. The harness row constant_private runs past the old runtime
on the RX 550 because of it: 2^20 threads in a line, 64 reads of 16 bytes from a 64 KiB constant
table, and a 4-byte store per thread. The planner ruled out a 1-D fold. In the two recorded streams
such grids are 0.00% and 0.59% of non-observer threads (replay, job m3-max-44422), under the 5%
threshold. So the gap is written where a user reads it.
Evidence:
- Matrix at 61f2799088, RX 550 (1002:699f, RADV Mesa 26.2.6, homelab-gem10-1), harness job
m3-max-44941: matrix time new 2387.1 us over old 1970.0 us (1.212). Re-timed in 3 pairs:
2380.8/2018.3, 2360.1/1998.8, 2465.2/1994.8 (1.180, 1.181, 1.236), median 1.181.
- Same matrix, Iris Xe (8086:a7a0, Mesa 26.2.6, homelab-ms01-1), job m3-max-44934: matrix time
new 2591.8 us over old 2410.7 us (1.075); GPU p50 2655.8 against 2495.8 us (1.064). The matrix
re-timed other rows, not this one.
- Same matrix, RX 7900 XTX (1002:744c), job m3-max-44930: re-timed median 1.036 in host wall
time. GPU p50 is 65.8 us new against 67.5 us old (0.975). The XTX's excess is host-side, not
this kernel's prologue or loads, so it gets no line here.
- Decomposition: probe 4f8a9df6b5 on development 80bd8ca764 (post-pace), RX 550, job
m3-max-44309, 2 rounds. Old 2025.3 us. The rule's tiles 2472.4 us (1.221 of old). Declared 256x1
workgroups with no decode 2217.8 us (1.095 of old, 0.897 of the tiles).
- ISA, jobs m3-max-44342 and m3-max-44347 on 4f8a9df6b5: the tile is a push constant, so the
prologue is the full 3-D decode, 28 instructions against 2 for a declared group. The module is
742 instructions, against 717 declared and 603 old. Each of the 64 reads through the device
address pays a 64-bit v_add + v_addc before its flat_load. The old runtime's buffer_load_dwordx4
takes a 32-bit offset off its descriptor. That second share comes from the ISA, not from timing:
the probe's descriptor arm also emitted software bounds checks and did not recover it.
- UHD 630 (jobs m3-max-44328/44329): declared 256x1 is 0.997 of the tiles for this row.
Docs only. README lines are 100 columns or fewer.
What: every_device_takes_staging_of_its_own_behind_a_held_command_buffer commits the command
buffer that waits on the event before it makes and names the Managed buffer.
Why: on every discrete leg of edfa66f02e (jobs 45072-45074) the held command buffer's own
commit captured the bytes named at the buffer's making, streaming them with nothing held ahead,
so the later commit named nothing and took no staging of its own (0 overflows, 1 expected); the
bytes checks passed.
Tests: legs rerun.
What: Chunk::end records and ends the command buffer in place, and Chunk::ended makes the
copy-in, so a failure gives the chunk up through its one path; the capture takes or makes the
upload before WorkState::stream, which can no longer fail. ManagedOvers::into_after and
capture::into are renamed copies_in_after and copies_in.
Why: clippy's result_large_err and wrong_self_convention lints on 20073b5d43 (check 45026).
Tests: check rerun.
What: the planner's ruling on a full capture ring, replacing the live read.
- A capture that finds the ring full waits for the oldest span's submission. Where the oldest
span is of a copy not yet submitted, every queue's held group goes at once and the commit waits
(on a new condvar the submit thread notifies after each pass) until nothing committed before
can still go. Then, where everything committed is submitted, the capture's own ring-full is
ended as a copy-in and goes in the upload's submission (after the upload's commands and any
copy-ins carried from a failed commit), flushed at once; the commit waits for it to complete
and reuses the ring. The ring is all the staging a capture holds, whatever it names.
- Where a command buffer committed before waits on the host (an unmet host event wait, or an
enqueued, uncommitted command buffer ahead of it), nothing can go: the rest of the capture is
copied into Shared staging blocks of its own from the pool (at most 256 MiB each), which the
committing command buffer holds and gives back as it retires, so the pool's idle rule governs
their release. Every byte is still as of the commit.
- The live read and Metrics::managed_bytes_live are gone, with their README known gap. Metrics
gain capture_streams, capture_overflows and capture_overflow_bytes; Gauges gain capture_bytes
(the ring once made, plus live overflow blocks), also in the replay's per-frame counters.
- Copy-ins are recorded through capture::Chunk: one vkCmdCopyBuffer per run of copies from one
source into one device copy. Copies back owed to textures over the ranges go at the head of the
capture's first copy-in, copies in at the tail of its last (ManagedOvers::captured is split into
backs_before and into_after). Copies read the buffer's mapped contents, which the naming keeps.
- The API signature table is blessed for the new Metrics and Gauges fields.
Why: the planner ruled that a commit's own captures stream and that only a host hold, where
waiting could deadlock, takes one-off staging; no byte may be read after its commit.
Tests: managed.rs's past-the-ring test now names three rings' worth with nothing held and checks
that it streams (two or more streams, no overflow, capture_bytes equal to the ring after the
commit) and that the bytes arrive; the hold test commits behind an unsignalled event with a ring
and a half named and checks one overflow of half a ring, the commit's bytes (a write and a
didModifyRange after the commit are not seen), and the staging given back after retirement.
Texture::image_bytes (test-only) read a texture's image once the upload had run, which carried a
Managed buffer's changed ranges before; the ranges now wait for a commit, so the peek commits a
command buffer first. The over test's image over a Managed buffer failed on the XTX and the 2080
without it (job m3-max-44933, archive of 6a8b901008). The past-the-ring test's buffer was shorter
than its two three-quarter parts (a slice past its end on the same legs); it is a ring and a half.
Verified: the next check and legs.
Development's new_buffer takes the offset to zero from (None for none); the rebase over it left
one call in the old form, which failed to compile (job m3-max-44925).
Verified: the next check job compiles it.
The Gpu field pushed the completion item's command variant past clippy's large-variant bound,
so the copy-ins move to the first segment, ahead of whose commands they go. A capture that
fails before its end leaves the carried copy-ins carried. Retire reads every copy-in field it
gives up (the images were never read, a dead-code error), and the drains are mem::take, as
clippy asks (job m3-max-44896).
Verified: the next check job compiles it.
The loop variable shadowed the list the unwind calls give back, so the build failed (job
m3-max-44888). The past-the-ring test also prints each three-quarter-ring commit's time and the
rate of its copy into the ring.
Verified: the next check job compiles it.
What: the rt backend places a Managed buffer in a Shared block and makes it with
Device::new_managed_buffer (bytes zeroed through a zeroed Shared buffer over the range, nothing
copied), and forwards did_modify_range. constant_managed, refused on rt so far (no CPU copy),
now runs there, through the capture at the commit on a two-copy device.
Why: the planner sizes the Managed capture ring on the harness's own workloads; the harness
compares rt's commit time with the old runtime's on them.
Verified: the check job that compiles it (clippy, harness tests).
What: didModifyRange (and a new Managed buffer's first bytes) only names a range, merged per
buffer; it submits nothing. The next commit of a command buffer with commands copies every range
named since, once, into a 64 MiB host-visible capture ring on the committing thread, and records
the ring-to-device-copy copies into a command buffer of its own (a copy-in) that goes ahead of the
committing command buffer's first segment, after its waits, between barriers. Textures over the
ranges in images of their own take their owed copies back before the copies and their copies in
after them, in the same copy-in. Commits take turns (a turn mutex taken before the work lock) so
command buffers keep the order of their captures while a capture copies without the work lock.
A full ring waits for its oldest span's submission; where the oldest span is of a command buffer
not yet submitted (held, possibly on a host event, or the capture's own), the held groups go and
the rest is copied from the consumer's bytes when the copy runs, counted in
Metrics::managed_bytes_live (a README known gap). Metrics gain managed_bytes_captured,
managed_bytes_live and capture_waits. Managed is one copy when Vulkan's device type is integrated
or CPU (Core::unified_memory, the answer Device::has_unified_memory gives), two otherwise, in
place of the Shared type's DEVICE_LOCAL flag.
Why: the planner's ruling. The old live read at submission let a write made after a commit reach
a command buffer committed before it (gb's Managed traffic); Metal takes the bytes shortly after
the commit, before scheduling, and a write while the command buffer runs does not reach it. The
deviceType rule makes the 780M (whose Shared type is not DEVICE_LOCAL) one copy, as reims reports
hasUnifiedMemory from it.
Also: queue abandonment and commit-time errors give the ring spans of copy-ins never staged back
and name their ranges again; the submit thread's end forgets named ranges and carried copy-ins
(they hold device copies, which hold the core); a texture over a Managed buffer joins its buffer's
entries only after its move home is recorded.
Tests: managed.rs gains the at-commit test (written, named, committed behind an event wait,
written and named again before the event: the kernel reads the commit's bytes on a two-copy
device; a write after naming and before the commit is read on both forms) and the past-the-ring
test (a range 16 MiB past the ring arrives whole, part live; two commits of three quarters of the
ring arrive whole); the changed-ranges test checks that changes submit nothing.
In Metal, each of a render pipeline's color attachments blends by its own
state, and a fragment function may write and atomically update device memory.
The translator asks Feature(IndependentBlend) for the first (it refuses with
Unsupported(IndependentBlending) without it) and Feature(FragmentStoresAndAtomics)
for the second. The floor enabled neither, so the translator, which sees only
what device creation enables, refused them. Vulkan 1.4 requires both of every
graphics device (55.1), Roadmap 2022 lists both, and every lab profile
reports both (RADV, ANV, NVIDIA, lavapipe). The planner ruled them required
floor features.
The README's floor table names them. The floor test's at-floor device reports
them; the test refuses a device that lacks either one, and checks that device
creation and the translator's enable set include both.
Found by the render census under the floor's real enable set (job 45000, on
the draws branch with robustBufferAccess): gb translated 144 of 274 render
pipelines, with 123 refused as IndependentBlending and 1 needing
FragmentStoresAndAtomics (b2: 141 of 266, 118 and 1). With both enabled
(job 45063), gb translates 267 and b2 259, the same counts as under the
profile's whole feature set.
Verified: lint of this commit (floor tests); census 45063 for the counts.
The create_64MiB regression (matrix 61f2799088: next_take 7-27x old on RADV, NVIDIA and the
Iris). Each create in the harness's loop takes a 64 MiB Shared block, which takes an
allocation of its own, and gives it back; the next create takes again straight away. A take
looked only at the kept blocks, and the block-maker thread keeps a given-back block only when it
gets to the queue. While the thread was inside a driver call (a 16 MiB vkAllocateMemory or a
vkFreeMemory, 3-70 ms on the NVIDIA cards), the take found nothing, allocated a fresh 64 MiB
on the guest thread (fresh pages, their first touch in the memset), and the block it missed
left its allocation idle and over the window's peak, to be freed: a free that kept the thread
busy for the next take. Shown by the new test at the parent of this change
(every_device_takes_a_long_block_given_back_again_at_once, draft at 30cc1a0b69): on the RTX
3090 (m3-max-45044) rounds 3-19 each allocated one and freed one; on the RX 550 (45043) round
16 did; lavapipe (45042) none.
- Pool::take, after the kept blocks, takes a block from the give-back queue that the thread
would keep (not spilled) and of the length asked: its allocation stays in use throughout, so
no bookkeeping changes but the reuse count and the window's note.
- The block-maker thread holds the lock from popping a kept block off the queue to pushing it
on the kept blocks (it dropped it in between, with nothing to do for a kept block), so a take
finds the block in one or the other.
- The test: 20 takes of a 64 MiB Shared block, each given a zeroed buffer and given back, each
take straight after the give-back before: only the first allocates, 19 reuse, none is freed.
every_device_bounds_the_pending_upload failed now and then on the Iris (ms01 jobs 44922 and
44970; passed in 44962): "copy 0: 4 allocations live, at most 3 expected". Its count of the
allocations in use was the Blocks gauge less the idle gauges' allocations. The Blocks gauge
rises in allocate() before vkAllocateMemory, and the allocation joins the pool (and the idle
gauge) only once make_allocation returns; and it falls in free_allocation after vkFreeMemory,
where the idle rule took the allocation out of the pool (and the idle gauge) before. So while
the block-maker thread makes or frees an idle allocation, that count is one more than the
allocations with a block in use.
The test now counts the allocations with a block in use where the pool keeps them
(Pool::in_use, test-only), which neither window touches. The bound itself is unchanged.
Whether rt must capture a Managed texture's bytes at replaceRegion (rather than when the GPU copy
is next used) turns on how often a program writes one while a command buffer that used it may
still be running. The report now says.
- The player keeps, from the stream alone (replay/texwrites.rs): the textures and each view's
texture; each encoder's command buffer; the textures each command buffer used (an encoder call
naming the texture or a view of it, or an encoder made with an MTL...Descriptor object, or one
made on such an object, that names one); each texture's latest committed user per queue; and the
completions the stream records, which are only the program's CPU waits (waitUntilCompleted of a
command buffer or a later one of its queue, waitUntilSignaledValue:timeoutMS: reaching a value
one of its queue's command buffers signals). The play itself waits at each commit, so this is the
recording's order, not the play's.
- At each call on a texture that carries bytes (replaceRegion:...), blobs resolved, it asks the
backend whether the texture is Managed (Backend::managed_texture, default None; the rt backend
answers from the texture's descriptor) and counts the write, and where a committed user has no
recorded completion, counts it by the presents since that user's commit (0, 1, 2, 3+) and names
the first eight.
- Report::texture_writes (TextureWrites) carries the counts and the report's texture_writes line
says them, with the writes into textures whose storage the backend does not tell.
REPLAY-STREAM.md section 10 documents the line.
Verified: a replay test (Kept backend) writes a Managed texture used through a view by a committed
command buffer, before and after a present, writes a texture that is not Managed, and writes again
after the CPU waited: 3 writes, 2 with the user not seen complete (one per present bucket), the
first two named; clippy and the plays in the check job.
A replace_region on a Managed texture lands in its named bytes at the call, and the upload
that copies them into the image reads them when the GPU reaches it. On a discrete Mac (Radeon
Pro 5300M, macOS 26.7.1, API validation off) a replace made after the commit is seen by that
command buffer only until it is scheduled; one made after the GPU started it is not (the
consumer's oracle runs 45008/45010; the UHD 630 control saw the replace in every step). So rt
can show a replace that Metal would not, in the window between Metal's scheduling and rt's
upload. The replay streams make no such write: every Managed texture replace in gb (301) and
b2 (111) precedes the texture's first use (replay census 44999/45028). Recorded as a known
gap; nothing built.
Each thread of a 2048x2048 grid, in threadgroups of 16x16, reads its texel of an RGBA16Float
texture and stores it as a float4 at y * 2048 + x: the harness's own texels_out kernel as a timed
workload, 64 MiB stored, the reference the texels themselves (sixteenths, exact in half).
Why: on Intel's Windows driver (101.2145) for the UHD 630 this shape took 2.05 times the old
runtime's time when rt ran it in 16x16 workgroups through its device address (7614 against
3711 us), and 0.98 in the tiles the landed rule gives a kernel that does not observe its
partition and is not image-only. No harness row held it, so nothing in the matrix would catch a
change that put such kernels back in a declared 16x16 workgroup. The kernel reads its grid
position alone, so it takes the tiles; the matrix's 1.03 budget now guards it on every leg.
Verified: see the jobs named in the landing message (clippy and the harness suite, and the row
under both runtimes on the UHD 630 and the RX 550 at this commit).
The default cap where the consumer names none was 512 MiB. Half the cap is what the store is
sure to keep, and the larger of the two recorded sessions filled 15.4 MB (379 pipeline files,
6.25 MB; 282 lowerings, 9.16 MB), so 128 MiB keeps about four times that.
The README quotes the store's measured costs, which do not grow with the number of files: the
scale probe (4229ae3525, whose cache.rs is this one's but for the default cap) at 100,000 and
1,000,000 files of 100 bytes, release build, on btrfs (msi, m3-max-44602) and NTFS (the Windows
host, m3-max-44612 and m3-max-44627).
A new test runs a child process that makes generation 3 young with its last write and exits at
once, while its removal thread has generation 1 to remove; the parent finds generation 1 still
there, and the next open removes it with the state whole and no listing.
Its cache directory helper read pipelines/ at the directory's root, where the generation store
no longer keeps it, so it found no file (lavapipe, job m3-max-44584). It now reads each
generation's pipelines/ directory.
The rt README's cache directory section, its teardown paragraph and the pipeline_cache_dir and
pipeline_cache_cap docs say what the generations keep: half the cap is what the store is sure
to keep (a set used over and over that is larger thrashes), at most the cap on disk plus what
is left of a generation a removal is taking, a file larger than half the cap is not kept,
devices on one directory share one count and should pass one cap. The device tests that read
the directory's files skip the state file and find pipeline files under their generation. The
multi-process stress reads each child's output and requires its one test to have passed, so a
child that matched no test cannot pass silently.
The landed store scanned the whole directory at open and kept every file in a map, so at
100,000 / 1,000,000 entries an open took 128 ms / 1.07 s and 18 / 164 MiB, a write at the
cap 424 us / 16.2 ms (a linear search for the oldest), and an open that evicted 1,000 files
0.49 s / 30.6 s (probe c09cae29ce on 8cfda4b5e1, job m3-max-44067). The consumer passes a
25 GiB cap, one store per host user, several processes at once.
The files now live in two generation directories, g<N> (young) and g<N-1> (old). A lookup
tries young, then old; a hit in old is renamed into young (its mark of use, with no bytes
rewritten and no file time read). A write goes into young. The bytes young holds are counted
in `state` (young's number, its bytes, a checksum), read and written under the file's lock
(flock / LockFileEx through std's File::lock), which each store holds open for its life,
beside an in-process mutex, since threads sharing one open file share its lock. The write
that takes young past half the cap makes the next generation young, in the same locked
state write; a thread of the store's own (at most one, not joined) makes the state durable
and removes every generation below old, so no thread that submits, waits for or completes
work removes files. Bytes are counted before they are written and given back when the write
fails, the write goes into the generation read under the lock, and the generation's own
directory is made only at the move under the lock, so a write into a removed generation is a
miss. Every file is checked before use (the translator's encoding, the pipeline data's
checksum); one that does not check is a miss and is removed. A state file that is missing or
does not check is rebuilt from the generations' names with young counted full; an open looks
for the generation below old (one stat) and finishes a removal a process left.
Gone: the map of every file, the scan and the eviction at open, the hourly time touch and its
stat on every hit, the stale temporary file sweep (a temporary file leaves with its
generation), and the pipelines directory made at device creation.
Metal's useHeap: names a heap the encoder's work may reach. rt had no such call, so the player
skipped and counted each one. ComputeCommandEncoder::use_heap takes the heap's block number (a
HeapRange's block, or the block a placement heap's buffers sit in) and keeps that block in the
command buffer until it retires, exactly as use_resource keeps a buffer's block (keep and the new
keep_block share one list). Metal states no retention for useHeap:, so keeping is the safe
reading. The call declares no access: a kernel that reaches a heap's resources through addresses
outside its slots already orders against every write since the last barrier. A number no handle
names answers Error::NoSuchBlock, as new_buffer's does.
The player's compute encoders now call use_heap with the heap's block, and still skip and count
a useHeap: of a skipped object. REPLAY-STREAM.md's skip list and the rt README say so.
Test: heap::every_device_holds_a_used_heap_until_its_command_buffer_retires takes a Private
block, uses it twice in one encoder (the command buffer holds it once), releases it while the
encoder is open (the command buffer still holds it, and a new use of its number answers
NoSuchBlock), commits, and waits for the block's last holder to go once the command buffer
retires. api_signatures.tsv regenerated (one new method); REFUSALS.md unchanged.
The matrix's lavapipe leg at aaf4d16993 (job m3-max-44768) failed
a_pointer_written_at_a_recorded_address_is_relocated: the test played one stream twice on the old
runtime and asserted the two whole reports equal. Since 2ac0ea6799 the old backend's executed
counters carry its vkCreate*Pipelines and shader-cache nanoseconds
(compute_pipeline_create_nanos 9055654 against 5423492, shader_cache_read_nanos 24416 against
27420 in that run), so two plays never report equal executed counts. REPLAY-STREAM.md section 10
already says executed counts differ between plays and only the stream's counts compare.
The test now compares each report with its executed counts (groups, frames, total, the split's)
and frame ends left out: the stream's counts, checks, IDs, private bytes and the rest still have to
match.
Verified: the test on lavapipe (--cfg m2v_cpu_icd, LP_NUM_THREADS=1) in the job named in the
hand-over.
The planner's ruling (free when quiet), replacing "free whenever the window lets go": a driver may
hold every submission of the process for the whole of a vkFreeMemory, and on the NVIDIA cards we
measured in Thunderbolt enclosures freeing host-visible memory takes about 1.1 ms per MiB (15-17 ms
for one 16 MiB allocation), where an internal NVIDIA card frees 16 MiB in about 0.5 ms (store lane
and planner rows). Under the 10 s window a give-back freed every surplus allocation at once, back
to back, beside the guest's submissions.
What changed:
- The idle rule (which allocations are surplus: the window's peak, the cap, the reserve) is as it
was. It now answers one allocation at a time (Rule::Free), and the block-maker thread frees it
only once no commit or submission has come on any of the device's queues for 20 ms
(QUIET_NANOS), then looks again. CommandBuffer::commit and the submit thread's vkQueueSubmit2
stamp the pool (one atomic fetch_max of host_time, nothing else on those paths).
- The rule runs on the block-maker thread's own time too: it sleeps until the next change, the
end of the quiet time where it has an allocation to free, or the second the window's peak can
fall where it keeps idle allocations. So a program that goes quiet gives its idle allocations
back without a call of its own (before, the rule ran only on a take or give-back).
- A spilled allocation that empties retires: no take lands in it, its bytes are not free bytes,
and it is the rule's next to free, through the same quiet path (it was freed at once).
- Metrics::allocations_freed counts the frees; Metrics::submissions_during_frees counts the
submissions made while the thread was inside a free's vkFreeMemory. The replay's per-frame
counters carry both.
- README: the idle paragraph, and a known gap of memory blocks in the planner's wording.
release_block's doc. api_signatures gains the two fields.
Tests:
- every_device_frees_idle_allocations_as_the_window_s_peak_falls: the three oldest freed one at
a time when the clock passes the window, and the fourth freed five seconds later with no take
or give-back (the timer path); four frees counted.
- every_device_frees_idle_allocations_in_quiet_gaps: command buffers committed every 2 ms while
four idle allocations are surplus; every free begins at least 20 ms after the last commit before
it (checked against the test thread's own commit times, whatever its gaps); the four are freed
once the commits stop. Then a free held open: a submission during it is counted, one after it
is not.
- The spill test exercises the retiring path (it failed while a newly made spilled allocation was
taken for an emptied one: 3090, 2080, RX 550 in m3-max-44872/44873/44874; fixed).
Verified at d7918e27fa (this commit's code on a6520161e8; the tree here is the same diff applied on
development 61f2799088): check m3-max-44879 (clippy all-features, --cfg m2v_gpu, rt under
--cfg m2v_cpu_icd, translator no-feature; rt and harness suites); legs 3090 m3-max-44882,
2080 44883, RX 550 44884, lavapipe 44885: 174/174 each. The old runtime and the translator are
untouched.
A play that hangs (gb's fault at frame 1095, b2's at 312) wrote no report: report.txt got its frame
and end lines only at the play's end, so every hung play left 0 frames in its timing table, and the
cold and warm plays of the frames before each fault could not be read.
- Player::until_frame(F) stops after frame F's present (frames counted from 0 as Report::frames
counts them), completes the work committed so far and reports as at the stream's end;
command-replay's --until-frame F sets it and says `until-frame F`.
- Player::with_frame_lines(out) writes each frame's lines (Report::frame_lines: its frame and end
lines) to out as the frame ends, flushed; command-replay passes its open report.txt and writes
the rest at the end (Report::lines_but_frames). Report::lines keeps every line, the completed
groups' first.
- The rt backend's report gets an `unwritten N` line: the Shared buffers made without bytes that a
compute encoder bound or used and whose command buffer committed before any recorded write,
upload or GPU pass reached their bytes since their making, with the first few named and the
command buffer that read each. It is where a recording that missed the program's writes shows
(b2's uniform ring #58725 had no recorded byte in its life). What reaches a buffer: an m2v.write
into it, into its block over it or into another buffer of the block over it; a blit or render
encoder call naming it or such a buffer (skipped encoders included); the commit of a dispatch
binding it. It counts and stops nothing (new_runtime/unwritten.rs, hooks in the make paths,
write, release, the encoder calls and the commit).
REPLAY-STREAM.md section 10 documents --until-frame, the per-frame lines and the unwritten line.
Verified: replay tests for the frame stop and the per-frame lines (Kept backend) and for the
unwritten count (the tracker alone: block writes, a blit naming, a write before the commit, a
release, a later commit, an alias made later); clippy and the device plays in the check job.
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.
conformance times --runs 8 --write buffer-bind-off-alignment (job m3-max-44858 at a574b72781, an
Apple M3 Max, macOS 27.0.1) writes both legs' figures into the case's recording, so
times::every_case_carries_its_timing holds the new case as it holds the rest. The case is within
the 10x margin over 8 rounds. The run reported its margin unjudged: the instrument's own cost
moved 2.31x during Metal's leg.
Verified: the recording only gains its times; coverage.py --check passes.
Record mode (job m3-max-44847 at 09c51a35ef, an Apple M3 Max, macOS 27.0.1) took the case's two
Metal facts:
- Plain Metal ran the pass: every step answered Ok, and the command buffer is Completed with no
error, over 3 runs folded into one outcome.
- Metal's API validation stopped it at the pass: "Compute Function(vwp_words): the offset into the
buffer src that is bound at Buffer index 0 must be a multiple of 4 but was set to 2.", and the
same for dst at index 1.
docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py): 167 case
modules, 1,282 recordings.
Verified: the recording's facts as listed (read from the file); coverage.py --check passes.
The planner asked for a conformance case built from the bind Metal's API validation refuses, beside
the new runtime's Refusal::BufferOffsetAlignment. One compute pass runs vwp_words (the owned
fixture vector_word_phases) over src and dst bound at byte 2, where its uint * arguments take a
multiple of 4: the uint-2 bind of probes/vector_access_placement.m. Record mode keeps plain
Metal's outcome of the pass and, as the validated fact, the validation's words ("must be a
multiple of 4 but was set to 2"). The case compares the pass's outcome and reads no bytes back:
where plain Metal places each element of such a bind is probes/misaligned_buffer_binds.m's
question and docs/API.md section 10's entry, and this case is about the refusal.
The case's own test holds the recording to both facts. It is listed among the cases authored after
the last whole-set cost run. Its recording follows in the next commit, taken on the M3 Max.
Verified: cargo fmt only; the build and the recording are the next potluck jobs.
The planner ruled that the bind-offset mask becomes a typed refusal. The binder pushed a bound
buffer's address, its gpuAddress plus the offset, rounded down to the alignment the kernel takes
it to have (FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), where Metal's
API validation refuses the bind offset ("must be a multiple of 4 but was set to 2" for a uint *
argument, probe vector_access_placement.m in the conformance crate). Plain Metal runs such a
dispatch at addresses of its own: an M3 Max reaches each element at its address rounded down to
the smaller of its alignment and 4. That is not the rounding the binder did for 8- and 16-byte
arguments.
The dispatch now refuses it with Refusal::BufferOffsetAlignment { index, offset, alignment }
before it records or keeps anything. check_alignment runs after the threadgroup size check and
before a kernel without effects returns, so both direct and indirect dispatches take it.
fill_parameters pushes each address as it is. A set_bytes copy sits at a multiple of 16 in the
ring, which every mask divides, so it is never refused.
Docs:
- docs/API.md: the identity-domain paragraph and the section 10 entry (renamed: "A dispatch that
reaches a buffer bound off its argument's alignment is refused"); no case names its slug.
- RuntimeFact::AddressAlignment's doc and the mechanism comment.
- The rt README paragraph and FieldValue::BufferAddress's doc.
- docs/REFUSALS.md regenerated (44 rt refusals); api_signatures.tsv gains the variant's row.
Tests (device, under --cfg m2v_gpu or m2v_cpu_icd):
- every_device_refuses_a_bound_address_off_its_alignment (was ..._rounds_a_bound_address_down_...):
at alignments 2, 4, 8 and 16, each of 17 binds 1 to 15 bytes past a multiple of 16 that the
alignment does not divide is refused and leaves the buffer unchanged, and the same buffer bound
at 48 runs. Without the check every one of the 17 dispatches returns Ok.
- an_argument_bound_off_its_alignment_is_refused (was ..._runs_at_the_address_rounded_down):
the translated vector_word_phases kernels with one argument off its alignment are refused,
naming the index, offset and alignment, and the command buffer completes with every buffer
unchanged.
13bb9a0a4e plays a Managed buffer in a block as a plain Shared range where
the recording device kept one copy, written for the old zeroed flag
(false). A placement zeroes nothing, as before: None.
every_device_fills_a_zeroed_private_buffer_before_a_copy_into_it_in_the_next_command_buffer
failed at its last check on every device (3090 m3-max-44735, 2080 44736,
RX 550 44737, lavapipe 44738): it made its texture with no index, and a
texture shaders read or write takes one ("a texture shaders read or write
takes an index, and none was given"). Every ordering check before it had
passed on all four: the bytes zeroed for each zero_from, and every byte of
the span for the four cases of copies into [0, zero_from) and into the
zeroed tail in the command buffer after the buffer's making. The test now
grants one texture index and places the texture at it, and waits for the
gauges to fall after teardown, as the other tests that make textures do.