9b60da4bee03514df7f4ef5a1aefa8f9ecd28bca
1258
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9b60da4bee |
host_ram: import a used RAM's chunks ahead, on a thread of the device's
What: Device::use_host_ram now starts a thread ("m2v-host-ram", through exit_guard::spawn)
that imports the RAM's 64 MiB chunks one after another, ahead of the objects over them. It
goes on from the chunk past the one an object last took, then from the RAM's start. It
skips a chunk whose lock is held (an object is importing it) and one it failed to import
(left to the first object over it, as before). It stops once every chunk is imported, the
use ends, the device goes or is lost, or the process exits (each import inside an
exit_guard section). It holds the device and the RAM weakly between chunks. An object over
a chunk the thread has not reached imports it on its own thread, as before. One over the
chunk being imported waits for that one import. New counter:
WorkCounts::host_ram_chunks_imported_ahead.
Why: a consumer makes 2 MiB heaps over consecutive fresh guest RAM (memfd). Each 32nd heap
was the first object over a chunk. Its making waited for the chunk's import, which faults
in and pins 64 MiB of fresh pages. That took ~7.5 ms exclusive on the RTX 5080 laptop, and
0.4-4.0 s in a shared boot with compaction (compact_stall +10,889). Keeping chunks imported
for the RAM's life already held at the start of this branch (a chunk stays in its slot
while the use lasts). Measured here: a heap made again after every heap was dropped
imported 0 chunks.
The trade-off: the whole RAM is resident and pinned from soon after use_host_ram, not only
the chunks objects touch. 16 GiB of fresh THP memfd RAM took 3.47 s on the thread, with
compact_stall 1152, compact_fail 56, pgmigrate_success 935291 and allocstall_normal 54,
all off the making threads. No kernel, boot or module parameter is needed. Recorded in
docs/HOWTO.md ("One run inside one chunk").
Vulkan rules relied on (checked against the 1.4.366 spec): the import itself is
Device::import_chunk, unchanged, under VUID-VkImportMemoryHostPointerInfoEXT-pHostPointer-01749
"pHostPointer must be a pointer aligned to an integer multiple of
VkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment",
VUID-VkImportMemoryHostPointerInfoEXT-handleType-01750 "pHostPointer must be a pointer to
allocationSize number of bytes of host memory", VUID-VkMemoryAllocateInfo-allocationSize-01745
"allocationSize must be an integer multiple of ...minImportedHostPointerAlignment", and
VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744 "the value of memoryTypeIndex must be one of
those returned by vkGetMemoryHostPointerPropertiesEXT". The spec's "Externally Synchronized
Parameters" list names no parameter of vkAllocateMemory, so the thread's imports may run
while other threads use the device. Each chunk's import is made once, under the chunk's own
lock. A chunk is freed only on the existing path (vkFreeMemory's memory parameter is
externally synchronized: one owner frees it).
Verified on the RTX 5080 laptop (NVIDIA 615.71.09), release, --cfg m2v_gpu:
- All 21 host_ram tests pass, among them the new device test
chunks_are_imported_ahead_so_no_making_waits_for_one. It covers 4 chunks of fresh memfd
RAM under MADV_HUGEPAGE, imported ahead in 32.5 ms. Then 40 heaps of 2 MiB over
consecutive runs: 0 chunk imports, 0 host-pointer imports and 40 chunk-bound buffers
during the makings, the slowest making 78 us. Heap 33 passes a CPU write -> GPU read ->
GPU write -> CPU read round trip. A heap made again after all were dropped imports
nothing. The other device tests hold the thread back (Device::hold_host_ram_imports,
test-only), so they still see each chunk imported by its first object.
- Negative control: with the spawn disabled, the new test fails ("the device's thread
imported 0 of 4 chunks").
- On the M3 Max (MoltenVK, macOS 27.0.1), release, --cfg m2v_gpu: all 19 host_ram tests
pass (the two dma-buf tests are Linux-only). In the new test, 4 chunks were imported ahead
in 7.2 ms; across the 40 makings the slowest took 35 us.
- Unit test the_devices_thread_goes_on_past_the_chunk_an_object_took_then_from_the_start
covers the order, the skip of a held or failed chunk, and the end.
Heap makings, 128 heaps of 2 MiB over fresh THP memfd RAM (wall time per
new_heap_with_bytes_no_copy):
case p50 p90 max makings > 5 ms
before, 1 GiB RAM 0.001 ms 0.002 ms 7.39 ms heaps 0, 32, 64, 96
after, made at once 0.001 ms 0.003 ms 7.54 ms heaps 0, 32, 64, 96
after, made once the thread is done (122 ms) 0.001 ms 0.002 ms 0.05 ms none
before, 16 GiB RAM 0.001 ms 0.002 ms 7.54 ms heaps 0, 32, 64, 96
after, 16 GiB, made once done (3468 ms) 0.001 ms 0.002 ms 0.03 ms none
Made at once, the makings outran the thread: 5 chunks were imported during them, 4 of
them by the thread. Once the thread is done, no making waits for an import.
(cherry picked from commit 7baa553a75515909f2ce9701c1e1bea4c408845a)
(cherry picked from commit 97a69f70ab96d37dcdf269192a6935f8c4126749)
|
||
|
|
c9a2347fa6 |
Re-bless the conformance cost records on the M3 Max at 2b55ab415e, four ICB/mesh cases withheld
What: the M3 Max cost records of the whole case set re-measured on this tree (2b55ab415e: the compressed-extended-range scratch fix 2b5f0731c5 and the no-copy look fix 36ec3efc81 in), debug build, MoltenVK 1.4.2: `conformance cost --runs 8 --write` over the whole set (1123 cases, 1114 measured, 9 stopped), then `conformance cost --runs 8 --alone --write` over the 820 cases whose record gained a bound or a record, so every new bound carries its contrast. The draws class's ceiling in cost::the_creation_prediction rises 45 -> 47 (below), with its table re-read from these files. AFTER_THE_LAST_RUN names no case and stays empty. Four cases keep their committed recordings, whole files, new counters and all, because their gated rises came with stack18's indirect-command-buffer and host-step commits and are not yet explained: indirect-mesh-commands-object-threadgroup-lengths, mesh-commands-unordered-draws, mesh-commands-own-state and indirect-render-commands-inherited-state. A `cost --check` on this tree reads `over` on exactly those four until their cause is fixed or shown to be required and their records are written in a follow-up. Differences of this commit's records from the ones they replace, as `cost --check` counts them (cost::drift of each committed record against this write, before the contrast): 1522 over 558 cases, 45 of them numbers the gate reads. - 1452 counts newly gated (the counters the old records predate: heap_tables_worked_out in 551 cases, resident_textures_looked_at 320, dispatch_shapes_made 293, host_steps_recorded 155, dispatch_used_resources_listed 47, and others); 25 no longer gated. - 43 gated bounds moved: 16 fell (bound_notices_made in 14 cases, no_copy_lies_read in two) and 27 rose. 2 pipelines-per-state ratios rose. Each rise, bisected with each case alone (`cost --runs 8 --show`, debug builds, one selection at every candidate commit): - compressed-blits-bgra10xr and -srgb: command_barriers 5 -> 24, cmd_copy_buffer_to_image 7 -> 12, cmd_copy_image_to_buffer 6 -> 11, cmd_pipeline_barrier 18 -> 37. |
||
|
|
e0b0bbb700 |
Pin the runtime sources after the captured core's merge leases
A type-only fix in encoder.rs (no behaviour changed, so RUNTIME_VERSION stays 1754). (cherry picked from commit 2b55ab415e2972a1f6cff06536bd4c659193f4e2) |
||
|
|
4bfc52b6de |
Hold a captured core's merge leases as the encoder now does
The kept ICB recordings' Captured takes an encoder core's kept_leases, which the lent merge scratch turned from Vec<KeptLease> into Vec<MergeLease> (and dropped KeptLease's import): each branch built alone, the two together failed E0425 at encoder.rs. Captured now holds Vec<MergeLease>, the same leases the core held. No behaviour changes. Verified: cargo clippy --workspace --all-targets --all-features -D warnings passes on the stack. (cherry picked from commit bee669c0efdb0be77539f3be2c1dd2e6aac1f694) |
||
|
|
18f064f0ff |
Pin the runtime sources after host steps, kept ICB recordings, replay misses and lent merge scratch
RUNTIME_VERSION 1754 says the behaviour changed. Hash from the pin derivation over the listed runtime and translator sources. (cherry picked from commit e9300eecd461cc17c6d9f37d22106d0bf5a0d681) |
||
|
|
e748ef398b |
Bump RUNTIME_VERSION to 1754: host steps off the scheduler, kept ICB recordings, unbound replay misses, lent merge scratch
- Unchanged indirect commands run from kept recordings, chunk by chunk. - A device replay leaves an address no allocation holds unbound, counts the miss and runs the command (it faulted and dispatched nothing). - Host steps record on a steps thread off the scheduler's, order by what the execution reaches, and make only the states the CPU named. - A command buffer lends its finished encoders' linear-merge scratch to its later merges. - A new no-copy buffer's pages are looked at once as it is made. Each changes what a recorded run did. Stacking note: the host-steps commit (3831ba7e12) met checks at commit in scheduler/mod.rs. run_work takes the scheduler's Arc (to post a step to the steps thread) and keeps the committing-thread doc of claim_check; submit_at_commit's call passes &self.shared (a check, so it never takes the steps branch). cargo check of the runtime passed after the resolution. (cherry picked from commit d8c160edeba572b9500a04e228c4b79d1fd6492d) |
||
|
|
9c41c0b2a6 |
Lend a command buffer's merge scratch to its later encoders' merges
A linear attachment rendered apart (a texture over a buffer's bytes beside a depth or stencil
attachment on NVIDIA, VK_NV_linear_color_attachment's rule) made a scratch of twice its box
for every pass's merge (LinearMerge:🆕 Device::scratch_buffer(2 * part)), and a shadow
merged back at each encoder's end (host pages, packed rows the device's linear images do not
lay out, such as an IOSurface's 4 * width) made one of its rows for every encoder: each held
until the command buffer completed, as the shadow's spares came back only then. A WebGPU frame
split at every indexed draw (stencilMask: 706 passes over a 1200x1200 canvas) so held 4 to
5.6 GiB, and the reims-vgpu lane's endEncoding failed out of device memory on the RTX 5080.
Now each command buffer keeps a pool of the scratch its ended encoders' merges are done with
(merge_scratch.rs, CommandBufferShared::merge_scratch): a linear merge takes the smallest free
scratch of its kind that holds its box, and gives it back once its pass's merge is recorded
(LinearMerge::record_merge); a shadow merge takes one the same way (before the shadow's
spares), held by a ScratchLease beside the encoder's kept-image leases (MergeLease) and given
back as the encoder goes. The pool holds weak references, so the bytes still go when the
command buffer completes, a shadow's back to its spares once the last merge that used it goes
(Scratch's drop, in place of ShadowMerge's). A new scratch takes at least twice the largest of
its kind the command buffer made, capped at a whole attachment's merge, so growing boxes make
a few. The memory a command buffer holds for merges follows its attachments, not its passes.
Why lending needs no wait (merge_scratch.rs's Order, against the barriers as recorded):
- a linear merge's scratch is touched only by its pass's fill and keep after the copy in
(record_keep: fill, Barrier::everything, keep, Barrier::everything), its reloads in the
pass's steps (reload_in), and its merge (record_merge: Barrier::everything, the changed copy,
Barrier::everything, the dispatches, Barrier::everything); a shadow merge's by its keeps and
merges, recorded before the encoder's next command that touches the bytes another way or at
its end, each merge ending with Barrier::everything after its dispatches (record_merge). All
lie in the encoder's own VkCommandBuffers or the segments it leaves between them;
- a command buffer's encoders go in order (one open at a time; a render end left to the
lowering thread is lowered before the next encoder opens) to its queue's one VkQueue, which
the queue keeps from the command buffer's making to its completion; reruns of a laying and
re-encodes after a rebind repeat or replace whole encoders. So two encoders' spans over one
scratch never interleave in submission order;
- each span writes what it reads before reading it, and the earlier one ends with
Barrier::everything (ALL_COMMANDS/MEMORY_WRITE to ALL_COMMANDS/MEMORY_READ|WRITE), whose
scopes are every command before and after it in submission order on the queue: the later
span's writes follow the earlier's reads and writes. A shadow's scratch is tracked besides.
Counted: WorkCounts::linear_merge_scratches_made and linear_merge_scratches_reused (new; the
api_signatures table blessed); shadow merges count the pool's loans in
shadow_merge_scratches_reused. A cfg(test) switch (DeviceShared::linear_rule_forced) makes
linear_attachment::bound answer the rule, so a device of no such rule (MoltenVK) reaches the
path in the runtime crate's own device tests.
Measured on the RTX 5080 Laptop GPU (msi-laptop, release, a scratch harness of
stencilprobe -P's sequence on the runtime: one command buffer, a clearing pass, 706 passes
loading colour and stencil beside a Depth32Float_Stencil8 attachment, a 1x1 attachmentless
encoder between them, 1400 encoders; three runs a process; peak = nvidia-smi's per-process
used memory, sampled every 50 ms), base 357a76f214 against this commit:
- texture over host pages, 1200x1200, rows 4800 (a shadow): before 3776 to 4096 MiB of device
memory allocated while encoding, peak 4333 MiB, commit to completion 87 to 89 ms; after 0 MiB,
peak 237 MiB, 57 to 65 ms;
- host pages, 1024x1024, rows 4096 (a shadow): before 2496 to 2816 MiB, peak 3053 MiB, 65 to
70 ms; after 0 MiB, peak 237 MiB, 53 to 59 ms;
- a Private buffer, 1024x1024, rows 4096 (the linear attachment rendered apart, 707 passes
through copies): before endEncoding failed, OutOfMemory(Device), peak 5485 MiB; after it
completes, 0 MiB, peak 237 MiB, 73 to 81 ms;
- a Shared buffer, 1200x1200, rows 4800 (a shadow): before 3776 to 4096 MiB, peak 4333 MiB, 80
to 88 ms; after 0 MiB, peak 237 MiB, 56 to 64 ms.
Measured on this Mac (M3 Max, MoltenVK 1.4.2, release, the same harness; peak = the process's
peak memory footprint, /usr/bin/time -l), base against this commit: host pages 1200x1200, rows
4800 (a shadow): before 3776 to 4096 MiB allocated while encoding, footprint 5087 MB, commit to
completion 117 to 151 ms; after 0 MiB, 795 MB, 104 to 138 ms. Host pages 1024x1024, rows 4096:
before 2496 to 2816 MiB, 3755 MB, 110 to 143 ms; after 0 MiB, 803 MB, 101 to 128 ms. The Private
and Shared cases render in place on MoltenVK (no rule, no shadow) and are unchanged (64 to 86
ms, 655 to 661 MB).
Tests (device tests, --cfg m2v_gpu):
- tests::merge_scratch (runtime crate): 240 passes beside a Depth32Float depth attachment in one
command buffer, over a Private buffer and a Shared buffer (packed rows of 1024 bytes), packed
rows of 1200 bytes, and host pages; the rule forced. Passed on the RTX 5080 as committed, and
on the M3 (MoltenVK) with a fifth case since dropped (below): each linear case 240 passes
apart, 1 scratch made and 239 reused; each shadow 239 reused; texels equal a private
texture's. Negative control (this tree with
MergeScratch::take lending nothing, on the M3): all four fail (240 made, 0 reused; 0 shadow
scratches reused). The base with the test copied in (its new counters left out) fails the
shadow cases on the 5080 too (0 reused).
- runtime_lane::linear_attachments::many_passes_* (validation crate): 706 passes over a Private
buffer (320x240, rows 1280), host pages (rows 1280 and 1200) and a Shared buffer of rows 1200,
colour bytes against a private texture's. Passed on the M3 and on the RTX 5080, where the
Private case is apart by the device's own rule: 706 passes through copies, 1 scratch made and
705 reused; each shadow 705 reused. The negative control fails the host pages case.
- clippy --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; the
api_signatures and api_surface tests.
Not fixed here, and not in the tests: over a Private buffer whose rows have bytes between them
(200 texels in rows of 1024 bytes, a shadow copied back), the same 240 passes leave 8800 (M3)
and 10516 (RTX 5080) of the 19200 texels unequal to a private texture's, at base 357a76f214 too
(the 5080, the test copied in): no merge runs there, so it is not this change's.
(cherry picked from commit b8fdd84f5c69546d1626fb994fd7d13756c1fc96)
(cherry picked from commit 6fa0708f5ef41bf2a599616a19d2da616492f032)
|
||
|
|
0e62eb1f72 |
host_replay_frames: HOST_REPLAY_VERTEX_OPS gives each state a vertex function of its own
With one vertex function for every state, the large-buffer form of the states' pipelines shares its vertex module, and the driver compiles it once: on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, its disk cache off) the parent's commit-time settle made 4,001 VkPipelines of 2,000 states in about 0.1 s, where a browser's states each bring their own vertex function. The knob gives each state its own: rt6_resolve_half's triangle, its depth a chain of that many dependent multiplies and adds on the vertex index, times zero, plus a half. Verified: the generated vertex function translates (metal2vulkan CLI, spirv-val PASS); clippy -D warnings with --cfg m2v_gpu for the validation crate. Needs no version bump: a test, ignored by default. (cherry picked from commit 7532a5fbc4ac6cad04a1b91186a8819952c7235c) (cherry picked from commit 59ea25b2d2894f467256420518445fe902e78deb) |
||
|
|
e51a3fa56d |
Name an ICB's per-command map CommandStates, not Commands
The kept recordings of unchanged indirect commands (four commits back) named the buffer's map of the states the CPU set, and of its kept chunks, Commands. tests::exit_guard's only_the_listed_modules_keep_the_device_s_functions reads the sources for copies of the device's functions and takes Commands for the generated-commands table that holds them, so it failed at indirect_command_buffer.rs's pipelines: Mutex<Commands>. The map holds no device function; its name now says what it holds. Verified: --cfg m2v_gpu, metal2vulkan-runtime's tests::exit_guard and kept_commands tests (42) pass; the exit-guard test failed on the commit before (the M3 Max run of the runtime's lib, 1,830 of 1,831 passing). Needs no version bump: a private rename. (cherry picked from commit 93c48b72a7a094d6c7cee93192070f7f99e77dea) (cherry picked from commit 831d54138016d0373b51e7c033e4c7665dbd65ce) |
||
|
|
51c7059a40 |
Regenerate docs/REFUSALS.md: KernelStageIn's site and the rebind_slots range refusals
python3 scripts/refusal-surface/refusal_surface.py on this tree. Two rows move: - KernelStageIn's runtime site is indirect_execute.rs's dispatch now, where the kept recordings of unchanged indirect commands moved the refusal (two commits back), not record; - BufferRange and DescriptorRangeExceeded gain bind/graphics.rs's rebind_slots, a site the base had added without regenerating the table. The device replay's ReplayFaults::ADDRESS was no refusal, so its removal moves no row; tests/api_surface.rs names ReplayFaults alone, and api_signatures.tsv dropped the constant with it (scripts/api-signatures --check passes). Needs no version bump: a generated document. (cherry picked from commit 07d7e05255a3d15ba98094389a680e96440eefa0) (cherry picked from commit 3d66d7436109ffbd80c5e6adf0ef1d92b26d70e5) |
||
|
|
2e0fb7b220 |
runtime_lane::host_replay_frames: what frames of GPU-writable render commands cost another queue
An ignored measurement (run by name, release, --cfg m2v_system_alloc), the shape of a browser's render bundle under a compositor: 256 render pipeline states made with supportIndirectCommandBuffers, each with a fragment function of its own, and an ICB of 5000 draws that sets the first 4 of them in turn, inheriting nothing. Each frame a compute encoder makes the ICB resident for writing and dispatches a kernel that writes no command, and a render pass executes every command; meanwhile another queue presents a clear every 8.33 ms. It prints HOST-REPLAY lines: the first 4 frames one by one, then the median, p90 and largest of 60 frames (the frame, its commit, first submission to last), the presenter's commit to completion and the ticks it missed, and the device's counters over them (host steps and their time, heads held, variant pipelines made, pipelines looked up, draws settled and dropped, records read). HOST_REPLAY_STATES sets the live states, HOST_REPLAY_OPS gives each fragment function that many dependent operations on the position (so the driver takes longer to compile it), and HOST_REPLAY_DROP_MS has the program release every state but the named ones that long into the first frame. Verified: the previous commit's M3 Max numbers come from it (run on the parent and on that commit's tree); clippy -D warnings with --cfg m2v_gpu for the validation crate. Needs no version bump: a test, ignored by default. (cherry picked from commit 42c7708b1ded77b1334812c7eb701764a5d69bd5) (cherry picked from commit afed271c358c30dcb1a7eddfe829c1518055998a) |
||
|
|
185bbd6328 |
Host steps: record off the scheduler's thread, order by what the execution reaches, make only named states
A batch executing indirect commands the GPU may write waits for its gate, then its host step records the commands from their records. Three costs fell on every other queue meanwhile: - The step ran on the scheduler's thread, which submitted nothing while it recorded (thousands of draws take milliseconds). - Its footprint was unknown (tracker::ordered's None), so every later batch of another queue that made a tracked use was held behind it until it was submitted. - At commit, the render settle made a VkPipeline for every live state that supports indirect command buffers, times the topology class's primitive types (1,280 lookups and 513 makings for 256 live states on the measured frame), and the step waited for all of them, up to the command buffer's bound. Now: - The scheduler hands each step to a steps' thread (scheduler/steps.rs, started at the first step, user-interactive like the scheduler's, recording inline where the host cannot start it), which records the steps in order, each a section of the exit guard, and wakes the scheduler. The batch is marked as stepping meanwhile (CommandBufferShared::begin_step/end_step), so it waits and no pass hands it over twice. - commit bounds a step's uses where it can (Segment::bound): for a compute execution, the resources the command buffer made resident and the ICB's storage (and an indirect range's copy); for a render pass, the pass's own uses, the resident resources and each execution's storage. CommandBufferShared::footprint uses that bound, so only a later batch sharing one of those is held. An execution that inherits buffers, is gated or preprocessed, reaches tile memory, has shadows or lends visibility stays unbounded (None), as before. - The render settle makes the states the CPU set on the executed commands (IndirectCommandBuffer::set_render_states, each state once), or the inherited one. A draw of a state a GPU-written record names that no settle made is begun at the step, made on its thread or handed to the device's pool and waited for until the command buffer's bound, as before; it holds no other queue's batch, and it is counted. On the kept recordings of the commit before (item 1), set_render_states reads the states the CPU set from the buffer's per-command map (Commands::states, a range of it), each state once. New counters: WorkCounts::host_steps_recorded, host_step_nanos, and host_step_pipelines_made (the VkPipelines a step began itself, made on its thread or handed to the device's pool and waited for: counted at the variant's making on the step's thread and at pipeline_pooled). The degrade notice host-replayed-indirect-commands states the new cost (degradation.rs and docs/API.md, same text). Verified on the M3 Max (MoltenVK 1.4.2), release, runtime_lane::host_replay_frames (the next commit: 256 live states, an ICB of 5000 draws naming 4, made resident for writing by a compute pass each frame, and a presenter clearing a texture on another queue every 8.33 ms), the parent and this tree run alternately twice, 60 frames each after 4 cold ones, on a loaded host: - the presenter: 80 of 244 and 73 of 192 ticks presented before (commit to completion median 16.9 and 16.4 ms, p90 40.8 and 23.7 ms), 186 of 186 and 185 of 189 after (1.13 and 1.13 ms, p90 1.49 and 2.23 ms); heads held behind earlier commits 23 and 13 before, 0 after; - the first frame's commit: 377 and 168 ms before (513 variant pipelines made, 1,284 looked up), 5.3 and 5.1 ms after (9 made, 24 looked up); a steady commit 2.38 and 2.33 ms before, 0.14 ms after; - the frame itself (commit to the last completion): median 28.7 and 24.4 ms before, 23.3 and 24.6 ms after, within the host's noise; the host step takes about 20 ms of it (host_step_nanos), recording the 5000 draws. The consumer's ICB repro (one state, 5001 draws, the ICB made resident for writing, another queue's one-dispatch command buffers meanwhile), same runs: that queue's commit to completion at the 99th percentile 53.5 and 24.3 ms before, 2.96 and 3.71 ms after, 140 and 119 command buffers in 40 frames before, 2,281 and 2,062 after; the frame alike (21 to 26 ms). Tests: runtime_lane::render_executions:: a_host_step_makes_the_pipeline_of_a_state_only_a_gpu_written_record_names (a blit-copied record naming a state, of another variant, that the CPU set on no executed command: both commands draw, the step's beginning of that state's VkPipeline is counted, and the step's time). --cfg m2v_gpu under the validation layer, on this tree before the pipeline_pooled count and the test: 234 tests of the indirect_*, kept_*, render_executions, render_gpu_executions, render_merged_executions, mesh_commands and executions lanes; 1,644 tests of the runtime crate's lib and the commands_recorded, dispatch_executions, generated_executions, kept_variants, device_commands, queue_order, submission_checks and grouped_submissions lanes. clippy -D warnings, plain and --cfg m2v_gpu; rustdoc -D warnings; scripts/api-signatures --check. Needs a RUNTIME_VERSION bump (what a run submits, when, and its counts) and a runtime-sources pin. (cherry picked from commit 4b05004999403684a2bdf4f3994108b53c7dc776) (cherry picked from commit 3831ba7e1298203779597feb0ea2943f77f9f5df) |
||
|
|
4b0222d316 |
Device replay: leave an address no allocation holds unbound, count the miss, and run the command
The compute device replay's preprocess (bind/replay.rs, the GPU-alone path of a GPU-writable compute execution and the generated-commands path) faulted a command whose kernel buffer address lay in no resident allocation (ReplayFaults::ADDRESS) and dispatched nothing. The command buffer completed with no error and the dispatch never ran: a command naming a buffer the program released before the execution, made resident for READ|WRITE in the executing encoder or for WRITE in an earlier encoder, wrote nothing. Metal runs that dispatch, and the draw replay and the host's step already leave such a slot unbound and count a resident miss. The preprocess now does the same: the slot is unbound (it reads as a buffer never set, so it reads zero and drops writes), the command's misses are added to the status's ResidentMisses with StatusBits::RESIDENT_MISS, and the command runs. A faulted command reports its faults alone, as before. ReplayFaults::ADDRESS is removed (bit 7 is no longer reported): a breaking change of the public `metal2vulkan::bind` surface, and the validation engine's verdict drops its name. Tests: bind::replay::tests' four ADDRESS refusal cases become an_address_no_allocation_holds_leaves_its_slot_unbound_and_counts_a_miss (no fault, one miss, the command's arguments and slot table, the missed slot zero, an empty command counts nothing); runtime_lane::dispatch_executions::a_command_s_released_buffer_runs_its_slot_unbound runs one command naming a released 16-byte and 1 MiB buffer with the ICB resident for READ (commit's recording), for READ|WRITE, and for WRITE in an earlier encoder (both on the GPU alone), and checks the output, one counted miss in the report, and that nothing is announced. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under the validation layer: - before the fix (the parent with the test added), the test fails at the READ|WRITE form of the 16-byte buffer: out stays 0xee in all 16 bytes, so the dispatch never ran; - with it, the test passes, as do runtime_lane::dispatch_executions, indirect_host_steps and generated_executions (35 tests). CPU: metal2vulkan bind::replay, bind::status, tests::engine_device_replay and the validation candidate::engine tests pass; scripts/api-signatures/signatures.py --check passes. Needs a RUNTIME_VERSION bump (the device replay's preprocess and its status) and a runtime-sources pin; no SEMANTICS_VERSION or ARTIFACT_FORMAT_VERSION bump. (cherry picked from commit 89ebae67047f940624efb76c0ab535fa3b3b56ab) (cherry picked from commit 15da05bbb5eb5fe8814efd912b6e81b50802a7a8) |
||
|
|
565fbd9153 |
Run unchanged indirect commands from kept recordings, chunk by chunk
An execution of an indirect command buffer read, decoded and recorded every command again at every commit, so an unchanged execution of 16384 draws cost about 44 ms of commit on the M3 Max and 64 ms on the RTX 5080 laptop, where Metal's costs 2 ms. A profile of the render case put a third of it in the records' decode and moves and the rest in recording the draws. Now an execution of commands the CPU encoded records them in chunks of 256 (kept_commands.rs). A render chunk records into a secondary of its own, begun for simultaneous use against the instance's compatible pass, through an encoder over a core of its own whose effects the pass's core takes (EncoderCore::capture, absorb); a compute chunk records as a segment of its own, behind a barrier from everything before. Each chunk takes its command pool, descriptor arena and uploads from a context of its own, lent to the command buffer while it records and held by every command buffer that runs it. A chunk whose recording is plain (every draw passes draw_again's keep test but for being replayed, no step outside its command buffer, nothing its command buffer alone holds, no released state) is kept on the buffer with what it was recorded from: the encoder's inputs (RenderKey, ComputeKey: the inherited state, the pass's compatible pass, shape, extent and sample positions, the encoder's state and scissors, the resident resources), each address its commands named and what it resolved to, and the no-copy moves. A later execution of the chunk under equal inputs, every address resolving as before, nothing detached and every held object alive, runs the kept command buffer and notes its uses, keys, holds and executions again (EncoderCore::run_kept), reading no record. Every CPU write of a command forgets its chunk under the lock the write takes; the buffer's first GPU write forgets them all; a recording from records written meanwhile is not kept. A chunk that is not plain records the rest of the range as before and is noted, so later executions of it record as before until a write reaches it. The buffer's per-command state moves to a map, so a buffer of commands never encoded holds nothing for them. WorkCounts::indirect_chunks_kept and indirect_commands_kept count the kept path. docs/FAST-PATHS.md's known gaps list the executions that still record every command at every commit. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under the validation layer: runtime_lane::kept_commands, 5 tests: unchanged render commands run 3 kept chunks of 600 commands reading no record, into another target and twice in one pass; a command written again or reset records its chunk alone; a blit's reset runs no kept chunk and its commands draw nothing; another residency or range records again; compute commands the same, with a command written again and a blit reset. 446 of 448 tests of the 33 lanes that execute indirect commands pass; the two others (extended_range_blends half outputs, padded_loads loading pass) are among the MoltenVK reds the parent already has. clippy -D warnings, plain and --cfg m2v_gpu, for the runtime and validation crates; the runtime's kept_commands unit test; the translator's fast_paths, api_signatures and api_surface tests. Needs a RUNTIME_VERSION bump and a runtime-sources pin. (cherry picked from commit 21b9438ec5b8cbf7a1e79c5dfbf84cdad7b43d91) (cherry picked from commit 922caf3199378b029bafc201429f80b0d43bb048) |
||
|
|
b7652d85a2 |
Re-qualify every authored case on Metal under ORACLE_ABI v49
ORACLE_ABI v49 (the tile oracle's own pipeline per threadgroup size) leaves every v48 row non-current, so every committed authored case is qualified again on the M3 Max under the C3 reference identity: macOS 27.0.1 (26A434), Xcode 27B52, metal 32023.922. The cases were measured through the indexed path (corpus-metal --batch, default jobs, under the Mac GPU lock) and installed with corpus-metal --batch-install, the store's validated write. Each case's apple-m3-max-macos27.0.1 row is replaced, and no other environment's row moves. Field by field against the committed rows, leaving out only the environment identity, oracle_abi and timing: - 2262 equal in every field: 2258 qualified with the same output and 4 reference gaps with the same family and message (GPUFamily10 simdgroup_matrix 16x16); - 0 newly qualified; - 0 changed status. The 2262 cases are every committed case. The 1x1 tile-order case left in the previous commit. Every apple-m3-max-macos27.0.1 row now records metal-literal-resources-v49. One case needed a second run. e997a71d…, a private-source compute case, timed out in the batch under host load: "compute pipeline creation did not finish within 60s". Run alone, it qualified in 43.7 s with its committed output. Verified: - the comparison above, by a script over the committed and installed shards; - the whole metal2vulkan-validation suite with every row installed: 1363 passed, 4 skipped. (cherry picked from commit 1a970229669e0e30c154182f453e8626220412fa) (cherry picked from commit c00efdc7c0519d01304f174ab625780ad8412ed4) |
||
|
|
b31ea18f1b |
Remove the 1x1 tile-order case: Metal runs no thread of a 1x1 tile threadgroup
The case tile-threads-1x1-in-a-16x16-tile-take-their-places (b879f660…) dispatched k10ts_tile_order at one thread per tile threadgroup. It qualified only because Metal's pipeline cache handed it a pipeline compiled for another case's larger size. Under ORACLE_ABI v49 its pipeline is its own, and Metal refuses it. Metal gives no error text: the tile pipeline answers maxTotalThreadsPerThreadgroup 0, and the oracle refuses the dispatch before encoding it: "Metal tile dispatch asks for 1 threads a threadgroup ([1, 1, 1]), but the pipeline permits 0". The 0 is Metal's real behaviour, not a value read wrongly. A from-scratch 1x1 tile pipeline compiled for the first time on the M3 Max (macOS 27.0.1) reports 0 and runs no thread of a 1x1 dispatch, with the command buffer completed and no error. The store has no Metal-refusal row, and a v48 row left in the slot would read as missing Metal forever, so the case goes. The same tile function at the same tile is still covered, through the same fixture and entry, at 2x2 (e307478f…, tile-threads-2x2-in-a-16x16-tile-take-their-places, the smallest size Metal runs), 4x4 (5e61d5c4…), 8x8 (81c239f3…) and 16x16 (0714ac91…), and in a 32x32 tile (2a0d4ff1…). Removed: the case line (cases/shard_030), its Metal rows (2), Vulkan rows (10), MoltenVK rows (2) and its line of the authored compile census (authored-compile.tsv, one line per committed case). No other line of the census moves. Nothing outside the corpus names the case. (cherry picked from commit 02006734aefb5100632cd20c6f060859074b1f48) (cherry picked from commit e9adbb55bedd2ab953a0988a8fbba66900b02ebe) |
||
|
|
4def63989b |
Give each tile threadgroup size a Metal pipeline of its own: ORACLE_ABI v49
The tile oracle now sets the tile pipeline descriptor's maxTotalThreadsPerThreadgroup to the
dispatch's threads, beside the requiredThreadsPerThreadgroup it already set.
Why: Metal keeps a tile pipeline it has compiled. For a later descriptor of the same function
that differs only in requiredThreadsPerThreadgroup, it hands back that pipeline and its
maxTotalThreadsPerThreadgroup, in the same process and in later ones (measured on the M3 Max,
macOS 27.0.1, with salted from-scratch kernels). A case's outcome therefore followed whichever
case of its fixture ran first:
- In the reference re-measure, the 8x8 case of k10ts_tile_order (81c239f3…) ran after its 4x4
case and got 16: "Metal tile dispatch asks for 64 threads a threadgroup ([8, 8, 1]), but the
pipeline permits 16".
- The 1x1 case qualified only when a larger size's pipeline was handed back.
- Such a pipeline also runs nothing: an 8x8 state that reports 16 runs no thread of its 8x8
dispatch.
The descriptor's own limit separates the pipelines. With it set to the size's threads, each size
reports its own limit and runs all of its threads (16, 64 and 256 for 4x4, 8x8 and 16x16), in
the same process and in a later one. A first compile of a required size reports that limit
anyway, and Metal refuses a descriptor limit above it ("must match"), so the limit adds no
constraint of its own. Metal still answers what it answers without a cache: the size's threads
rounded down to a multiple of 4.
ORACLE_ABI moves from v48 to v49: what the oracle compiles changed. Every Metal row recorded under
v48 stops being current evidence until it is re-qualified, which the commits that follow do.
Verified with the release corpus-metal of this tree, reference environment, single runs:
- e307478f… (2x2), 5e61d5c4… (4x4) and 81c239f3… (8x8) qualify, each with its committed output.
- b879f660… (1x1) is refused: "Metal tile dispatch asks for 1 threads a threadgroup ([1, 1, 1]),
but the pipeline permits 0".
(cherry picked from commit 193875e7393810840c517a9d9d5ea127a0e317ec)
(cherry picked from commit ac29781634d83f9d1b814f0156b3d01ad320d84b)
|
||
|
|
3cbc39b51c |
Look at a new no-copy buffer's pages once as it is made
What: making a no-copy buffer (Device::new_buffer_with_bytes_no_copy and the other callers of the import path in buffer_descriptor.rs) looked at where the new buffer lies three times, each look taking the pages' lock (WorkCounts::no_copy_lies_read): kept_log for the log of the pages' writes and the copy's name, kept_with for the guest RAM runs, and the aliases' join. kept_with's `if let (Some(runs), Some(pages)) = (runs, buffer.host_pages())` evaluated the look even when there were no runs. The import path now looks once (HostCell::current, as the aliases' join did) and gives those pages the caller's dirty log, the log, the copy's name, the runs and the aliases; the two copied paths look once in kept (kept_log and kept_with merged into kept and keep_in). Why: the whole-set conformance cost check on the M3 Max read no_copy_lies_read over its records in host-page-writes-visibility-read-only and -writable (18 -> 19) and -kernel-store-read-only (21 -> 25). Bisected per case alone (cost --runs 8 --show, debug builds, the three cases in one selection, visibility / kernel store): |
||
|
|
043018d751 |
Pin the runtime sources after required sizes, checks at commit and the unzeroed canonical scratch
RUNTIME_VERSION 1753 says the behaviour changed. Hash from the pin derivation over the listed runtime and translator sources. (cherry picked from commit abd5f64c55a37cd2df0257185c40dce7fc0c69ca) |
||
|
|
622d03bd59 |
Bump RUNTIME_VERSION to 1753: required sizes answer W*H*D, checks run at commit, canonical scratch unzeroed
- A pipeline state with a required threadgroup size answers W*H*D as its maxTotalThreadsPerThreadgroup (compute and tile), lowered only to the device's limit. - commit_and_submit runs a ready head's submission checks on the committing thread. - The canonical extended-range encoding makes its image scratch without a zero fill. Each changes what a recorded run did or answered. (cherry picked from commit 1480dbb62e83eda330debe8d098c6b0480e7aeb5) |
||
|
|
f2c12aeb80 |
submit_path: a --checked flag, each fill with a passing submission check
What: the bench's latency, cpu and threads rows can give each fill a submission check that answers None, as a consumer's detach check does. Why: to measure commit to completed-handler latency for checked command buffers before and after the committing thread runs their checks (commit_and_submit), on the RTX 5080. Verified: clippy -D warnings on the runtime's examples (all features). (cherry picked from commit 1677e2c42bf862411799073c34f6e8f35552eb3b) (cherry picked from commit bb4b6681a74eaad43cb8dd3d96d7386162d890fc) |
||
|
|
22fe806e71 |
scheduler_wakes: count the sleep under way as the window opens
What: wakings_and_sleeps now counts, besides the sleeps the scheduler's thread began between the two reads, the one it may have been in as `before` was read. Why: tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake failed 3 of 30 at 357a76f214 and 8 of 30 here, every failure exactly one waking over the sleeps (121/120, 36/35, 42/41, 33/32, 8/7, 6/5). Each test reads `before` on an idle device, whose thread is asleep in a sleep counted as it began, before the read; the first commit's waking of it is counted inside the window. It reads `after` as its last command buffer completes, when the thread may be awake again with its next sleep not yet begun: the wakings then exceed the sleeps begun by one with no sleep notified twice. A sleep notified twice by a change of the wake path would show more than that over a run's 30 to 120 sleeps. Verified on the M3 Max (--cfg m2v_gpu, maclock): both scheduler_wakes tests, --stress-count 60: 60/60 passed; over the 120 runs the wakings never exceeded the sleeps begun by more than one (two runs at exactly one). (cherry picked from commit 7dfd7177e0660d95db25483c620147690cbca371) (cherry picked from commit ee8447c8053d201f893794db4930c2a4906b1819) |
||
|
|
b74a0a4866 |
commit_and_submit: run a head's submission checks on the committing thread
What: a thread in CommandBuffer::commit_and_submit now runs the submission
checks of the head committed first of all itself, without the scheduler's
lock, right before it submits that head, where the head is ready but for its
checks (no host step, no group, no storage-form switch, no rebind) and every
event value it waits for was reached on the device or by the host. It then
passes again under the lock (Inbox::pass_again, which takes nothing in) and
submits that head first, and so on up to PASS_SUBMISSIONS batches in all. A
head whose checks wait for a submitted GPU signal to land, or whose checks the
scheduler's thread took first, stays the scheduler thread's, as before.
Why: reims's Vulkan platform sets a check on every command buffer it commits,
so commit_and_submit never submitted at commit for them (plain_ready held out
every checked head). Metal checks a submission as it submits it, on whichever
thread submits, so running the check on the committing thread is Metal's
behaviour; the check follows the submission handler's rule there (no lock the
caller holds, no GPU wait).
How:
- Held::checks_taken marks a batch whose checks were taken, by check_heads
(left to the scheduler's thread, replacing its Left::holds lookup) or by a
committer (claim_check), so the two never both run them.
- claim_check looks at Order::first_mut (the head take_first would take), so
no head is passed over: commit order holds across threads.
- The committer's handlers keep their Turns tickets: each pass under the lock
takes its own ticket, and its handlers run before the next check.
- The check runs through run_work -> CommandBufferShared::run_checks, the
scheduler's own path, so a code (or a panic) fails the submission exactly
as there (fail_submission, the CB completing with Injected(code)).
- plain_ready now holds out only a checked head whose checks are still to run,
so a head whose checks ran goes with any plain pass.
- Counted: WorkCounts::batches_checked_at_commit (new), beside
batches_submitted_at_commit; classified as Submission by its "batches_"
prefix in the conformance cost rules.
Verified on the M3 Max (MoltenVK, --cfg m2v_gpu, maclock, load 50-90):
- New tests in tests::commit_and_submit:
- a_checked_command_buffer_is_checked_and_submitted_on_the_committing_thread:
40 of 40 checked and submitted on the caller, check then handler, before the
call returned; batches_checked_at_commit 40.
- a_refusing_check_fails_its_submission_alike_at_commit_and_on_the_scheduler:
two submissions split by an event signal, the second refused with code 8:
identical status, error, completed-handler status, submissions seen, bytes
and event value on both paths.
- checked_command_buffers_keep_commit_order_across_commit_and_commit_and_submit:
2 threads x 500 checked CBs, commit and commit_and_submit in turn: checks
and submission handlers in commit order, each check once; 308 of 1000
checks on a committing thread.
- The five commit_and_submit tests: --stress-count 10, 10/10 passed.
- Negative controls:
- claim_check answering None: all three new tests fail (0 checked at commit).
- claim_check neither honouring nor setting checks_taken: the order test
fails 4/4 (checks out of commit order, checks run twice).
- runtime_lane::submission_checks' in-flight test gains a commit_and_submit
variant whose wait is met only by a GPU signal in flight: its check ran only
after the signal landed and never on the caller, Event and SharedEvent.
submission_checks, grouped_submissions and queue_order lanes: 24/24 passed.
- Runtime tests matching scheduler|check|teardown|completion|submission|inbox|
order: 169/169 passed. Conformance cost, fast_paths and api_signatures
tests 38/38; clippy -D warnings (runtime + validation, --cfg m2v_gpu) clean;
public rustdoc clean. api_signatures.tsv blessed (one new field).
(cherry picked from commit 91d0ea691a95649cbdc7828d4cc9ee6762a7ae53)
(cherry picked from commit 6c5fca926e855ee7d7236bc850bb9b281f4dd9cd)
|
||
|
|
0e7e09a064 |
Answer a required threadgroup size's threads as a state's maxTotalThreadsPerThreadgroup
A compute or tile state whose descriptor states requiredThreadsPerThreadgroup now answers that
size's threads as its maxTotalThreadsPerThreadgroup. The answer is lowered only where this device
holds fewer threads for the kernel than the size. A state that requires no size keeps today's
answer, the compiled pipeline's limit. Before this change every state answered the compiled limit
(1024 on a full device) whatever size it required. Metal answers the size.
Measured on the M3 Max under macOS 27.0.1. Each state came from a source compiled once and never
before, with an integer baked into it:
- Compute: exactly W*H*D. 1x1x1 gives 1, 3x1x1 gives 3, 3x3x1 gives 9, 7x3x1 gives 21, 8x8x2
gives 128, 1x1x64 gives 64, 32x32x1 and 1024x1x1 give 1024. No size gives 1024.
[[max_total_threads_per_threadgroup(128)]] with 8x8x1 gives 64.
- Tile (threadgroupSizeMatchesTileSize on or off): W*H*D rounded down to a multiple of 4.
1x1, 2x1 and 3x1 give 0, 3x3 gives 8, 7x3 gives 20, 2x2 gives 4, 6x6 gives 36, 8x8 gives 64,
16x16 gives 256, 32x32 gives 1024. A tile dispatch of the state's own size runs no thread
where the threads are not a multiple of 4 (1x1, 2x1, 3x3, 7x3). The command buffer completes
with no error.
- Metal keeps a state it compiled and hands its limit to a later state of the same function
that differs only in the required size. For compute this was seen in the same process; for
tile, in the same process and in a later one. A compute state with 8x8x1, and one with no
size, answered 16 after a 4x4x1 state of the same MTLFunction. An 8x8 tile state answered 16
after a 4x4 one, and its 8x8 dispatch ran no thread. The module doc's earlier "the state's
maxTotalThreadsPerThreadgroup stays the kernel's own" reads like such a measurement: a
function compiled first with no size.
Rule 1 does not cover this: it is an API value Metal reports, not arithmetic. So the runtime
answers Metal's first-compile rule and does not imitate its cache. Following the owner's
decision, a tile state also answers the size's threads where Metal rounds them down, and its
dispatch of that size runs. Metal runs no thread there, which is its own defect. docs/API.md's
accepted differences records both and Metal's cache answer.
How:
- ComputePipelineState::max_total_threads_per_threadgroup answers
pipeline::reported_max_total_threads(required size, compiled limit). A tile state's
RenderPipelineState answer goes through its tile function's compute state, so it follows.
- The compiled limit moves to pipeline_max_total_threads_per_threadgroup (crate-private). The
replay and folded indirect-dispatch paths (gpu_execute, indirect_dispatch) read it, so no
dispatch path changes.
- Docs: the additions module's measurement, the tile module's answers, the render and compute
accessors, the translator's descriptor fields and ComputePipelineMetalInfo, and docs/API.md's
accepted differences.
Tests:
- tests::pipeline::a_required_size_is_the_states_thread_limit (CPU): the rule, the device's
lower limit, no size, and axes whose product overflows.
- runtime_lane::compute_threadgroups::a_compute_state_with_a_required_size_answers_its_threads
and runtime_lane::tile_states::a_tile_state_with_a_required_size_answers_its_threads
(--cfg m2v_gpu): states made through the runtime with and without a size.
Verified:
- cargo clippy -D warnings, plain (metal2vulkan, metal2vulkan-runtime, metal2vulkan-validation)
and with --cfg m2v_gpu (metal2vulkan-validation);
- RUSTDOCFLAGS=-D warnings cargo doc (metal2vulkan, metal2vulkan-runtime);
- scripts/api-docs;
- the metal2vulkan-runtime and metal2vulkan-air suites: 1715 passed, 4 skipped;
- the device lanes on the M3 Max through MoltenVK (tile_states, compute_threadgroups,
tile_threadgroups, indirect_dispatches, indirect_executions, function_tables): 124 passed.
With the old answer put back, both new device tests fail ("left: 1024, right: 1" at 1x1x1).
No version bump and no pin here: they come at stacking.
(cherry picked from commit 94fbec600e2155fff4c05b88894155054569621e)
(cherry picked from commit 09be67cab1968bbadcc698456fb245ec6e94f20a)
|
||
|
|
e23bd582ca |
Name Feature::Constant in ConstantRecord's doc without a link
ConstantRecord lives in metal2vulkan-air and metal2vulkan re-exports it in its error module. Its
doc linked [`Feature::Constant`], which rustdoc resolves to the AIR crate's Feature. The
reference that scripts/api-docs renders does not document that Feature, so the link rendered as
bracketed text and the script failed ("links that did not resolve": error/index.html and
error/enum.ConstantRecord.html). The doc now names the variant in plain code. The constants-record
change that added the doc introduced this.
Verified: scripts/api-docs passes.
(cherry picked from commit 139b3b3d37b9eacb075189d3d7f47c72bd4e28c6)
(cherry picked from commit 24e85e53141c571acc78f402d42bbb279a253256)
|
||
|
|
7e48216b37 |
Make the canonical encoding's image scratch without zeros
What: under ExtendedRangeBlitPolicy::Canonical, a blit into a compressed BGRA10_XR or BGRA10_XR_sRGB image rewrites its texels through a scratch buffer: a copy out, one dispatch a region, a copy back. The scratch was made with Device::own_buffer, which zeroes a Private buffer in a submission's first work (a copy of the device's zeros on a device with unified memory, a fill on a discrete one), in a command buffer of its own. The copy out writes every byte the dispatches and the copy back read (the regions, tightly packed) and nothing reads the alignment gaps, so the scratch is now made with Device::unzeroed_buffer (Private, tracked as before), as shadow_merge's fully written scratch already is. Nothing the program or Metal observes changes; the work counts do. Why: the whole-set conformance cost check on the M3 Max read compressed-blits-bgra10xr and its sRGB twin over their records since |
||
|
|
209b375767 |
Pin the runtime sources after the GPU-time long mark
The queue-share change edits the runtime's completion and placement sources; RUNTIME_VERSION 1752 says the behaviour changed. Hash from the pin derivation over the listed runtime and translator sources. (cherry picked from commit 715f47be94b579e6ea954c544c8403137368a96f) |
||
|
|
c11497e7a3 |
Bump RUNTIME_VERSION to 1752: a queue is marked long by its command buffers' own GPU time
Adaptive VkQueue sharing now marks a queue long only when one of its command buffers' GPU timestamps spans more than 2 ms, and a device without readable, calibrated timestamps does not share (WorkCounts::queue_sharing_untimed). Placement, and so what a recorded run did, changes. (cherry picked from commit a460f320ebb3c1ef6ce8d983adeef9e9d0af39ca) |
||
|
|
7996b9a164 |
Mark a queue long by its command buffer's own GPU time, not the host's view of its head's age
What: a command queue is now marked long where one of its command buffers' own timestamps (its first batch's start to its last's end) span over LONG_HEAD (2 ms), in the completion turn that read them (CommandBufferShared::place_gpu_times), before the turn finishes it. The waiter's host-age check in command_buffer/completion.rs (HeadWatch, Device::head_watch) is removed, and went_long returns at once unless the device shares. A device whose command buffers write no timestamps the host reads (gpu_times_from_host, a driver whose timestamps wait for every queue's, or no calibrated timestamps) no longer shares: queue_switch_check::timed() gates the check, and recall settles Unchecked and counts the new WorkCounts::queue_sharing_untimed where the device has two VkQueues of one family to share. Two runtime extensions, doc-hidden, for the lanes and the probe: CommandQueue::vk_queue_sharing() (its VkQueue and long mark) and Device::shares_vk_queues(). Why: the host's view of a batch's age as its VkQueue's oldest also holds its wait for the GPU to start it and the waiter's lateness to see it complete, so short command buffers marked their queues long for good. On the RTX 5080 Laptop GPU, 2x3 runs in a slow stretch had each thread's queue marked long mid-run (at 20 ms to 1,238 ms) and settled apart, the PerQueue placement, at PerQueue's rates. Measured cause, with a diagnostic build printing each host-age mark beside the command buffer's own GPU span: beside another process's 30 ms command buffers, draws of 11 and 16 us of GPU time were seen 2.0 and 2.3 ms after they became their VkQueue's oldest, 1.8 and 2.1 ms of that before they started; that run's thread queue settled apart and ran at PerQueue's 4.1k. In the runs without contention, every true mark had a GPU span within 1.2 ms of its host age (the 30 ms command buffers and the probe's 2.7 ms sizing one); under contention the sizing command buffer's host age exceeded its span by 4.2 ms. Neither suggested alternative fits: the false marks came mid-run, not only in a queue's first command buffers, and decaying the mark after short heads would let the trap and alternating shapes' long queues rejoin and stall the compositor again. Tests: tests::queue_share_device gains a_device_that_answers_gpu_times_from_the_host_does_not_ share_and_counts_it (expected, not run, to fail without the gate on the 5080: there it printed "Unchecked ... could share: true", so the recorded Idles verdict would make it share), and asserts queue_sharing_untimed == 0 elsewhere; its isolation runs print each queue's VkQueue and mark over the run. The queues lane's a_queue_joining_another_s_busy_vk_queue_is_announced_once now makes its device under QueueSharingPolicy::Adaptive (over the lane's exact_answers()), lets the busy queue's fills be submitted first, and asserts queue_joins > 0 exactly where the device shares, saying why where it does not. cross_queue_shadows gains the signal-in-between and the waiting-writer cases on one VkQueue: no spin, Adaptive, the check settled, queue 2 joining queue 1's busy VkQueue; they assert the join, neither queue long, the hold still withheld while the waiting writer has not completed, and the bytes. Docs: QueueSharingPolicy::Adaptive, the FAST-PATHS row (the rule, the untimed exclusion, the new ranges), docs/API.md (the policy section and the notice), the queue-sharing notice's cost text, queue.rs and queue_share.rs; api_signatures blessed (additions only). Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, msi, under gpu-locks, no VM), release probe: - 2 threads x 3 in flight, 10 runs each in turn: Adaptive 48.3, 28.0, 50.7, 52.9, 28.1, 53.7, 48.6, 29.9, 31.5, 53.0k against PerQueue 21.4, 24.9, 27.8, 28.0, 27.6, 27.4, 27.1, 23.3, 26.9, 27.3k, Adaptive above PerQueue in each pair; no thread's queue marked long in any run (gone long 1 each: the probe's sizing queue). The 28-31k runs keep the shared placement, with waiter parks 0.23 against 0.02-0.05 per command buffer in the fast ones: a host-side mode, not a move. - Beside another process's 30 ms command buffers, 3 runs each: the old rule 4.1k (a thread's queue marked long by its host age), 5.2k, 6.6k; this rule 6.7k, 5.4k, 5.1k (no mark); PerQueue 4.1k, 4.1k, 4.0k. There, draws' own spans reached 1.16 to 1.52 ms (timesliced), under the bound. - Isolation, 3 runs each: trap and slow-alternating 64 completions over 10 ms under Adaptive (the one first-long stall, at most 26.4 to 30.1 ms) against none under PerQueue (at most 5.6 to 9.7 ms); alternating none under Adaptive (at most 5.7 to 9.8 ms) against 7, 0, 0 under PerQueue. Unchanged from the host-age rule's runs. - 8 threads: 3 in flight 53.4k, 54.4k against 27.8k, 27.4k; 1 in flight 50.1k, 49.3k against 14.0k, 13.9k. - Device tests (debug, --cfg m2v_gpu): tests::queue_share_device 8/8, the joining lane test and cross_queue_shadows 7/7 (the one-VkQueue cases: X's and Y's queues both on VkQueue 1, neither long, holds withheld 2, gated copies in 2). The compositor isolation test, old rule and new in turn, 3 each: p99 2.66-2.94 ms against 2.16-2.83 ms, 0 stalls, the same placement (the compositor alone on VkQueue 1, the application long on VkQueue 0, gone long 1). Its one earlier failure under this rule (p99 7.93 ms, 20 stalls, 5,579 of ~9,600 commits made) ran right after a 74 s compile inside the hold, with the same placement and gone long 1: host load, not the rule. On the M3 Max (MoltenVK, no sharing), tests::queue_share*, command_queues, cross_queue_shadows, gpu_time and host_memory: 90/90. clippy -D warnings plain and --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc; fast_paths, degradation*, api_signatures, api_surface, work_counts pass. No RUNTIME_VERSION bump or pin here. (cherry picked from commit 4fd88b7564cd9cd3651543bb3f8cd529b021709e, two claims corrected to what was run) (cherry picked from commit eb0153e9d0fe6d272f2411c65f0a1ecda2c78bc2) |
||
|
|
3e55a67849 |
Re-measure the C3 reference under this host's toolchain: Xcode 27B52, metal 32023.922
The M3 Max's toolchain moved from Xcode 27A266a (metal 32023.921) to 27B52 (metal 32023.922) on macOS 27.0.1 (26A434). corpus-metal refuses to record under an identity the reference list does not declare, so the list moves to the new toolchain and every committed authored case is qualified again on Metal under it. What changed: - cutover/c3-references.json names xcode_build 27B52 and metal_toolchain "Apple metal version 32023.922 (metalfe-32023.922.4)". The device, GPU cores, OS and OS build are unchanged. - corpus/observations/metal holds one fresh apple-m3-max-macos27.0.1 row for each of the 2263 committed cases. They were measured through the indexed path (corpus-metal --batch, default jobs, under the Mac GPU lock) and installed with corpus-metal --batch-install, the store's validated write. No other environment's row moves and no slot goes away. The re-measured rows were compared field by field with the committed ones, leaving out only the environment identity, oracle_abi and timing: - 2259 are equal in every field: 2249 against the old reference row, and 10 against the local-metal row of a case that had none. - 4 cases had no row and now qualify (the msl-4-1 atomics cases). - 0 changed status. 2263 rows carry the new identity: 2259 qualified and 4 reference gaps (GPUFamily10 simdgroup_matrix 16x16), as before. One case needed a second run: 81c239f3…, "tile-threads-8x8-in-a-16x16-tile-take-their-places". In the batch, Metal refused it twice: "Metal tile dispatch asks for 64 threads a threadgroup ([8, 8, 1]), but the pipeline permits 16". The cause is Metal's pipeline cache, not the toolchain. A tile render pipeline with threadgroupSizeMatchesTileSize off, compiled for the first time, reports maxTotalThreadsPerThreadgroup as the product of its requiredThreadsPerThreadgroup (8x8 gives 64). A later pipeline of the same function that differs only in that size gets the first one's value, in the same process and in later ones. In the batch, the 4x4 case of the same fixture (16 threads) ran before the 8x8 one. A from-scratch kernel compiled at run time with a salt shows the same thing under 32023.921 and 32023.922, so the old toolchain behaves the same way. Run alone, the case qualifies with output 188e2242…, equal to its recorded row, in all six runs since, across two builds, two environments, and single and batch mode. Its row here is such a run. A bug report draft with the from-scratch kernel is staged outside the repository, in the orchestrator's bug-drafts folder. No validation test or case-index entry reacts: no status changed. Verified: the whole metal2vulkan-validation suite (1363 passed, 4 skipped) with the list and the 2262 batch rows installed. Then, after the tile row, its case, observation, store, reference, corpus and census tests (cargo nextest -E 'test(/case|observation|store|c3|reference|committed| corpus|cutover|census/)'): 405 passed. (cherry picked from commit 175d5f044aa526850b469ccfdb7758b36c442463) (cherry picked from commit b1fe02a98c37ef685ab933426bb166258e27852c) |
||
|
|
26ee8643da |
Re-bless the authored compile census: 10 new cases, artifacts at this build
The census on development
|
||
|
|
ee3b71ee64 |
Record the command recorder's sharded counts in the signature table
The recorder's commands! macro now reads per-thread shards (CommandsRecorded::read takes &[Shard; SHARDS] and each thunk counts into its thread's shard). The draw-fast commit that made the change left the table's record of the macro body at the single-array form, so the_public_signatures_are_the_committed_table failed on the stack. Verified: signatures.py --check passes after --bless; the diff is that one record. (cherry picked from commit 6c9d152e28a4057ddcd577d4876711a240a985d5) |
||
|
|
3684e795d8 |
Pin the runtime sources after draws rebound after buffer, texture and sampler binds
(cherry picked from commit cc91867c8a204aadfb14acf3099a584398388293) |
||
|
|
9d058c707a |
Bump RUNTIME_VERSION to 1751: draws rebound after buffer, texture and sampler binds
A run of an unchanged artifact and plan may now record other commands' timing and take other steps than before. A render encoder's direct draw that repeats its last one, after calls that bound other buffers, offsets, bytes, textures or sampler states at slots of its tables, rewrites those slots alone (render/draw_again/rebound.rs; WorkCounts::draws_rebound). It has the same commands, set-0 writes, dynamic offsets, push bytes, vertex buffers, uses, barriers, notices, refusals and retains as the draw taking every step, and records only the state commands that changed before its draw. A draw after a sampler state is made or released takes every step, as its kept draw read the device's sampler listing. Draws again and rebound draws count into per-thread shards as they record. 1751 is the lane's 1750 (shared linked pipelines) plus one. (cherry picked from commit 5f9d5720885ec8d303e703b76aac416cbd5964bf) |
||
|
|
df7b5d3310 |
Count the stage tables a rebind brings in where it reads them
A draw after calls that changed its tables brings the changed slots into the kept draw's bind state (rebound::bring_in) and marks the tables read, before it decides whether it is rebound. The draw rebound counted those reads (stage_tables_read and stage_tables_read_in_part), but a draw that then took every step did not: its rebind stopped (a slot it cannot rewrite, a changed shape), or it was the draw rebound that the debug check takes every step of. Its every step found the tables read and counted nothing, so the device's counts left out reads that happened. bring_in now counts the tables it reads in part as it marks them read (Counters:: tables_read_in_part), whatever the draw does next; draw_rebound counts the draw alone. This is what runtime_lane::draw_work's a_draw_reading_its_tables_in_part_brings_in_each_setters_slot, draws_read_only_the_stage_tables_a_call_changed and draws_reading_a_no_copy_buffer_s_binding_look_where_it_lies_once measured short on the M3 Max with debug assertions: 2 of 13 reads in part; no read where a bytes call changed 1 or 2 tables; 4 of 7 reads. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions: those three lanes pass, among the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage, shadows, attachments, executions, degrade_notices), 288 of 288; the runtime's whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes:: commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns). Clippy over the workspace, plain and --cfg m2v_gpu. (cherry picked from commit d8ceaa4b35d66283e8e13ffb91d919528b72b788) (cherry picked from commit 198956b1362eadd9d71bed11dbfb2f31440c437d) |
||
|
|
df985fbacb |
Check a draw again against its every step by digests: the check allocates nothing
In builds with debug assertions every second draw again (and rebound draw) takes every step and checks it against what the draw again would have done. The check boxed itself (Again::Check's Box<Checked>) and cloned what it compared: the drawn areas and coverage, the pass's reads and the instance's gathered uses (HeldReads, HeldGathered: copied lists), the noted uses, the pass's input and extended sets, and of a rebound draw its commands, set-0 writes, offsets, push bytes, vertex buffers, uses and resident keys. Those allocations count in the frame lanes' draw allocations, which CI runs with debug assertions: runtime_lane::frame_costs' a_frame_s_draws_and_pass_ends_allocate_within_their_bounds measured 22.30 allocations a draw on the M3 (bound 20) once draws rebind. Each part is now compared by a digest of its Debug form, streamed into a hasher through a fmt::Write adapter (draw_again::digest), which copies nothing. The encoder's held state is taken only for a plain draw again (Expected::Plain; a rebound draw's check compares what it worked out, Expected::Rebound). Checked is no longer boxed: the draw path hands draw_again an Option<Checked> on its stack, which kept_again takes as before. pass_start_reads::held and shadows::gathered lend their lists rather than copy them; binding::Info and NotedApart print their Vulkan values raw (ash's types print nothing without its debug feature). Release builds are unchanged. No bound changed. Measured on the M3 Max (MoltenVK 1.4.2), with debug assertions: that lane's draws make 18.21 allocations a draw (was 22.30; bound 20); a pass end 15.67, a pass open 5.00. Negative control: with binding::rebind_into's image descriptors left as they were (the rebind's texture path broken), tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds fails with "a draw rebound worked out other set-0 writes than its every step". Verified there, --cfg m2v_gpu, on a tree that also held the next commit's change: the runtime's whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes:: commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime lanes listed in the last commit, 288 of 288. Clippy over the workspace, plain and --cfg m2v_gpu; release builds check clean. (cherry picked from commit 1b8e52fe2f58f01df507d4f9b345dcb901c16ca2) (cherry picked from commit 838786566146858e00b579ebc78240353fa87061) |
||
|
|
6980b529dd |
Count draws again and rebound draws as they record, into per-thread shards
A render encoder's draws again and rebound draws added their counts to the device's only at the encoder's next call that forgot the kept draw, or at its end (draw_again::Counted), so that no draw took a shared atomic add: draws_as_before, draws_rebound, commands_noted_as_before, draws_pushing_set_zero, provoking_last_pipeline_draws, the stage tables they read in part and the state commands and set-0 writes they recorded. A reader of WorkCounts between draws saw none of them. Those counts, and the other counts the draw paths add per draw (stage_tables_read and _in_part, draw_states_recorded, set_zero_writes_pushed), now live in per-thread shards: shards.rs holds the recorder's shard scheme, moved out of recorder/thunks.rs, and a generic Sharded<T> of 16 shards on 128-byte lines; each thread adds into its own shard (threads past 16 share them in turn) and WorkCounts sums them. A draw counts as it records: one thread-local lookup, and atomic adds on a line no other thread writes. The deferral and forget_again's flush are gone; the WorkCounts docs no longer say the counts wait for a call. Checks: tests::draw_again::draws_again_and_rebound_count_as_they_record reads draws_as_before and draws_rebound before each draw, with no call between but the binds a rebound draw takes; under the deferral every read is 0. tests::recorder_shards::a_sharded_count_is_every_thread_s_additions sums 19 threads' additions over the 16 shards. Cost, M3 Max, release host_ab encode, one session, per draw (instructions retired and cycles over 23 passes of 10000 and of 30000 draws), before -> after: - draw_static (draws again): 2018 instr, 450 cycles, 0.110 us -> 2042, 639, 0.115 us; - draw_offset (rebound draws): 12452 instr, 2376 cycles, 0.554 us -> 12357, 2442, 0.563 us. The same within the runs' spread: a draw's adds land on its thread's own line. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that also held the next two commits' changes: the runtime's whole suite, 1545 of 1546 passed (the one failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage, shadows, attachments, executions, degrade_notices), 288 of 288. Clippy over the workspace, plain and --cfg m2v_gpu; the runtime's Rustdoc. (cherry picked from commit c26838fdd2abe5bcaa5e3ecb2ed9477721b017dc) (cherry picked from commit 643246f591c39b40c0d7d00f68f8768457673bdf) |
||
|
|
85c6c786d0 |
List the rebound draw's kept recording among the modules that keep device functions
A kept draw's recording (rebound::KeptRecording) holds its index bind (draw_source::IndexBind), which keeps the device's sized index bind command where the device has it. The exit guard's tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions lists every module that keeps a copy of the device's functions with why it may, and failed on the unlisted render/draw_again/rebound.rs. It is listed: the recording is held by its encoder's bind state (a spare one by the device's, which the teardown ends) and recorded again only by the encoder that kept it. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that also held the next commits' changes: the runtime's whole suite, 1545 of 1546 passed, this test among them (the one failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, 69 wakings over 68 sleeps, passed 10 of 10 reruns on the same tree). (cherry picked from commit 921cfd22688850e5392ee455dec82c27cdeb1234) (cherry picked from commit 383e74af1eaf0aceb4e600d5502f6a408c9c1517) |
||
|
|
3a8b56ecc7 |
Take every step of a draw after a sampler state is made or goes: its kept draw read the listing
Every step of a render draw lists the device's live sampler states again where their slots changed since its bind state listed them (LiveBind::listed_at, Device::sampler_slots_changed). The listing goes into the bind state and so may change its shape. A draw again, and a draw rebound, took the kept draw's bind state as it was: after a sampler state was made or dropped between two draws, they skipped the listing and the reshape that every step would make. The kept draw's Under now holds the count of the sampler IDs' slots' changes. A draw under another count is not the kept draw again and takes every step. The count is one Acquire load a draw, with no read-modify-write. Check: runtime_lane::draw_work::draws_take_the_device_s_sampler_states_only_where_they_changed (draws rebound after set_vertex_bytes: a state made before column 3's draw, gone before column 6's). With the bind tail and without this, the M3 counted [0, 0, 1, 0, 1, 0]: the listing came one draw late, at the debug check's draw that takes every step. The test expects [0, 1, 0, 0, 1, 0]. (cherry picked from commit d8bf1bcf383b7e746916d8f0dbbf769e0a60d4ae) (cherry picked from commit 1a2b148ba4145da26a456ea52b6fc249b14aaeb4) |
||
|
|
50b41ecc54 |
Draw the kept draw again rebound after texture and sampler binds too: rewrite those slots alone
A vertex or fragment texture or sampler bind forgot the encoder's kept draw, so a draw after one
took every step: the compositor shape (a buffer and a texture bound before each draw) never
reached the bind tail.
Now:
- Texture and sampler binds keep the kept draw (log_keeping), as buffer binds do; the next draw
compares the tables' stamps.
- BindingPlan::rebind_draw_slots_into (was rebind_draw_buffers_into) takes buffer, texture and
sampler slots. A texture or sampler slot decides none of the commands. It answers Ok(false)
for a texture buffer's texel range and a YCbCr texture's planes.
- binding::rebind_into writes a changed texture's or sampler's image descriptor as bind_into
does (image_descriptor, through the encoder's memo, its samplers kept for retaining). It
answers Ok(false) for a changed texel buffer, YCbCr image or argument sampler.
- The draw rebound brings in texture and sampler slots and stops where every step would differ:
- a memoryless texture its functions use (the full path fails the command buffer there);
- runtime samplers' address modes other than the kept draw's;
- a changed shape (a sampler of other addressing, which the pipeline's specialization
reads, takes every step);
- a plan that samples or writes a color attachment's texture;
- an extended-range shadow.
It retains the new samplers and notes whether its uses read an image (Kept::reads_images).
- Docs: rebound.rs, WorkCounts::draws_rebound, docs/API.md, api_signatures.tsv.
Check: tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
(tob_sample). It covers another texture each draw, another sampler of the same shape, both,
and samplers of other addressing. It checks rebound counts (0 for the last), commands, state
commands, noted uses and pixels against every step, with the debug cross-check on every second
hit. It fails without the change (0 rebounds). The buffer test's slot-of-another-class case is
now more slots than a draw rebound takes (samplers 0 to 8). Passes on the M3 (MoltenVK) with
the draw_again tests; clippy clean, plain and with --cfg m2v_gpu.
(cherry picked from commit ecf97956b214836a1309affe539aff8454239e97)
(cherry picked from commit 8472edf4c0ae174c3dab7bc667cecfa6874aa942)
|
||
|
|
01f40bb3f4 |
Hold a render encoder's current instance in its lowering's box: a pass open makes no box of it
1aaf95c79f boxed the current instance (1656 bytes) so that the encoder's moves at its pass end carried a pointer. That made one more allocation at every pass open, on every device: runtime_lane::frame_costs::a_frame_s_pass_opens_allocate_within_their_bound measured 6.00 a pass open on the M3 (bound 5.5) and 5.00 on NVIDIA (bound 4.5). The instance now sits unboxed in the RenderLowering, which is already boxed once where it is built. end_pass lists the pass's instances in the earlier instances' vector, the current one pushed last, in place of a vector of boxes; a split still boxes the new instance it hands back (Next::New) and unboxes it into its place. OPEN_ALLOCATIONS' doc says where the instance lives. Not done: keeping the emptied instance box in the draw room. end_pass moves the first instance's pieces, earlier steps, shape, positions and kept commands out to the pass's steps, so keeping its box would need placeholder moves or a change to how long the steps live. Verified: builds (cargo check, all features); the frame_costs lane runs next on MoltenVK. (cherry picked from commit e4fb5fcd47c4a3bd97e1ef9a021d3c466291ac19) (cherry picked from commit 15c0626814a8e8e75c30c105c1a69f7f8dd3ea0e) |
||
|
|
d6302220bf |
Count recorded commands in per-thread shards: threads that record at once write apart
The recorder counted each command with one relaxed fetch_add into a single array per device slot, so every thread recording at once wrote the same cache lines. On the 5080 a draw drawn again (a Vulkan draw alone) cost 0.060 us of thread CPU on one thread and 0.232 us on eight. Each slot now keeps 16 shards of its counts, each aligned to 128 bytes. A thread takes the next shard at its first count (a thread-local, one fetch_add per thread, not per command) and keeps it; threads past 16 share them in turn. WorkCounts::commands_recorded reads the sums, so the counts mean what they meant. Measured on the 5080 laptop (host_ab threads, 10000 draws, 32 timed passes, one round, under the GPU locks, SCHED_OTHER), landed tip vs the bind tail plus this (a static draw takes no part of the tail): - draw_static, one shared state, thread CPU us/draw at 1/2/4/8 threads: 0.060/0.092/0.149/0.232 -> 0.065/0.062/0.059/0.065; Mdraws/s 16.9/21.1/25.8/30.9 -> 14.1/30.8/49.7/87.8. - draw_static, a state per thread: 0.061/0.099/0.126/0.202 -> 0.058/0.062/0.059/0.062; Mdraws/s 16.2/19.9/31.0/35.1 -> 18.7/32.6/59.8/94.6. Check: tests::recorder_shards::threads_count_into_shards_of_their_own (as many threads as shards each count apart, and the next shares the first's): passes under nextest. clippy clean. (cherry picked from commit 43ac1c48e746d592055aa5e0606cf79e8ebaedd7) (cherry picked from commit ada254765fb0a09294b03a1ad17428a111c8192b) |
||
|
|
e3f2c95dfe |
Draw the kept draw again rebound: after buffer, offset or bytes binds, rewrite those slots alone
A render encoder's kept draw (render/draw_again.rs) drawn again after calls that bound other
buffers, offsets or inline bytes at vertex or fragment buffer slots now rebinds only those slots
(render/draw_again/rebound.rs, WorkCounts::draws_rebound), where it took every step of a draw.
- Translator: BindingPlan::rebind_draw_buffers_into(state, slots, commands) writes again, over
the same draw's commands of a state of the same shape, only what the buffer slots decide: their
descriptor ranges at their places, the SlotBindOffset, SlotGuestBase and pulled-stride push
fields that read them, and their vertex buffers' offsets. Ok(false) for a device-address slot,
an argument or root table, a per-bind stride's vertex binding, a mesh, patch or de-indexed draw,
or a uniform view a written slot may alias. docs/API.md says so; api_signatures gains it and
WorkCounts::draws_rebound.
- Runtime: buffer and bytes binds keep the kept draw (log_keeping); the draw compares its tables'
stamps with the kept draw's. On a difference, the tables' changes since (argument_table::
changed_since: buffer slots alone, at most 8) are brought into the kept bind state
(refresh_changed), and the draw goes on only where its shape stays, its variant and plan then
the bind state's kept settle (LiveBind::settles_kept). It rewrites the commands
(rebind_draw_buffers_into), set 0's writes and dynamic offsets (binding::rebind_into), push
bytes and vertex buffers, and its uses whole (command_uses_into), and takes the checks a draw
takes of them: a pulled attribute's reach, the stages' function tables, the attachments' reads;
it stops at a pass whose fragments wrote memory, a shadowed texture among its uses, a barrier
its fragments need after earlier geometry writes, or a detached buffer. It records with set 0
as any draw finds or writes it (EncoderCore::set_zero_of), its uses noted as any draw notes
them, through the kept draw's recording parts against what its command buffer holds; a notice
met at each occurrence forgets it once recorded, as every step does. The kept parts (set-0
writes that hold no keeper, dynamic states, the rest of its recording) live in the bind state's
storage (LiveBind::kept), filled at the keep alone: a draw that takes every step pays one
KeptStorage::keep and nothing per recording.
- Checked in builds with debug assertions: the first rebound draw of a kept draw and every second
after it take every step instead, which must keep the draw, with the same commands, set-0
writes, dynamic offsets, push bytes, vertex buffers and uses.
Tests: tests::draw_again::draws_after_buffer_changes_rebind_what_every_step_binds (MoltenVK, M3):
draws after offset and bytes changes rebind (draws_rebound == the draws again but those the check
takes), with the same commands of every kind, state commands, noted uses and pixels as the same
draws each taking every step, every draw at its own offset and color; a sampler bind between them
takes every step. Negative control: the translator not rewriting a changed slot's range fails it
at the cross-check ("other commands"). metal2vulkan's tests::engine_graphics_binder rebind test:
1360 rebinds over stage-io plans equal a full instantiate, and its negative control fails.
host_ab encode, release, 10k draws per command buffer, us/draw, offset case (one
set_vertex_buffer_offset before each draw), measured on this change before its last revision
(which moved the kept parts' fill from every full draw's recording to the keep and dropped three
Arc clones a keep; its own numbers come with the next landing):
Apple M3 Max, MoltenVK 1.4.2, three interleaved rounds (median / mean of round p50s / max p90):
lock fix 1.561 / 1.550 / 1.591 -> 0.550 / 0.548 / 0.592
RTX 5080 Laptop GPU, thread CPU per draw, host_ab threads workload, one thread:
lock fix 2.006 (shared PSO), 2.001 (own) -> 0.541, 0.585; on 8 threads 10.3 Mdraws/s (was 2.9)
The unchanged draw (static) holds: 0.044 -> 0.046 on the M3.
(cherry picked from commit 2ee3520ff104094afde523e2eebf7bc8a9a9626d)
(cherry picked from commit d00975ea7da92da4886a29f1ebda6397f64202b1)
|
||
|
|
658e5ced81 |
host_ab: the compositor stand-in, passes of 300 draws each binding its own buffer and texture
The encode workload's `draw_compositor` variant draws as a window server's frame draws: render passes of 300 draws (the first clearing the target, the rest loading it), before each draw another vertex buffer and offset and another fragment texture bound (as `draw_bind`), and every run of 10 draws drawn by the next of three pipeline states reused every frame: the two textured states (`quad_vertex` + `textured_fragment`, without and with blending) and a solid one (`quad_vertex` + `icb_draw_fragment`, blending, which reads no texture), the Scene's new `solid`. It stands in for the shape a guest compositor's main command buffer takes during a window drag: a few hundred draws a pass whose buffers and textures change between draws, its pipelines the same across frames. Per draw: the encoding thread's wall time and the process's CPU time, as every encode variant. Verified: the example builds (release) on the M3 and runs its variants; its numbers come with the commits that measure against it. (cherry picked from commit 89cd071b0d416127c483900ccbbcabee04dc6fa0) (cherry picked from commit f4d394f7d12a12f937e455f52ec6b5f3ce7b53f0) |
||
|
|
9ec100ba7c |
conformance cost: RACY holds 38 rows with linked_pipelines_shared beside commits_taken_in
Two commits each added one row to the racy-count table from bases that held 36 (the shared linked pipelines' linked_pipelines_shared, and the taken-in wait's commits_taken_in); the cherry-pick kept one length, so the array's stated length was 37 for 38 rows and the conformance crate did not compile. Verified: clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings clean. (cherry picked from commit 357a76f214273dd25e3caa905336fce7b7548135) |
||
|
|
14a73185a2 |
Pin the runtime sources after the empty fresh log's skipped lock and the warm budget's docs
(cherry picked from commit 0222da037d4a9883995cf96dd7645081ad3f00ab) |
||
|
|
d07650b362 |
Warm passes: judge the byte budget on every device, and say what pipeline_bytes counts
What: tests::warm::a_byte_budget_stops_the_pass no longer skips its 1-byte leg when the pass counted no driver bytes. That leg runs over a directory of its own, which holds none of the records' driver data, so it now asserts that the pass wrote records' data (driver_saves > 0), counted it (pipeline_bytes > 0), and stopped after the first record, on every device. A new test, a_pass_over_its_records_own_directory_counts_only_what_it_writes, warms records over the directory whose creations made them and asserts that the pass counts driver bytes exactly where its makings wrote data. Where it wrote none, it asserts that a 1-byte budget stopped nothing. WarmStatistics::pipeline_bytes, Device::warm, the runtime README and docs/HOWTO.md now say that a making whose data the directory holds already adds nothing. Over that directory the budget binds only where a making writes new data. Why: the consumer read pipeline_bytes 0 on every boot of the RTX 5080, though the warm pass made 248 pipelines, and asked whether the counter is broken there (a making's keep on a thread without the pass, or a path that never keeps). Measured with a scratch diagnostic at 1bb0b87a5a, not committed: - RTX 5080, a fresh directory: 23,800 bytes counted, 3 records' data written. - The 5080 over the records' own directory: 0 bytes, 0 written, 2 unchanged, 2 found. - M3 Max on MoltenVK 1.4.2: 13,362 bytes and 3 found respectively. So keep() runs on the pass's thread and counts on NVIDIA too, and the consumer's 0 is the true value. Their records come from the boot before, over the same directory, whose creations wrote every making's data. The old test's skip branch could have hidden a broken counter; now a pass that writes data and counts none fails. Verified: tests::warm on the M3 (MoltenVK 1.4.2), 6 passed. The 1-byte pass over a fresh directory counted 8,003 bytes with 1 record's data written; the pass over its own directory counted 0 bytes, wrote 0 and found 3. cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc clean. The RTX 5080 run is in the hand-over. (cherry picked from commit 83cc2dbe6fb610c6ad59a741a7170812611cf703) (cherry picked from commit 1d43003372f23275ceb7fcc463a34abedbeff9a7) |
||
|
|
376d835a4f |
Take no lock of a command buffer's fresh-texture log at a commit that logged nothing
What: FreshLog keeps a flag, set where FreshLog::add pushes an event. FreshUnwritten::commit returns before it takes the log's lock where the flag is clear, as it already did where no texture is noted. A commit that logged something takes the log as before. Why: host_ab percall's commit rows failed on gate/stack11: commit_one_dispatch 5 allocations a call (held to 4) and commit_no_copy_dispatch 10 (held to 9). e3b963bdc0 measured 4 and 9 on 9f56956ef3, before the pattern reads moved to the commit (95d7bdf6dc). Since then, while any noted texture is live in the process, every commit locks its command buffer's FreshLog mutex, in these rows for the first time: their dispatches bind only buffers and log nothing. On macOS a std Mutex makes its pthread mutex at its first lock, one allocation (Rust 1.98.1 on the M3: 4 allocations for the first locks of 4 new mutexes, 0 for the second locks). The trace put that allocation in FreshUnwritten::commit, the fifth of the commit's sites. The other four (Predication::end_unit, close_tail, the BatchSync list, gate::Hold::new) are the ones the rows were measured with. Verified: - host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2), on 4f0a1043b1 with this branch's two commits before this one, the gate made to print: commit_one_dispatch 4 and commit_no_copy_dispatch 9 allocations a call (stack11 with those two commits: 5 and 10). No row of the gate fails in that run: end_render 24, end_compute 7, end_blit 7, heap_texture_256 17.25, the draws 0.0390625, dispatch 8.13. - The traced commit_one_dispatch lists Predication::end_unit, close_tail, the BatchSync list and gate::Hold::new, the four a trace of 9f56956ef3 lists, and no FreshUnwritten::commit. - tests::fresh_unwritten (8), tests::tracker and tests::heap pass under --cfg m2v_gpu on the M3 Max (93 of 93). - cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, plain and under --cfg m2v_gpu: clean. The rows already hold the counts this restores, so the gate itself is the check: it fails without this change. No answer, announcement or submission changes (a log with no events gave the record nothing), so RUNTIME_VERSION stays; the runtime sources' pin moves with fresh_unwritten.rs. (cherry picked from commit b878f5b569662b4fcf45c23ef84e619e5e212ea6) (cherry picked from commit 6c70d5b7e01a874aa2cfde501b024cea394209d4) |
||
|
|
a977bbbe45 |
Pin the runtime sources after shared linked pipelines and the small encoder parts' stack order
(cherry picked from commit 873c932fa849d07da1d3d9186412d8044042c39c) |
||
|
|
e6f3c91973 |
Bump RUNTIME_VERSION to 1750: render variants of one link share its linked pipeline
A run of an unchanged artifact and plan on a device that links pipelines from libraries now takes the device's linked VkPipeline for a render variant whose four libraries and pipeline layout equal one already linked (a content-keyed map; WorkCounts::linked_pipelines_shared), where it linked a duplicate before; teardown drains the links before the libraries. Elsewhere nothing changes. Encoder ends order a small part's resources on the stack and a heap texture asks whether a shadow fits only where its images do not, which changes allocations alone. 1750 is 1749 (commits taken in) plus one. (cherry picked from commit 2d9d5868bce2b1ddc1b46bf15d0901f320e6ffd3) |