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.
development brought three new_buffer callers written for the old zeroed
flag: the replay's staging copy (nothing zeroed: it writes the range
itself, so None), the upload bound test's second fill and the
buffer-to-buffer blit test (zeroed whole, as before: Some(0)). The mapping
is the one the zero_from change used everywhere: true is Some(0), false
is None.
Documented Metal promises zero only for a buffer from
newBufferWithLength:options:. It is silent on heap memory and on the
bytes a placed texture sees. rt zeroed more: every new allocation whole
(Shared by host writes through the mapping, Private by a GPU fill in a
submission of its own, waited for), every block given back on the
block-maker thread, and then the buffer's range again at new_buffer.
Measured raw call against fill, 16 MiB, at e34c0d0ed7:
- UHD 630: the Private fill is 9.8-11 ms against 0.08-0.10 ms for the
call. Iris Xe: 2.8-4.3 ms against 0.01-0.11 ms.
- NVIDIA: the call dominates (Shared 2.9-4.0 ms, Private 0.55 ms).
Both whole fills are gone. A taken block's bytes are undefined, new or
taken again. Device::new_buffer takes zero_from: Option<u64> in place
of zeroed: bool. Some(z) zeroes the buffer's bytes [z, length), through
the mapping for Shared, by the upload's fill for Private. None zeroes
nothing (heap buffers, or a range the consumer writes itself), and an
offset at or past the length zeroes nothing. reims's Managed device
copy passes zero_from and copies [0, zero_from) itself, so the head is
no longer filled and then overwritten. Metrics::bytes_zeroed counts the
bytes, a Managed device copy's zeroed tail among them.
With no fill of its own, the filler keeps only the zero source: its
command pool, command buffer and fence are gone, and make_allocation
reads the buffer requirements from the device instead of making and
binding a buffer.
Tests:
- A zeroed buffer zeroes exactly [zero_from, length), counted as the
buffer's bytes. Shared and Private, offsets of 0, 3, 5, 12, 4000, and
one past the length.
- A kept block taken again holds its bytes as written. A Private one
the GPU wrote holds the GPU's bytes, and reads zero only in a buffer
zeroed over a range of it.
- A zeroed Private buffer's fill lands before a copy into it encoded in
the same command buffer, for reims. The upload is the first command
buffer of the next submission and ends with an ALL_COMMANDS/
MEMORY_WRITE barrier. Cases: copies into [0, zero_from) and into the
zeroed tail, both holding.
- A texture placed in a block zeroes nothing.
- The harness gains create_private_16MiB: a Private buffer's creation
plus one command buffer that reads its ends, through to completion,
checked zero. That time holds the fill, wherever the runtime does it.
The replay's per-frame counters gain bytes_zeroed. README, REFUSALS and
api_signatures are regenerated or updated.
The upload bound test came to development (5b52afb17b, eb46c7fa2c) written
for the old pool: a Private block of 64 MiB, the upload's bound. Under the
range pool a Private block is 16 MiB, so the released block no longer
filled the bound alone and "a fill past the bound" kept 16 MiB and more
pending: upload.rs:265 on the 3090 (m3-max-44811) and the 2080 (44813),
at b261e44947. The released and filling blocks now ask for UPLOAD_BYTES,
the bound's length, which the test's comment already names; a take that
long makes an allocation of its own.
On lavapipe (44809) and the RX 550 (44814) the test timed out earlier,
waiting for the released textures' allocations to come back to the count
before them. A texture made while earlier ones are still being freed can
take a second 16 MiB texture block (64 textures of 256 KiB fill one); once
empty it goes back to the pool, which keeps the allocation idle for its
window, so the raw count of allocations stays one higher. The test now
counts the allocations in use (all of them less the idle ones, from the
idle-bytes gauges) for that wait and for the copies' ceiling, waits for the
textures and the allocations apart so a timeout names which, and prints
the gauges after the released textures.
every_device_frees_idle_allocations_as_the_window_s_peak_falls read the blocks
gauge as soon as the third hook had run and the Shared idle gauge had fallen.
The block-maker thread settles the idle gauge under the pool's lock, then, for
each allocation the idle rule takes out, runs the kept block's hook and only
then frees the allocation and lowers the blocks gauge. So the read raced the
third vkFreeMemory and saw one allocation too many (5 for 4) on the 3090
(m3-max-44731), the 2080 (44732) and lavapipe (44734); a 16 MiB system-memory
free on NVIDIA takes about 17-20 ms, so those legs read inside it every time,
while the RX 550's cheap frees passed (44733). Every assertion before it (the
three oldest unmapped in order, on the block-maker thread, and the idle gauge)
passed on those legs: the rule was right, the test's read order was not.
The test now waits for the blocks gauge to reach the zero source, the reserve,
the fourth and the Private allocation, then checks the three unmaps, their
order and the idle gauge, all final by then. A rule that made or kept an extra
allocation still fails it (the wait times out), and one that freed the wrong
allocations fails the order check.
The pool's returned blocks were a stack: blocks given back while the
block-maker thread was busy were taken newest first, so the emptied
stamps that order the idle rule's frees depended on when the thread
woke. On every device leg (3090, 2080, RX 550, lavapipe at b3dec72137)
every_device_frees_idle_allocations_as_the_window_s_peak_falls freed
block 5 first where it gave back 3, 4, 5, 6 in that order. A queue makes
the allocation emptied first the first freed, whatever the timing.
The texture-over-buffer test took a Shared block of 128 KiB and placed
a Managed buffer at 128 KiB in it: before 16 MiB allocations a small
take was a 16 MiB block, now it is the length asked, rounded to 64 KiB.
It takes the 192 KiB it uses.
Verified: the two tests' failures on lavapipe (44659) and the RX 550
(44663) name these causes; the legs run again on this commit.
A raw Private vkAllocateMemory on the UHD Graphics 630 (Intel's Windows driver 101.2145) took
0.08 to 0.20 ms at 16, 32 and 64 MiB, three trials each, and round trips on the queue during it
took as long as before it (0.32 to 0.48 ms against 0.36). The 0.4 to 0.75 ms per MiB that rt's
fresh Private take held submissions for is the making's zero fill, the memory's first use.
Verified: potluck job m3-max-44513 (the raw probe at d4a739dd7b, cross-built in m3-max-44352);
cargo fmt.
- The harness's rt heap takes a block of MemoryClass::block_len (16 MiB) when no block it holds
fits a buffer, the way a guest's allocator takes chunks of that length. Under the range pool, a
take of the span alone carved 64 KiB, which no consumer does.
- create_state's first now includes the creation of the 16-byte buffer its dispatch writes, so a
take of memory and the pipeline creation it may hold beside it are timed together, in both
runtimes.
- Each creation row prints the runtime's allocations on the caller's thread during the first
creation (count, time, the longest since the device was made), with matrix lines, where the
runtime counts them (rt: Metrics::consumer_allocations).
- rt counts each class's first allocation in Device::new with the block-maker thread's, as
allocations made ahead of need, so the consumer's figures start at zero.
Verified: cargo fmt; api_signatures --check passes. Clippy and the rows follow as potluck jobs.
Clippy (all features, and --cfg m2v_gpu) refused be6c48e94a: a drain into a new Vec, two
extend-from-drain moves, the unused Pool::allocations test helper, and a manual is_multiple_of in
the memory tests. Behaviour is unchanged.
Verified: cargo fmt; clippy follows as a potluck job.
The pool handed a take of up to a block length a whole pooled block and kept one ready block per
class, which the block-maker thread made again as soon as a take used it. A 16-byte Shared buffer
took the ready block, and the 16 MiB allocation that followed held the consumer's next pipeline
creation for its whole length on NVIDIA's driver.
Now each block is a range of one of its class's allocations, with its own VkBuffer:
- A take is a kept block of its length, else the first free range that fits, else the start of an
allocation made in the call: 16 MiB, or the block's own length where that is longer. Lengths
round up to 64 KiB (or bufferImageGranularity); a block starts at its length rounded up to a
power of two, up to 2 MiB.
- Device::new makes one 16 MiB allocation per class. After that, the block-maker thread makes
another only while the class's free bytes are under 8 MiB. A take never waits on it for memory.
- A take that no free range fits, while the class keeps blocks of other lengths, allocates at once.
It also asks the block-maker thread to give those blocks' bytes back, after the consumer's hook.
Only when its own allocation fails does it wait for those bytes, then look for a free range once
more.
- An allocation holding no live block is idle. A class keeps its idle allocations while their
bytes plus those of its allocations in use stay at or under the most bytes it had in use over the
last 10 seconds, and within an eighth of its memory type's heap. Past that it frees the oldest,
except the reserve that keeps 8 MiB free. The rule runs at takes and give-backs on an injectable
clock; there is no timer.
- Removed: the dedicated path, fits-and-fills-half, the 256 and 128 MiB idle bounds and the 64 MiB
Private block.
- Metrics: blocks_reused replaces dedicated_blocks_reused. New metrics: block_bytes_made, and the
vkAllocateMemory time on the consumer's threads (count, total, longest) apart from the
block-maker thread's.
Tests:
- Unit: rounding, base alignment, and the window and surplus rule.
- On device:
- the first allocations, and the trigger at 8 MiB free;
- kept blocks taken again with their number, address and mapping;
- an allocation beside kept blocks of other lengths, with their bytes given back;
- the failed-allocation path, at an answered maxMemoryAllocationCount;
- idle allocations following the window down, the reserve kept;
- a seeded 300-step stress of mixed takes and releases across both classes, each step under a
one-minute timeout.
- Tests that took a block of 1 byte and used more of it now take what they use.
- The replay's rt counters read the new metrics.
Verified: cargo fmt; api_signatures blessed; REFUSALS.md regenerated. Clippy, the suites and the
device legs follow as potluck jobs.
create() made its first buffer of the row's length untimed, so a runtime's
first take of memory for that length, which may allocate where later takes
reuse, was hidden in the steady times. The first creation and the second, the
first after the first buffer's release, are now timed and reported apart for
both runtimes: the row's line says 'first take X us, the next Y us', and the
matrix gets harness-<runtime>/<row>/first_take and next_take. Both are checked
zero at every 4th byte as before.
Verified: built by job (pending).
How a Managed buffer behaves depends on the recording device's hasUnifiedMemory: one copy where
it is true (a CPU write needs no didModifyRange), a GPU copy made at the buffer's making and
changed only by didModifyRange where it is false. The stream did not say which, and the rt backend
always made the runtime's Managed buffer: gb, recorded on a discrete GPU, wrote its no-copy
Managed buffers (#368205, #368202, #368214) once before first use with no didModifyRange, so their
GPU copies never got the bytes; b2, recorded with unified memory, relies on such writes legitimately.
The player now takes the form from the stream's new m2v.deviceIdentity record (it plays as nothing
and tells the backend hasUnifiedMemory through Backend::recorded_unified_memory), or for a stream
without one from command-replay's --managed one-copy|two-copy. One copy: every Managed buffer plays
as a Shared one. Two copies: the runtime's Managed buffer, its GPU copy from the bytes it was made
with: a copied buffer's, or the new create-time bytes a no-copy one's making now carries
(newBufferWithBytesNoCopy's first argument, a no-copy descriptor's contents). A stream with no
identity record gives none, so a no-copy buffer's GPU copy takes the writes recorded before its
first use (the commit of a command buffer whose encoder names it). With neither the record nor the
setting a Managed buffer stops the play with an error saying so. The report's managed line names
the form and its source, counts the Managed buffers and the no-copy ones with contents from first
use, not from create, and notes a two-copy recording played on a unified-memory device.
REPLAY-STREAM.md documents the identity record, the create-time bytes and the player's rule.
Verified: a replay test plays an identity record as nothing and sees the backend told
hasUnifiedMemory; the rt paths need a device play (gb on the 3090 next).
So the leg output shows the device-copy form ran where the Shared memory type
is not device-local, rather than leaving it expected (main's ask after the
b2b legs).
Verified: the legs print it.
Rebasing the render encoder over 3201e09737 put both sides' Refusal
variants after HeapTexturePlace; the resolution kept both but dropped the
closing "}," of BufferCopyOverlap and the ")," of its Display arm, which the
two sides shared outside the conflict. The file did not parse
(signatures.py --check fell back to the translator's Limit). REFUSALS.md is
regenerated from the repaired file; signatures.py --check passes.
Verified: signatures.py --check rc=0 and refusal_surface.py locally; the
lint job compiles it.
Lint m3-max-44560 at 619f22dc36 failed to build: the attachment descriptors
derived Debug over Texture, which has none; the stencil format check compared
the translator's ImageAspectFlags with ash's; the profile's limits are a
method; the action-mapping test printed ash enums, which carry no Debug here.
The color attachment descriptor's Default is now derived (its fields' defaults
are Metal's), the view lookup copies the kept view out before the push, and
the api_signatures table is re-blessed for the dropped derives.
Verified: the rerun lint is the check.
CommandBuffer::render_command_encoder(&RenderPassDescriptor) is
renderCommandEncoderWithDescriptor:. It begins one vkCmdBeginRendering (dynamic
rendering, in the floor: floor.rs requires vulkan13.dynamicRendering) into the
pass's attachments, and end_encoding ends it with vkCmdEndRendering. Load and
store actions map one to one (Load/Clear/DontCare, Store/DontCare). A clear
color is a float in a float, normalized or sRGB channel (the device converts
it), and an integer channel's is truncated toward zero and saturated, NaN 0,
as Metal's; rotated formats and A8Unorm held in R8_UNORM go through the
format's rotation; a clear stencil keeps its low 8 bits. The render area is the
smallest attachment's level, cut to renderTargetWidth/Height where set.
Each attachment is one level and slice of a 2D texture, 2D array, cube or cube
array of one sample: the texture keeps an identity-swizzled image view of that
level and layer, made at the first pass and freed with the texture through the
reaper (new gauge attachment_views). A pass orders itself as a blit copy does,
two barriers: the first after every earlier command, moving shader-read-only
homes to the attachment layout (general and attachment homes render in place)
and paying an owed barrier; the second after the rendering, moving them home
and making the writes visible to every later command.
Refused as Metal's validation stops them: Refusal::AttachmentUsage,
AttachmentPlace, AttachmentFormat; past maxColorAttachments,
Limit::ColorAttachments. Not built, Gap::RenderPass naming RenderPassKind: a
depth attachment, more than one sample, a resolve, a 1D or 3D attachment, the
Unknown and CustomSampleDepthStore store actions, a clear of a format only a
shader clears, a pass with no attachment. The replay streams' passes (pass
census over gb and b2, counts only): one or two color attachments plus a
stencil in 11,187 of them, every attachment a level of a 2D texture of one
sample, no depth, no resolve, loads Load/Clear/DontCare, stores Store/DontCare.
Tests: tests::pass's host tests pin the action mapping and the clear values;
on_device clears a mip level of a shader-read texture (moved and back), an
integer texture and a stencil, loads and keeps, cuts the area, clears one
slice of a 2D array, and counts one pass alone as one submission, three
barriers, one pass and no bytes copied; each view is made once and freed with
its texture; refusals leave the command buffer open. README render encoder
section and known gaps; REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
A kernel indexes the heap arrays with the resource ID's index as given, with no
clamp, so an index past an array's length (a Texture-class index of 4,096 or
more through the 4,096-element storage-image array, for one) reads a descriptor
from past the array: undefined in Vulkan, as Metal leaves an ID naming no live
resource of the access undefined, and it can fault as a bad address does. The
planner ruled it a README gap in the bad-address class, with no clamp.
The block-maker thread's zero fills of the blocks it makes and is given back
are submissions too, and come when they come: on llvmpipe one came inside the
fill-at-the-bound step (check m3-max-44699: 15 submissions against 14). The
upload's pending bytes say what the step asks: the released block still counts
at the bound, and past it the send starts the count again.
The test released a Private block of 64 MiB, exactly UPLOAD_BYTES, after a zero fill, and expected
the next fill to send the upload. Upload::full sends only past the bound, and a zero fill stages
nothing, so the block alone keeps the upload pending: the test passed only where the 4 MiB texture
phase before it left released bytes in the upload. Readout (probe 9ada86cad0 on development
0c9a4ad558, the test alone): on the RX 550 the upload held 125829120 bytes after the release and
the block came back (m3-max-44685); on the Iris Xe it held exactly 67108864, no submission came,
and the block never came back in 40 s (m3-max-44686), the timeout the Iris legs saw on development
(m3-max-44629, 44561, 44577). Under B's texture blocks the leftover changes, which fits item-a's RX
550 timeout inside the suite.
The part now sends the upload first (a read of one texel), checks that the block alone is counted
at exactly its length and that a fill at the bound submits nothing and keeps the block, then
releases a small texture after a copy to take the upload past the bound: the next fill submits it
and the block comes back. The product is unchanged: the bound is at most UPLOAD_BYTES.
The shape rule (730c43e7d0) bumped SEMANTICS_VERSION to 2171 and ARTIFACT_FORMAT_VERSION to 535, so
every authored case's compiled artifact hash moved. Re-blessed on development 7fd80ec2b4 by the
census job on the M3 (m3-max-44753, census-exit=0). No case changed status: 2,369 rows before and
after, every row's status kinds equal; only artifact hashes and some refusal reasons' text differ.
The golden hash tables, engine inventory and air_input printouts re-blessed in m3-max-44752 with an
empty patch (no change).
Device::minimum_linear_texture_alignment answered the smallest power of two from 16 at which the
device lays every width's linear rows at the row rounded up to it, and 16 where none held. ANV
(Mesa 26.2.6) on the Iris Xe of RPL-P lays each linear row at the row itself, with the image's
memory aligned to the texel. Probe m3-max-44665 (never lands) asked R8Unorm, RGBA8Unorm, R32Float,
RGBA16Float and RGBA32Float at 15 widths from 1 to 1,920 texels under read, read+render and
read+write: every pitch was the row and every memory alignment the texel's bytes. So no power of
two from 16 held for texels under 16 bytes. The answer fell back to 16, and a texture over a
Shared buffer at a pitch the guest rounded to 16 was the counted copy wherever its row was not a
multiple of 16. That is the Iris failure of every_device_holds_a_texture_over_a_buffer_in_place at
width 1 (matrix leg m3-max-44561 at e886ee4c74).
The candidates now start at the format's texel bytes, rounded up to a power of two
(linear_rounding). ANV answers the texel (4 for RGBA8Unorm, 1 for R8Unorm). A guest that rounds
its pitch to the answer gets the device's own layout, and its texture is the linear image on the
buffer's memory. Devices that pad rows to 16 or more answer as before: RADV on the RX 550 still
answers 256 for 1- to 4-byte texels and 512 and 1,024 for 8- and 16-byte ones, in the same probe
(m3-max-44666). Metal on the M3 answers 16 for every format; a smaller answer is the device's, as
RADV's larger one is.
The device test asked an RGBA8Unorm texture at (row + 1) rounded up to the answer. That is the
device's pitch only where the answer is 32 or more, so it now asks the row rounded up to the
answer, which has rows longer than their texels on a device that pads. The test's range check
takes each format's texel bytes as its floor. The docs said a pitch that is any multiple of the
answer is in place; it is the row rounded up to the answer.
Verified: cargo fmt. the_linear_row_rounding_starts_at_the_texel (rt tests::texture, no device)
fails under the old floor of 16 for rows laid at the row itself, and pins RADV's padded answers
and a floored layout's none.
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.
The planner asked for the declared-at-tile form's first-dispatch wait in the consumer's terms
before it lands. An image-only kernel's first dispatch over a grid more than one deep, at a tile no
state of its content has run, makes that tile's VkPipeline on the calling thread. The thread waits
for it (Metrics::first_use_waits), and the pipeline comes from its file in the cache directory
where there is one.
The count comes from replay's job m3-max-44702, over both recorded streams whole: image-only
non-observer dispatches with threads z > 1, by (spec, grid_tile) pair.
- 49 pairs of tile depth 64 or less in each stream. Every pair's first dispatch is in one frame:
224 of one stream and 312 of the other.
- One more pair in each, of tile 1x1x256, runs in the remap's tiles where the device's
maxComputeWorkGroupSize is 64 deep, and makes a 50th pipeline elsewhere.
Metrics::first_use_waits's doc names the tile among the workgroup sizes a wait is for.
Verified: docs only; the counts are the job's output.
A known gap the planner asked for at landing: a kernel that does not observe its threadgroup
partition and is not image-only runs a grid more than one deep in the tiles its regions carry.
- RX 550 (RADV, Mesa 26.2.6): grid3_fill, one 4-byte store through a device address per thread,
took 2.6, 9.4 and 30.2 µs over 4x16x312, 24x24x252 and 256x256x8 grids in tiles. On a pipeline
that took the tile as a specialization constant (the deleted fold) it took 2.2, 8.6 and 25.0 µs.
Job m3-max-44507, probe a636c4175a, 6 rounds; every round within 0.4 µs.
- UHD 630 (Intel's Windows driver, 101.2145), 24x24x252: the tiles took 1.26 and 1.59 times the
old runtime's time by median: 93.6 vs 74.0 µs (m3-max-44604, 8 rounds) and 79.7 vs 50.0 µs
(m3-max-44506, 10 rounds). Within one job, one form's rounds ranged up to 2.8 times apart; the
modes differ between jobs.
- The old runtime's form in this runtime took 0.97 of the tiles' time in 44604, with its fastest
round 72.6 against old's 69.4 µs. That form is the guest's 8x8x4 threadgroup as the workgroup,
with the buffer through a pushed storage-buffer descriptor (probe arm f8x8x4+d).
- So the old runtime's form is not an untried one that wins here: neither the workgroup shape
nor the descriptor accounts for the ratio.
Verified: the numbers are the jobs' logs above. Docs only.
The planner's ruling makes the rule two lines. An image-only kernel that does not observe its
threadgroup partition is declared: 16x16x1 on a grid one deep, the grid's tile (grid_tile) on a
deeper one, at MultiRegion 0 with the extent test. Every other such kernel runs today's remap:
256-lane workgroups, each one tile the region carries. The fold no longer serves buffer-touching
kernels. Image-only kernels used it only where the grid's tile is past the device's
maxComputeWorkGroupSize, and that class is too small to keep a form for, so those dispatches take
the remap too.
The census (replay's job m3-max-44582, both recorded streams): image-only non-observer
dispatches whose tile is past a depth of 64 (NVIDIA's, the floor's limit) are 6 dispatches,
1,760 threads in each stream, one (spec, tile) pair of tile 1x1x256. That is 0.0004% of the
image-only non-observer threads in one stream and 0.0033% in the other. No tile is past a side of
1,024.
Deleted: SpecKey::FoldedTile and the select that took it in place of the region's tile
(lower::dispatch), its binder entry, codec tag, signature row and API guide sentence; rt's
Variant::fold, Constant::FoldedTile, Choice::fold and Last::fold. The cache versions stay at this
branch's single bump (SEMANTICS_VERSION 2171, ARTIFACT_FORMAT_VERSION 535, now for
KernelFacts::image_only and the edge test under MultiRegion 0 alone). An image-only kernel's
pipeline per tile stays: its workgroup is the tile, so a deeper grid's first dispatch at a tile
makes it, and waits once, as the square device test's two-deep dispatch checks.
Verified: cargo fmt; docs/REFUSALS.md regenerated (unchanged). The dispatch-choice tests pin a
tiling kernel's grids of every depth in the remap's tiles, and a 1,024-deep column in them past
a depth of 64. The translator's engine test runs the edge kernel at MultiRegion 0 in 16x16x1
workgroups and at the grid's tile.
A kernel that does not observe its threadgroup partition and is image-only (it reads an image and
does no addrspace(1) load, store or atomic) ran a grid one deep in declared 16x16x1 workgroups but a
deeper grid in folded tiles, workgroups of 256 lanes that decode the tile from a specialization
constant. It now runs a deeper grid at MultiRegion 0 in declared workgroups of the grid's tile
(grid_tile), the region carrying them and flagged where they do not divide the grid, so the
extent test returns the invocations past it. One VkPipeline per tile, made at the kernel's first
dispatch at that tile, as the folded one was. A tile past the device's maxComputeWorkGroupSize
(a column 1,024 deep tiles 1x1x256, past a depth of 64) still runs folded. Buffer-touching
kernels keep the folded tiles. Launched threads are unchanged: the workgroup is the rule's tile.
encoder::choose takes the device's maxComputeWorkGroupSize to hold the tile to it.
Why: the planner's 3-D row, declared at the tile against folded at the tile, on an image-only
kernel over 3-D grids (probe a636c4175a, never lands; rows 4x16x312, 24x24x252, 256x256x8).
Declared beats folded by more than 3% on the UHD 630 and loses nowhere by more than 3%:
declared at the tile over folded at the tile, each the median over rounds of the arm's GPU p50
against the rule's from the same job, one build per GPU at a636c4175a:
rows UHD 630 RX 550 RX 7900 XTX RTX 2080 RTX 3090
4x16x312 0.966 0.946 1.000 0.989 1.000
24x24x252 0.746 0.992 0.965 1.000 1.000
256x256x8 0.997 1.000 0.968 0.993 1.000
(m3-max-44506, 10 rounds; 44507, 44508, 44510, 6 rounds; XTX 44524, 12 rounds).
Verified: cargo fmt. The dispatch-choice tests (tests/choice.rs) pin an image-only kernel's
deeper grids at their tile, a tiling kernel's folded, and a column 1,024 deep folded past a depth of
64; the translator's engine test runs the edge kernel at the grid's tile at MultiRegion 0 over
ragged and whole 3-D grids; the square device test's two-deep dispatch now runs this form.
The old runtime's render descriptor key hashes SEMANTICS_VERSION, which this branch moved to 2171
for KernelFacts::image_only and SpecKey::FoldedTile, so the pinned key of the test descriptor
moves with it. The old runtime's cache entries under the earlier version are misses, as every
semantics bump makes them.
Verified: the_old_render_descriptor_key_keeps_its_value failed at fe31e5b618 (check job
m3-max-44493) with exactly this value on the left; the rest of that job was green (clippy
workspace, m2v_gpu and no-feature; rustdoc; rt lib 62/62; translator lib 3673/3674; signatures).
Both recordings' guest-RAM copies (gb 106 before frame 1095, b2 14 before frame 312) land in
Private buffers, and the rt backend skipped them, so the bytes and addresses they carry never
reached the GPU. A buffer-to-buffer copy now plays as rt's copy_from_buffer_to_buffer. A copy from
the guest's RAM, the recording's plumbing, plays as its pieces' bytes in a Shared staging place of
the backend's own, then a buffer copy into the target in the same blit encoder, so the GPU's order
holds. A buffer copy takes whole 4-byte words at 4-byte offsets: a piece's edge bytes up to whole
words come from the target's mapping where it has one; a piece with such edges into a buffer
with none is skipped and counted. The staging place is given back at the command buffer's commit
and is free once it completes, so the staging stays bounded by the work in flight
(staged_guest_ram_bytes counts it). The player times these copies in a column of its own
(`upload`), the recording's share and not the runtime's.
Both halves the planner asked for, in the fault gap's bullet:
- The hang ends at the device's next submission on any queue: that vkQueueSubmit returns
VK_ERROR_DEVICE_LOST (measured on the 2080 and 3090 for the same queue, the family's second
queue and another family; m3-max-44654, 44655), the runtime takes a failed submission as a
loss, and the completion thread's wait (any of the progress and wake semaphores) returns once
the wake semaphore is signalled from the host after the fault (same jobs). So with a submission
every frame it lasts about a frame; with none it lasts indefinitely.
- The old runtime took the faulting accesses without a fault (no raw addresses in its kernels);
under the new runtime a bad address ends the GPU's work for every guest process on NVIDIA and
RADV, the consequence of one device and direct addresses that the owner accepted.
The bullet reflowed to 100 columns.
The planner ruled the NVIDIA fault gap a known gap (ladder rung 3: repro, upstream report, README).
Measured with an opt-in repro: one compute dispatch storing through a buffer device address
nothing maps, then bounded probes (C program fault-wait.c, staged with the upstream draft):
- NVIDIA 620.70.06, RTX 3090 (m3-max-44640, 44655: Xid 109) and RTX 2080 (44643, 44654: Xid 13
MMU Fault): the semaphore never signals; 1 s waits return VK_TIMEOUT and the counter read
succeeds with the old value; an unbounded vkWaitSemaphores had not returned after 60 s. Every
later vkQueueSubmit of that device (same queue, the family's second queue, another family)
and vkDeviceWaitIdle return VK_ERROR_DEVICE_LOST; a second VkDevice runs. A wait for either
the faulted semaphore or a second one returns once the host signals the second, as the
completion thread's wake does, so a later submission's loss ends the hang.
- RADV Mesa 26.2.6, 780M Phoenix and RX 7900 XTX (44635, 44643): GPUVM fault and ring reset; the
semaphore signals after 2.0-2.1 s, later submits return VK_ERROR_DEVICE_LOST, a second device
runs.
- Intel Windows 1.3.215, UHD 630 (44620, 44642): the counter reads UINT64_MAX at once, the next
submit returns VK_ERROR_DEVICE_LOST, a second device runs.
- ANV Mesa 26.2.6, Iris Xe RPL-P (44641): no fault; the store completes.
- Through the harness (a described workload: a store through a pointer to 0x10000, and a store
64 TiB past a 16-byte buffer): old completed both without a fault or an error on all six GPUs;
new refuses the pointer kernel (the translator's IdentityDomains) and completed the other
without a fault.
The gb play's hang (replay, frame 1095) was this: its #382399 was submitted and its kernel hit
Xid 13 on the 3090 (readout m3-max-44566).
The replay's rt backend skips buffer-to-buffer copies and the guest-RAM
copies that need one, so their destinations are never written on rt: the lead
suspect for gb's hang and b2's device loss on the 780M. This builds the copy.
One vkCmdCopyBuffer region between the bytes shaders reach (a Managed buffer's
device copy where the device keeps one), between a fill's two barriers: the
first after every earlier command (paying an owed barrier, hazard sets start
again), the second making the write visible to every later command; a copy
into a Shared buffer marks the segment so its end reaches the host. The
command buffer keeps both buffers until it retires; textures over either
device copy are settled as the other copies settle them. A size of 0 records
nothing.
Refused: another device's buffer (OtherDevice); a range past either buffer's
end (new Refusal::BufferCopyRange, Metal's validation); an offset or size not a
multiple of 4 (new Refusal::BufferCopyUnaligned, Metal's documented macOS
rule); a source and destination sharing bytes, one buffer's overlapping ranges
or two buffers overlapping in one block (new Refusal::BufferCopyOverlap:
vkCmdCopyBuffer forbids it, VUID-vkCmdCopyBuffer-pRegions-00117, and the
runtime does not emulate it).
Tests: a host test pins the checks (offsets in the device buffer, adjacent
buffers of one block, size 0 anywhere, each refusal); on_device copies between
two buffers of one block and within one buffer, the bytes checked and
everything around kept, one copy alone one submission, three barriers, one
pass and no bytes copied; a copy into a Managed buffer lands in the bytes
shaders reach, brought to the host by a synchronize. README blit section;
REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.