85b896a7e10abe3ea529efc611f8dfd29ea39b4d
98
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
21fa95cbdd |
host_ab percall: hold a dispatch to 6.2 allocations, what it makes now
With a dispatch's uses made over the last dispatch's storage and its group counts listed only inside a predication unit, the gate's dispatch group makes 6.13 heap allocations a call on the M3 Max (MoltenVK) where the row held 8.2 (8.13 measured at the 11-03 re-bless, 10.16 at a1ca5c673f). The row moves to 6.2, so the two allocations cut stay cut. (cherry picked from commit fba5723eb6360658aecf6667516430d588641176) |
||
|
|
812c4c1d10 |
draw_costs: a clips shape, a compositor's draws between scissor rectangles
The restated cut keeps the kept draw across render state sets, but no draw_costs shape set any: ws, many and 10k set only buffers, textures, samplers and pipeline states, so they time the cut's overhead and none of its gain. clips is the 780M glass drag's mix of gaps (main's setter histogram): every draw a vertex buffer at the next slot; every second one a scissor rectangle before it (the target's top half, then its bottom, in turn); every 4 draws instead a pipeline state switch with its sampler and a texture. 8 command buffers of 500 draws, as ws. set_scissor_rect is counted apart under --calls. Verified: cargo fmt; built and run in the branch's A/B job after this commit. (cherry picked from commit de82ba3ff84724dbb8c468869b0e89720261f68f) |
||
|
|
0d66b9de2b |
with_vk_queue: the closure gets the VkDevice its VkQueue belongs to
`CommandQueue::with_vk_queue` now calls `f(&ash::Device, vk::Queue, u32)`. The device is the serving generation's, read under the queue's lock with the VkQueue. After a recovery the queue lends the new VkDevice's VkQueue. Until now a caller could get the device only from `Device::raw` handles it had cached, and after a recovery those name the lost VkDevice. The consumer's copier did exactly that: it submitted command buffers from a pool made on the lost device to the new device's queue, and the process died inside RADV (a segfault at null+0x50 in libvulkan_radeon.so, right after our "VkDevice was lost and made again" log). No call let it see the change atomically. Every call site in the runtime, its examples and the validation lanes takes the new argument. The runtime README's interop and "A lost device" sections, `Device::raw`'s docs and docs/API.md's device-recovered entry say what the closure gets. api_signatures.tsv is re-blessed (one signature changed). Test: device_recovery::a_lent_queue_names_the_vk_device_it_belongs_to_across_a_recovery. It reads the lent queue's device before and after recover_for_test. The two differ, and the second equals what Device::raw answers after the recovery. The test also asserts the old route is wrong: the raw handle cached before the recovery differs from the lent queue's device after it. That cached handle was the only source of the device under the old signature. (cherry picked from commit b4bf228df9db98a451c997f350c6014b027f7e31) |
||
|
|
a06c5f123c |
Keep a device's coverage query pools as spares instead of one made and released a pass
The Iris Xe A/B (job 7439) put the coverage queries at about 15% of the GPU time of snapshot_crossover's private passes, with the same forms as the build before (q scratch against ctl, and tip against ctl where they took the same form), while the area lane (one command buffer a frame, waited for) showed 0.2-0.5% and self_reads 2%. The crossover commits four command buffers back to back, so each pass's pool was released while the next pass ran on the GPU. A device now keeps up to 16 pools no pass holds (render/coverage.rs SparePools): a pass that measures a reader takes one, reset on the host, and gives it back as its command buffer completes; a pass makes one only where none has come back. Released as the device ends. Counted: WorkCounts::coverage_pools_made; tests::learned_coverage asserts at most two pools over its seven passes. (cherry picked from commit f1e328796c8218553c5834e4044a71bdebaf9be5) |
||
|
|
26d00a396c |
Weigh a reader of its pass's color by what it covered in its last measured pass
The area rule weighs a reader through no scissor at the share least favourable to each form, since a draw's recording cannot know what it covers. A 1280x720 or 1080p reader covering the whole target therefore took the snapshot, 1.97-2.34x the split's GPU time on the Radeon 780M, while the consumer's readers over 3% of a 3662x2039 target need the snapshot (Iris 12.8 -> 1.7 ms a frame). Both shapes weigh the same at recording, so no static rule serves both. Now, on a device with occlusionQueryPrecise that resets queries on the host, each reader the rule would weigh records its drawing commands inside a precise occlusion query of its pass's own pool (render/coverage.rs). As the command buffer completes, the count is kept on the reader's first color's texture, keyed by the pipeline state and the reader's place among that state's readers of the texture in the pass. Later passes weigh that reader at its count: the snapshot where SNAPSHOT_PIXEL_COST per covered pixel per color costs no more than the split's copy. A device without precise queries or host reset, a reader inside an app's visibility query (already refused the snapshot), a pending pipeline's draw and a replay record no query and keep the area rule. Instances recorded inline after a split keep the query's begin and end with their draws. Both forms are exact; a stale count costs the form it chose until a pass after the change completes. Counted: WorkCounts::coverage_queries and reading_draws_by_coverage. The crossover lane runs each cell once untimed so its timed frame is weighed by the learned count. Tests: tests::learned_coverage (forms and bytes across a sparse -> whole -> sparse change; an app's Counting visibility query keeps its count with a reader inside), coverage unit tests. (cherry picked from commit 1108cd1bdebfb15f9da91b39ed80d91d8624bc28) |
||
|
|
e5c37ecc62 |
Read a self-read through a snapshot of a color's own image where its image lacks STORAGE, pinning the instances through it
On the Iris Xe (m3-max-5702, the self_reads lane) a surface in place over host pages split every reading draw: 30 splits a frame, 224M texels copied in, 19.5 to 26 ms of GPU a frame, where its shadow took the snapshot (4.2 to 4.8 ms). Its image lacks STORAGE (the device's check failed storage writes over its pages), so snapshot_wanted fell back: a later framebuffer fetch of the color would render it through a stand-in for the whole pass, copied in before the pass, which a snapshot draw reading the texture's own image would not see. A draw now reads such a color through a snapshot of its own image all the same, pinning it (RenderLowering::pins_own_attachment), where nothing the pass's end decides from the whole pass changes what the instances through the draw render: the pass's first instance recorded inline, no stand-in, memoryless color or depth/stencil attachment in the pass, every color stored Store, no tile dispatch, execution, color groups or extended-range shadows, a draw that fetches nothing and needs no hidden depth. A stand-in arriving after a pin freezes the pins (no later draw pins), and the pass's end then renders the instances through the last pinned one with the colors' own images, takes each stand-in's copy of its attachment after the last of them (and a merged color's keep after that copy), keeps the reloads after them alone and joins no run of passes: as after an instance recorded inline (render/inline_first.rs). Counted: WorkCounts::reading_draws_pinned, WorkCounts::stand_ins_after_pins. Tests: tests::self_read_storage: a private target without STORAGE pins its first pass's reader and then takes its storage form; a pass whose pinned reader is followed by a fetch of the target keeps the reader's pixels and halves the fetched ones (a stand-in for the whole pass would leave the reader the red before the pass). The self-read cost lane (runtime_lane::attachment_read_costs::self_reads) prints the readers pinned per frame. Verified: - Iris Xe (ANV, Mesa 26.2.6), m3-max-6011: tests::self_read_storage passed both. A private BGRA8Unorm target without STORAGE gave (splits, snapshotted, pinned, stand-ins after pins, storage forms) = [0, 1, 1, 0, 1] in its first pass and [0, 1, 0, 0, 0] in later passes. A fetch after a pinned reader gave [0, 1, 1, 1, 1] in pass 0, with the reader's pixels the pass's red and the fetched ones halved. - lavapipe takes no snapshot path. There, both tests check the split branch ([1, 0, 0, 0, 0]); 193 filtered lavapipe tests passed in m3-max-5964. - Clippy plain, --cfg m2v_cpu_icd and --cfg m2v_gpu, and rustdoc -D warnings, for runtime and validation: clean (m3-max-5964). - The Iris lane frame: the device's render-target check now fails over host pages (the next commits), so the surface is a shadow and its readers take the snapshot unpinned: 3.94-3.97 ms/frame on development and on this commit alike (m3-max-6068, three rounds each, each process checking on a fresh cache). Pins apply there to a private target without STORAGE and to a render target over pages whose check passed. (cherry picked from commit e0799938e01c14d6b087ce7442bf9acfe3171b1c) |
||
|
|
3daaca19fc |
Fill with vkCmdFillBuffer on MoltenVK too: drop FillCompiledPerCommandPool and the transfers form
On MoltenVK the runtime recorded every fill as transfers (a vkCmdUpdateBuffer of the first 64 KiB, then copies of what was filled past barriers), because DriverFact::FillCompiledPerCommandPool said MoltenVK compiles its fill pipeline per command pool inside vkQueueSubmit and, behind a storm of pipeline creations, a commit waited 250-330 ms there (MoltenVK 1.4.1 on an M4). That release runs on no venue any more, and the tree's own 1.4.2 note recorded that the wait was not found there: a fresh pool's first vkCmdFillBuffer took 0.022-0.038 ms in vkQueueSubmit beside one to eight threads making 91 and 496 compute pipelines. The transfers form has a real cost at submission: MoltenVK ends its encoder at every barrier, and a 256 MiB fill took four. Measured on the M3 Max (MoltenVK 1.4.2), the signaller of event-wait-behind-a-running-signal (192 fills of 256 MiB) from its commit to Scheduled: - selection of the case, median: 4.3 ms as transfers, 0.55-0.6 ms as vkCmdFillBuffer; - under CPU spin on every core, worst of 15: 10.2 ms against 2.7 ms; - first row inside whole-set replays: 21.2, 15.0 and 9.5 ms against 1.8 and 0.8 ms; which put the case at its 20 ms window and, under load (5506), past it: a divergence of ours (Metal's own recording held in 25 of 25 runs under the same loads, 5580). So every fill is one vkCmdFillBuffer on every driver. With no driver carrying the fact, its variant, its row and its tests go, and so do the transfers form (word_fill's steps), its tests and WorkCounts::fills_by_transfers; the first move's zeros fill on a discrete device without the transfers check; the lanes that split their expectations by the fact expect one fill each. Signatures regenerated (the count and the two DriverFact variants removed). Every M3 cost record that fills moves (cmd_update_buffer, cmd_copy_buffer and barriers down, cmd_fill_buffer up): the M3 cost set wants a whole-set re-bless after this lands. (cherry picked from commit ac0310c517e62c9c490c58539f001e0ffc004a47) |
||
|
|
cede971187 |
Split the pass where MoltenVK's interlocked draws race, in place of the barrier
runtime_lane::framebuffer_fetch::coverage_chain failed under load on
the M3 Max (lane s37; also 2026-11-03, 1 lane run in 11): the target
lost whole 8x4 groups of texels, left at the clear. The colour draw's
fetch read the coverage as it was before chain_coverage, the draw
before it in the same render pass instance, wrote it. Alone it never
failed (10 of 10 runs, m3-max-5322; 840 passes, 5337).
A scratch loop of the test's 21 passes, run as six processes at once on
the M3 (MoltenVK 1.4.2, macOS 27.0.1, m3-max-5349, 7,560 passes each):
- the barrier between such draws (development): 2 lost;
- no barrier: 6 lost;
- a new render pass instance where the barrier goes: 0 lost.
Every loss was in a pass whose coverage writes and fetches share one
instance. Passes where they fall in different instances lost none.
Our use is valid, documented Vulkan. Vulkan orders such draws by the
ordered interlock alone ("Interlocked Operations": operations happen
before those of later fragments in rasterization order, which follows
primitive order through a subpass, submission order first; 34.3). The
critical section's accesses are coherent. The extra by-region barrier
from the fragment shader's writes satisfies VUID-vkCmdPipelineBarrier-
None-07889 against the subpass's self-dependency. The validation layer
reports nothing in these lanes. So MoltenVK does not honour that order
under load.
The new DriverFact::InterlockedDrawsRaceUnderLoad (MoltenVK on Apple's
GPUs, measured on the M3 Max) records such a draw into a new render
pass instance after the one the earlier draw wrote in. The draw is one
that reaches interlocked storage an earlier draw of the instance wrote
(InterlockedStorage::meets). An execution's replay takes its next run.
The instances' boundary orders the two draws. Every other driver keeps
the barrier, or nothing where InterlockOrdersDraws holds. The split is
counted as Split::InterlockedWrites, which is
WorkCounts::instance_splits_interlocked_writes, and every sum of the
split causes counts it.
Tests: runtime_lane::interlocked_draw_order checks the path. It prints
what lies between the draws (nothing, a barrier or a split) and
requires one split a draw after a pass's first where the runtime
splits, none elsewhere. tests::driver_facts gains the MoltenVK M3
profile's new fact.
Docs: DriverFact's doc and its measurement, framebuffer_fetch.rs,
render.rs (InterlockedStorage), render_target::between_storage_draws,
and the lane's header. api_signatures.tsv blessed. REFUSALS and
coverage unchanged.
Verified: cargo fmt. The build, the lanes, the A/B under contention and
the cost before and after follow in the tip's evidence.
(cherry picked from commit 660da10d1fd912ef8a86591e3ef2e3b1ff5fd300)
|
||
|
|
d33079bd05 |
Read a shadowed attachment through a snapshot after a barrier, not a split
A texture over host pages that renders is always a shadow (in_place.rs: ShadowCause::RenderTarget), the consumer's guest's IOSurface framebuffer among them, and Texture::snapshot_color took only an image of its own or a linear image over the bytes. So every draw that read such a target at its own pixels after a barrier over the render targets split the render pass instance, on every device: a keep of the whole shadow for the merge, a copy of every texel from the bytes into the copy the reader reads, and a store and load of the attachment, at each read (the guest's selfread probe on the Iris Xe: 30 splits, 31 whole copies in and 30 keeps a frame, 98 ms). The shadow is the image the pass renders, so the snapshot path serves it as it serves an image of its own: - the shadow image takes the feedback loop usage where that costs it nothing (Device::if_free, as with_free_usage gives an image of its own), counted as WorkCounts::feedback_loop_shadow_images; - Texture::snapshot_color takes Storage::Shadow's image; - RenderCommandEncoder::over_bytes (the snapshot at any area) takes a texture that renders its bytes through a shadow too (Texture::renders_bytes), as the split's copy there reads the bytes into the reader's copy after a keep and a merge. Every other check of render/snapshot.rs stands; the reads are the snapshot's, exact as for an image of its own. The pass's shadow plan is unchanged: the attachment is copied in before the instance and merged back as the encoder ends, as before, without the keeps and copies of the splits. Tests: runtime_lane::snapshot_reads::a_surfaces_readers_take_the_snapshot_at_any_area now expects a snapshot for each reader of a surface over host pages wherever the device takes the path and the image the pass renders took the usage (the shadow's, or a linear alias's), its bytes unchanged. The self_reads lane prints the images made with the usage. The WorkCounts field is in the api_signatures table and host_ab's list; the FAST-PATHS row on attachment reads names shadows. (cherry picked from commit 60b9a69d393a097f8658af8bcb5a8d6ef3576441) |
||
|
|
c9b8d711e0 |
Say what makes the draw_costs lane's chunk mapping safe beside why it is private
(cherry picked from commit 4ded42455b3a48e7b6cb0155fd46c323c5ab034d) |
||
|
|
c4c76fea87 |
Map the draw_costs lane's chunks private, which RADV imports
RADV refuses a host-pointer import of shared anonymous memory (VK_ERROR_UNKNOWN on Mesa 26.0.8, VK_ERROR_INVALID_EXTERNAL_HANDLE on 26.2.4), so every shape of the lane failed its first chunk on the RX 7900 XTX (gem10, potluck job m3-max-4287: Unsupported HostMemory NotRepresentable). A private anonymous mapping imports on RADV, NVIDIA and MoltenVK alike. Verified: the XTX runs in the perdraw report. (cherry picked from commit 2619ddc1c3d69aa81f5e8b3457299bd82fb4c28b) |
||
|
|
d37a42d6bd |
Measure the draw_costs lane's draws in a heap over host pages, on several threads, and count Linux instructions
The consumer's draws.10k profile on the RTX 5080 host (reims-vgpu, 11-07) spends its graphics threads' time in the runtime's draw path, with HostAliases::augment_into, HostCell::lying and ArgumentTable::changed_as high among it. The lane's 10k shape reached none of that: its upload chunks were no-copy buffers of their own, whose uses take no other, on one thread. - --heap places the chunks in one Placement heap over the host pages, beside a no-copy buffer over those pages and one chunk more, which stands for the guest RAM's key: the heap's bytes meet it, so every draw's use of them takes a use of it, as the consumer's chunks in a heap over guest RAM do. - --threads N encodes on N threads at once over one device and queue, each its own command buffers, every repetition started together, as the consumer walks a queue's command buffers on threads of their own: work the threads contend on shows as cycles a draw that grow with N. - On Linux the thread's user-space instructions and cycles come from perf_event_open (the frame_costs lane's counter), so a Linux run has the deterministic figure too. Verified: built and run in the potluck jobs named in the perdraw report. (cherry picked from commit a3f318f0279236fa9023d5d732e1a0d3a2f6d98c) |
||
|
|
e08ad161e6 |
WIP: a DontCare color of a texture's own image keeps its texels through a pooled backing
(cherry picked from commit 568dd0d59b0ae6b30a6308a2f7587cfe7c4a41dd) |
||
|
|
4dbc5451b1 |
Print the device's work counts around each shape in the draw_costs lane, with --counts
With --counts a shape's runs are bracketed by Device::work_counts, printed whole (WORK-COUNTS lines, the before and after values and the draws between), so a moved figure can be read against what the runtime did per draw: draws drawn again or rebound, heap parts made, sets pushed. Verified: built and run in release on the M3 (potluck). (cherry picked from commit 2b14e2d85dfcb031ea85cb8431941c8113466a2f) (cherry picked from commit b7460de4de64b5d39953f26c64fec987c7791810) |
||
|
|
f2042ac43d |
Count the process's page faults and context switches in the draw_costs lane
thread_selfcounts counts the instructions the kernel runs on the thread too: a counter read costs 1543 of them on the M3 (macOS 27.0.1), a system call's way in and out. A build whose draws fault more pages or wait on more locks moves a draw's figure without running more of the runtime's code. Each repetition now also reads getrusage's minor faults and voluntary context switches of the whole process, printed a draw beside the thread's figures, so a moved figure can be told apart as the runtime's code or the kernel's work. Verified: built and run in release on the M3 (potluck). (cherry picked from commit cba40c145e998d0874bd0bc5ea11cbbb7178e2f0) (cherry picked from commit dd89d082172c3d1b26478b0dcc078bdf73f42d1a) |
||
|
|
b3d57b6d00 |
Name the draw_costs lane's sum of two counts plus, not add
Clippy's should_implement_trait reads a method add(self, other) -> Self as std::ops::Add's. Verified: clippy follows on the M3 (potluck). (cherry picked from commit 073de3b9c423efd14e718495cf268b12ffe3f8f6) (cherry picked from commit a898af2d714315f5776641283a3cb45310bc5c88) |
||
|
|
9a9e4319ff |
Count each call's instructions apart in the draw_costs lane, with --calls
A run with --calls reads the thread's instruction counter around each call of its counted repetitions (command_buffer, render_command_encoder, each set_* call, draw_primitives, end_encoding, add_completed_handler and commit), takes off the read's own cost measured as the run starts, and prints each call's calls a draw, instructions a call and share of a draw: the median over the runs, with the lowest and highest a call. Why: the bisect's totals say which commits grew a draw's cost; the calls say which call a commit's instructions went into, so the change can be read where it lands. Verified: built and run in release on the M3 (potluck) with the bisect's points. (cherry picked from commit 998a998b5e6f10fca43f52907119217f0ccd2a84) (cherry picked from commit 15e64f7dcf0f20a476895157d3cde5cad74b4f1a) |
||
|
|
c88b1cf57f |
Measure a draw's cost on its encoding thread in three shapes of a guest's render work
Adds the draw_costs example (a measurement, not a consumer's example): command buffers of one render pass each, committed back to back through the runtime's public calls on one thread, in the shapes of the consumer's draw benchmark: ws (8 command buffers of 500 draws, each a 4-vertex strip after a fragment texture, a fragment buffer and a vertex buffer bind, the pipeline state and sampler again every 4 draws), many (64 of 16 draws, each a vertex buffer bind and a draw) and 10k (3 of 10,000 such draws). The buffers' slots lie in 64 KiB no-copy chunks over host pages, as a guest's upload chunks do. Each figure is a draw's share of the thread's CPU time and, on macOS, its instructions and cycles (thread_selfcounts), median and range over 9 runs. Why: the consumer measured a draw's instructions growing between two runtime pins in the bind and command-buffer paths; this reproduces those shapes in our tree so a bisect can find the commits. Verified: built in release on the M3 (potluck); its figures are in the bisect's report. (cherry picked from commit cc9dbf1eb1982afc3c4eea6e5459901e22e85c17) (cherry picked from commit d350b4d273b86d3c288542c5cc2f32aaec038aad) |
||
|
|
2d6b322e40 |
Clear a pass-start read's copy to the clear instead of splitting the pass
A pass that clears a color, begins with a memory barrier over the render
targets and then samples that color's texture split off a first instance of
the clear alone, stored it, loaded it again in the next and copied the read's
texels between (
|
||
|
|
164fdf475f |
Queue a staging-queue texture's first move and zeros instead of waiting at create
A texture that copies on the staging queue (a transfer-only family, NVIDIA's) took its first layout move and its zeros in a staging submission of its own, which new_texture waited for on the host (FirstMove::record_alone): the consumer measured 0.95 ms p50 and 26.8 ms at most for a Managed texture's creation on an RTX 5080. Now the move goes into the staging queue's batch (texture/staging_copy.rs's Queued) as the texture is registered, under the registration lock and before its slot write, and rides the next flush: its first replaceRegion's copy (recorded after it, a transfer write-to-write barrier between them when the image repeats), the next batch's or internal submission's flush (which the queue then waits for on the GPU), or a host read, hand-out or settle (waited on the host). Runs of moves share one barrier (FirstMove::record_several). The zeros come from one device-wide zero buffer (Device::staging_zeros) instead of a buffer per texture. The burst bound of copies and bytes holds the moves too. So every read of a fresh texture still answers its zeros, and a first copy lands after them: both ride one ordered queue. FirstMove::record_alone and Device::submit_staging go: nothing uses them now. WorkCounts::staging_moves_queued counts the moves queued (api_signatures blessed for the field; host_ab lists it). Verified on the M3 (MoltenVK, no transfer-only family, so the staging path does not run there and its counts do not move): staging_batches, first_use and heap_layouts lanes, 27 passed; conformance replay of the 22 fresh-texture-* cases exact; cost --alone --show of the 2d rgba8unorm managed and shared cases: no count moved. fmt, clippy plain and --cfg m2v_gpu, and the release check with --cfg m2v_gpu are clean. The 5080 legs (counts, before and after, the negative control) run on msi. (cherry picked from commit cad7056ecee2416d0e57d6db41b0cfdee07e3523) |
||
|
|
97baf233de |
Queue staging-queue texture copies and carry a burst in one submission
What: a replace_region into a Shared or Managed texture that copies on the device's staging queue (a transfer-only family: the RTX 5080's) packs the caller's bytes into a staging buffer of their own before it returns and queues the copy, instead of making a staging submission and waiting for it. The queued copies go to the staging queue in one submission, in their order (a barrier between two into one image), made by the first of: the device's next batch or internal submission, before its own, which waits for it on the GPU (Device::staging_wait, beside binding_wait); a get_bytes, which carries them before its read; a VkImage hand-out (settle) and CommandQueue::with_vk_queue, which wait on the host; a write into a texture whose VkImage was handed out; and the call past STAGED_COPIES / STAGED_BYTES, which waits on the host. The staging queue now records into up to eight command buffers and signals its own timeline on every device (no fence); a submission is waited for only where the CPU needs its result. The batch keeps what the flush copied (images, staging buffers) in its retained list until it completes; a queued copy holds its image weakly, so a texture gone takes its copy with it. Why: the consumer measured Safari's GPU process making 1776 replace_region_with_host_bytes calls at its first page on the RTX 5080, each waiting for its own staging submission (p50 120 us, p99 232 us, 223 ms in all). Metal's replaceRegion is a CPU copy; only the submission may move. Counted: WorkCounts::staging_copies_queued, staging_flushes, staging_gpu_waits (API table blessed: three fields added; conformance cost puts the last two in the submission region). Verified on the M3 Max (debug, --cfg m2v_gpu, under maclock and memcap): the new lane runtime_lane::staging_batches (6 tests) and runtime_lane::first_use (10), runtime tests cpu_copy_layouts, first_move, staging (30): all pass. The M3 has no staging queue (MoltenVK lists no transfer-only family), so there they run the host path and check the contract only; the staging path's counts and negative control run on the RTX 5080. clippy (plain and --cfg m2v_gpu, workspace, all targets, all features) and the release check of the runtime's tests are clean. (cherry picked from commit d47df5a36970e54e51465588e4ae3d6b299bcb0a) |
||
|
|
24dc3f20bb |
Keep an ICB range's chunks from their second execution, and forget a written chunk in one store
A range's first execution no longer pays for keeping. Before, every execution of CPU-encoded
commands recorded each 256-command chunk apart, in a KeptContext of its own (a command pool, a
descriptor arena and uploads), so it could run that recording again later, even when no later
execution came. Now a chunk is recorded to keep only from its second execution with no write
reaching it since. The first execution since a write records inline, as before 922caf3199, and
keeps nothing. A consumer that re-encodes every command each frame now pays nothing for keeping.
- kept_commands.rs: KeptChunks notes which chunks an execution that may keep its commands ran
since a write last reached them. look_up answers each chunk of a range as Kept::Recording (a
kept recording), Kept::Again (run before, nothing kept) or Kept::First, and notes each as run.
IndirectCommandBuffer::kept_chunks answers None, so the execution records inline, when every
chunk is First. When some chunks are kept and others are not, a First chunk records apart from
its command buffer's own pool and arenas, with no KeptContext, and is not kept. An Again chunk
records apart in a KeptContext and is kept.
- KeptChunks is dense: one ChunkState per chunk (kept recording, stepped, seen) up to the
furthest chunk looked up, plus a flag for whether any chunk holds a state. KeptChunks::wrote
costs one store per chunk the written range covers, whatever the number of kept chunks, and
returns at once while no chunk holds a state. Before, it ran BTreeMap/BTreeSet::retain over
every kept and stepped chunk on each setter call.
- WorkCounts::kept_contexts_made counts the KeptContexts made (api_signatures.tsv).
- Docs: kept_commands.rs, render/executions/kept.rs, indirect_execute/kept.rs and
docs/FAST-PATHS.md (the kept-recordings row).
- examples/icb_setters.rs --kept now executes three times before each repetition: the first
keeps nothing, the second records every chunk to keep, and the third runs all of them from
those recordings.
Tests:
- runtime_lane::kept_commands asserts kept_contexts_made beside the records read and the chunks
and commands kept.
- A once-executed range makes no context: [N, 0, 0, 0].
- Its second execution keeps every chunk: [N, 0, 0, 3].
- Its third runs them: [0, 3, N, 0].
- After a write, the written chunk records inline again and the next execution keeps it.
- kept_commands::tests::a_write_costs_the_chunks_it_covers asserts the count of chunk states
wrote() looks at.
Verified on the M3 Max:
- Debug device lanes (--cfg m2v_gpu, nextest), with the live compute flags fix from stack22
applied locally (not part of this commit): every runtime_lane module that executes an indirect
command buffer (39 modules, 471 tests) pass.
- Negative control for the ruling (each chunk keeps from its first execution), debug:
3 of the 5 kept_commands tests fail, a first execution making 3 contexts where 0 are expected
and a written chunk making 2.
- Negative control for wrote() (it walks every chunk state): a_write_costs_the_chunks_it_covers
fails, looking at 1000 states where 1 is expected.
- Unit tests: kept_commands::tests 2/2 and metal2vulkan tests::fast_paths 19/19.
- cargo fmt --check and clippy -D warnings (runtime and validation, all targets and features,
--cfg m2v_gpu) are clean.
- icb_setters compute --kept (release, instructions per command, median of 30, two runs each):
| | before (2c542021bf) | after |
|---|---|---|
| compute command, nothing kept | 2528.7 / 2529.1 | 2428.1 / 2427.7 |
| compute command, 64 chunks kept | 5947.8 / 5945.5 | 2586.5 / 2583.9 |
| set_kernel_buffer, 64 chunks kept | 1129.6 / 1129.6 | 456.9 / 456.3 |
With three executions, the third runs all 64 chunks from kept recordings (the
bench prints [64]), at 2583.9 and 456.3 instructions.
- conformance cost --alone indirect-render-commands-inherited-state reads arena_pools_made 1,
argument_objects_retained 2 and argument_tables_retained 1, the recorded bounds. With a first
execution's KeptContext these read 3, 6 and 3 (the cost run that held its record back).
- execution_costs (release) on a loaded host: wall times are dominated by host load. An earlier
pair of runs read the first execution as slower (render n=1024 all re-encoded commit 2.88 to
6.55 ms), but the parent then read 6.55 ms itself under the same load. Time Profiler, test
thread CPU, same case and count, this change on 2b55ab415e against its parent:
- render n=1024 one re-encoded, 300 executions: 611 to 610 ms;
- compute n=1024 all re-encoded, 80 executions: 336 to 333 ms;
- render n=1024 all re-encoded, 120 executions: 782 to 859 ms. This is the inline path's
whole-range read: RenderExecution::commands collects the range into a second
Vec<Option<Command>> (memmove 0 to 25 ms in RenderExecution::record), and render_records
reallocates as it grows. The same profile has IndirectCommandBuffer::edit, whose code is
the same in both builds, up 31 to 40 ms, so part of the difference is load.
A later run of this commit's tree read render n=1024 all re-encoded at 2.37 ms commit, one re-encoded
at 0.61 ms, and compute n=1024 all re-encoded at 3.49 ms.
Needs a RUNTIME_VERSION bump. No SEMANTICS_VERSION: no translated module changes.
(cherry picked from commit a54756c6a4f7fbe9ae82d732e8de46a19f4f86e5)
(cherry picked from commit 71e798c081648ea3818abbffc7538a3061456c75)
|
||
|
|
35110091d4 |
icb_setters --kept: the setters' cost after executions that kept every chunk
A consumer's frame executes the buffer and then encodes it again. After an execution kept its chunks' recordings (kept_commands.rs), each CPU write forgets the chunk it lies in through KeptChunks::wrote. With the --kept flag, the compute row now also times its encoding in that state. Before each repetition, untimed, a compute encoder executes every command twice, each time in a command buffer that is committed and waited for. The second execution runs every chunk from the first's recordings, and the bench prints indirect_chunks_kept for each second execution. This mode submits GPU work; the other modes still submit nothing. Verified on the M3 Max (MoltenVK, release) under maclock, one run, median of 6 repetitions x 16384 commands, every second execution running all 64 chunks from kept recordings: - parent e3444f3273: compute command 10187.8 instructions (589.3 ns), after the kept executions 13788.8 (826.3 ns); a set_kernel_buffer pass after them 2728.2 a call. - df69cd7b7a: compute command 2528.7 (163.4 ns), after the kept executions 6140.9 (406.7 ns); set_kernel_buffer after them 1168.2 a call, against 441.1 with nothing kept. Both sides pay about 725 instructions more per setter while chunks are kept: KeptChunks::wrote's retain walks over the kept chunks and the stepped set. That is the figure to compare a one-store invalidation against. (cherry picked from commit ac8eae71c9d063369c6568a2b38fb2fd30e22f47) (cherry picked from commit 2c542021bff8d4bb7f500b63e69cf35e6005bf3c) |
||
|
|
da7b285ec7 |
icb_setters: the CPU cost of an indirect command buffer's setters
A bench for the cost a consumer pays to encode indirect commands on the CPU, every field of each command set by its own Metal-shaped setter, one thread, nothing executing. It has the shape of the consumer's report (rgk-icb-2): - render: a buffer of 16384 commands of DRAW alone, 2 vertex buffers and 1 fragment buffer, nothing inherited. Each command is indirect_render_command_at, set_render_pipeline_state, set_vertex_buffer twice, set_fragment_buffer and draw_primitives. - compute: CONCURRENT_DISPATCH, 3 kernel buffers. Each command is indirect_compute_command_at, set_compute_pipeline_state, set_kernel_buffer three times and concurrent_dispatch_threadgroups. Each repetition encodes every command once, over the last repetition's, and is timed as a whole: wall time, and on macOS the thread's own instructions and cycles (libSystem's thread_selfcounts, readable unprivileged). It prints the median a command with the lowest and highest. `--calls` also times each call kind alone, and the record format's own write_field of the same fields (no lock, no check): the floor of a setter's write. The pipeline states come from the owned fixture runtime_examples.ll through llvm-as. Nothing is submitted. Verified on the M3 Max (MoltenVK, release) at this commit's parent e3444f3273: median of 5 runs x 6 repetitions x 16384 commands, each run's median a command: render 588.0-599.4 ns, 10350.9-10351.9 instructions, 2107-2145 cycles; compute 578.3-588.1 ns, 10176.3-10177.5 instructions, 2083-2105 cycles. --calls: about 2000 instructions a buffer setter and 2288 for set_render_pipeline_state, where write_field of a field costs 130-213. (cherry picked from commit 5a88c91634f289aaaf9d866ecdf36b949f3ee45d) (cherry picked from commit 46a4a5d15cb7423a031650f9fc136e7470912174) |
||
|
|
0b7aba796c |
Measure cross-queue completion order and latency in submit_path
What: submit_path gains a `cross` mode. Command buffer A on one queue signals an event at its end and command buffer B on a second queue waits for it on the GPU. The mode prints A's commit to A's handler and to B's handler (p50, p90, p99), and how many of 2000 rounds ran B's handler before A's. It covers shared and plain events, completed or completion-seen handlers (`--seen`), and gaps of 0 and 2000 us between rounds. Why: it measures the completion order the previous commit fixes, and its cost, on any device the example runs on. Verified on the M3 under MoltenVK 1.4.2: it ran before and after the fix, two pairs each. Before, 3/2000 rounds ran B's handler first (plain events, 2 ms gap); after, 0. The latencies are in the previous commit's message. (cherry picked from commit 521479bb0bf6324131f4fcf0fe9519b84d011160) (cherry picked from commit 85c5343c65375ef437ff17bb5328bda381cc1438) |
||
|
|
7148b9518f |
host_ab: draw_host, each draw's vertex buffer bound at the next 256 bytes of no-copy host chunks
The encode workload gains a variant over the buffer kind a guest's setVertexBytes: reaches the runtime through: no-copy buffers of 64 KiB over host pages (one mapping, a buffer a chunk, 256 draws' rectangles each), each draw binding the chunk its rectangle lies in at its offset (setVertexBuffer:offset:atIndex:), as reims-vgpu's draws.10k measurement does. The other variants draw as before (encode_draws takes the chunks, empty for them). Verified: clippy over host_ab, all features. Run on the RTX 5080 Laptop GPU at the lane base and at the draw path's step 4 (one run each, 3000 and 9000 draws a pass, encode us a draw): draw_host 0.642 / 0.617 and 0.584 / 0.528, draw_offset 0.536 / 0.532 and 0.490 / 0.516. (cherry picked from commit 691332c6c3076d78b68abed22960227d3c220e27) (cherry picked from commit 07145d5cfde93f81acf46fe8ae84e306cd2760ae) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
2bf4e3b4cb |
Ask whether a shadow fits a heap texture only where its images do not, and hold it to 17.25
What: held_to_metal takes the question whether a shadow of the heap's bytes fits the image's planes as a closure (shadowable), asked only of a single-sample texture its images do not hold: past Metal's answer, or 4:2:2. HeapTextureShape loses its shadowable field. Device::heap_plan passes `|| shadowable(plan, metal.size)`. host_ab percall's heap_texture_256 row comes down to the measured 17.25 allocations a call from 20.25. Why: shadowable answers from heap_planes, which lays out the texture's planes (copy_units' list, heap_plane_layout's planes) and its copy regions (a BufferImageCopy list) only to compare the bytes they span. |
||
|
|
7e0d848a0c |
Order a small encoder part's resources on the stack at its end, and hold the end rows to 7 and 24
What: EncoderUses::finish_parts orders each part's resources by key through by_key. Up to 16
resources (ORDERED_INLINE) are sorted in an array on the stack, more in a vector of their own
as before. The summary is unchanged: resources in key order, each one's uses in the order
recorded. host_ab percall's HELD rows come down to the measured counts: end_compute and end_blit
8 -> 7, end_render 25 -> 24.
Why: a5a8ddf96f replaced the stable sort of a part's flattened uses, which allocates nothing for
a short slice, with a sort of the resources' keys, each once, through two vectors: the tracked
map collected, and the order. 1aaf95c79f dropped the first. The second was one allocation at
every encoder's end, the +1 c01e79adc1 raised end_compute and end_blit to 8 for with no cause
found. At
|
||
|
|
b85685ae41 |
host_ab percall: re-bless the gate's stale rows to what the runtime does now
The percall gate (HELD) held calls to counts the runtime no longer makes, so it failed on every run for reasons that were not regressions, and a real one hid among them. Each row now holds what one percall round on the M3 measured (gate/stack6 with this landing): - draw_strip, draw_triangles, draw_indexed: the draw is recorded at the call (rt_draws_at_call 1, rt_recorded_cmd_draw_indexed_at_call 1), not at the commit. - end_render: its render pass is begun at the call (rt_render_passes_begun_at_call 1). - end_compute, end_blit: 8 allocations, held to 8 where they were 7. - dispatch: recorded at the call (rt_dispatches_at_call 1); 8.13 allocations, held to 8.2 where it was 19. - heap_texture_256: 20.25 allocations, held to 20.25. - buffer_texture_256: one image and one binding at the call, no memory of its own and no view (held to 0 images and 1 view before). - use_resources_read_256: 16 allocations, held to 16 where it was 277. Two rows keep their bounds and still fail: the draws' 1.055 allocations a draw (held to 0.2; 0.041 before this base) and end_render's 27 (held to 25). Neither has a cause found here, so neither is blessed. Verified: host_ab --only percall --rounds 1 on the M3, built with this table (its gate made to print rather than fail): the gate reports those four rows alone, and every row that holds a call to some work names a count its group moved. (cherry picked from commit c01e79adc1944a6f86ce63d13163c1b7f612b429) (cherry picked from commit 48e3b1e102411b6877258c1c91c142d5f014b0ca) |
||
|
|
2f9a3a3782 |
A command buffer joins its ended encoders' resources where its work reads them, not as each ends
Each compute or render encoder's end joined everything it made resident into its command buffer's
residency (Residency::join_encoder: a clone and a hash insert per resource), and each later
encoder's open walked every texture of that union for the shadowed ones. Most command buffers'
work never reads the union: only the commit's and host steps' recordings against every encoder's
resources (CommandBuffer::residency), the resident set of a GPU-alone recording, a texture made in
a heap since, and an encoder encoded again do.
- command_buffer/mod.rs: an encoder's end joins its heaps at once (join_encoder_heaps) and leaves
its resources in its record; State::joined_residency joins the records not joined yet, in the
order they ended, at the first read (CommandBuffer::residency, make_resident, fresh_ranges, a
splice of an encoder encoded again, before the textures its heaps made since). The union holds
what the eager join made, in the same token order: State::sync_heaps joins the records first
where a heap made textures, as each encoder's join came before them. The commit's sync of its
heaps and an encoder's open (State::inherited) read no resource list unless one did.
- residency.rs: each residency lists its shadowed textures' tokens (shadowed), found where an
open first asks for them (find_shadowed) and each texture looked at once, so making a texture
resident reads nothing of it, and an open starts with the shadowed textures of the joined union
and of the records not joined yet, in the order they were made resident, with the joined usage
and stages, at the cost of their count. The join's resource and heap halves and sync_heaps's
finding and joining halves are split out.
- WorkCounts::resident_resources_joined counts the joins (api_signatures.tsv blessed: one field).
The records hold what their encoders made resident until the command buffer completes, as before,
and the union goes with them, so nothing lives longer or shorter. The same resources, usages,
stages, tokens, shadows and heaps at every read.
Release numbers, M3 Max (host_ab --only encode, runtime side, median of 3 rounds, µs; before is
this landing without this commit, after with it, two or three interleaved runs each):
before (3 runs) after (3 runs)
resident_0 end_call 14.1 11.6 14.9 11.3 14.4 15.1
resident_256 end_call 34.7 25.6 37.3 11.1 13.3 15.4
resident_4096 end_call 230.3 152.3 244.3 11.4 14.1 15.5
resident_moving_4096 end_call 170.5 154.3 248.6 10.7 11.8 15.2
resident_textures_256 end_call 41.5 29.5 43.1 11.2 13.0 15.3
resident_textures_4096 end_call 287.8 193.5 294.6 11.5 12.9 15.8
resident_4096 use_call 346.1 379.3 335.1 326.1 297.3 342.0
resident_textures_256 use_call 38.0 37.0 36.9 35.1 35.1 37.2
resident_textures_4096 use_call 450.3 481.0 430.3 409.5 419.6 438.3
resident_4096 encode/dispatch 1.73 1.32 1.62 1.74 1.65 1.65
resident_textures_4096 encode 2.20 1.78 1.93 1.93 1.99 1.97
static encode/dispatch 1.75 1.74 1.61 1.62 1.64 1.60
The end call no longer grows with what the encoder made resident, and the useResources call does
not take the cost instead. A first form of this change looked for a texture's shadow as it was
made resident; that put about 80 µs into resident_textures_4096's use_call (260 to 317 against
188 to 200 before, four interleaved runs each), which is why the shadowed textures are found
where an open first asks for them. Percall's counts are the same with and without this commit;
the calls workload's end_compute allocates 5 a call where it allocated 8.5.
Checks that fail without it, in tests/joined_residency.rs:
- ended_encoders_join_their_command_buffer_s_residency_where_it_is_read: with the second
encoder's open joining the records (the eager join's timing), its first assert fails (16 joined
where 0).
- shadowed_textures_made_resident_reach_the_next_encoders_in_order: with find_shadowed looking
at none, its first assert fails (no shadowed texture inherited).
Verified: the runtime GPU suite on the M3 (1527 passed, 3 skipped); cargo clippy -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu;
scripts/api-signatures/signatures.py --check.
(cherry picked from commit 18553c295c98dabe4c74fc226be6b45955c0c13a)
(cherry picked from commit ae56cfdfdd2e4cb1e9b189c7ce303d680fbc2b7f)
|
||
|
|
c6ff058263 |
host_ab encode: time each dispatch_resident variant's endEncoding call
The dispatch_resident variants timed the useResources call and the dispatches after it, but not the encoder's end, where a command buffer joined everything the encoder made resident into its residency: a cost that grows with the resident count and fell outside every row. Each variant now emits dispatch_resident_<name>_end_call, the end_compute call alone (before the commit), on Metal and on the runtime alike. Verified: host_ab --only encode on the M3 prints the new rows for every variant. (cherry picked from commit 87d8341d269d126b1edac5d3935485f0997b47be) (cherry picked from commit 400bf537e6efaaa15cdb1e6a8fcb1c7836de53f3) |
||
|
|
917fa5adf2 |
host_ab percall: the no-copy commit group's buffers live only in its windows
commit_no_copy_dispatch kept its two buffers over host pages alive in Objects for the whole run, so every other group's calls ran beside two live buffers over host pages and counted differently: use_resources_read_256 24 allocations a call where it makes 16 (16 before the group was added, 24 with it, 16 again with this; one percall round each on the M3). The group now makes its two buffers in each window's preparation, over the first two megabytes of the no-copy pages (Objects::pages, which buffer_no_copy_1m's windows use too), and lets them go with its drain. end_render's 27 allocations a call (25 before) is not this group's: it stays 27 with this change. (cherry picked from commit e2671b315330440b360abcd7a797ab414861068e) (cherry picked from commit fac1d2aeb20253c7593ce14a053d3a5c4506efce) |
||
|
|
11edfb6daf |
A commit counts its buffers' host imports without making a list for the first sixteen
Buffer::distinct_host_imports, which every commit calls for WorkCounts::host_imports_used, collected the import of each used buffer over host pages into a Vec, sorted it and removed the repeats. It now tells the first 16 distinct imports apart in a stack array (FEW_IMPORTS), and lists and sorts them only past that. The count is the same. The audit proposed a per-import epoch stamp instead. The call runs outside any device-wide lock (command_buffer/mod.rs, in the commit), so two command buffers committed at once on two threads would share the stamps and miscount each other's imports; the stack array is exact under any concurrency and makes no allocation in the common case. The other half of the audit's commit-cost finding, the scheduler's wake broadcast, is the owner's question (spinning, or the committing thread submitting itself) and is not changed here. Checks: - host_ab percall now holds commit_one_dispatch to 4 allocations and commit_no_copy_dispatch (its two buffers over host pages) to 9. Before this change the latter makes 10, so the gate fails without it. - tests::host_import_counts::a_commit_counts_each_import_once_past_the_few_it_tells_apart_in_place checks the count at 1, 15, 16, 17 and 18 imports, each buffer twice and one import holding two buffers, on both sides of the fallback. Verified on MoltenVK with the other host-import tests (6 passed). Release, M3 Max, MoltenVK 1.4.2, host_ab percall, before (9f56956ef3) and after interleaved twice: | row | before | after | |---|---:|---:| | commit_no_copy_dispatch allocs/call (both rounds) | 10 | 9 | | commit_one_dispatch allocs/call (both rounds) | 4 | 4 | | commit_no_copy_dispatch self, ns/call (round 1, round 2) | 2414, 1477 | 2354, 1495 | The times ran under a load average of 30-60 from other builds and moved more between rounds than between builds. (cherry picked from commit 7b1b75bdddfafd3cb3dd835d4b5f87ab2db2f7a0) (cherry picked from commit e3b963bdc0e5c41766b6a42892860a4eec7c005b) |
||
|
|
6b13f54c5e |
host_ab percall: time a commit whose dispatch binds two no-copy buffers
commit_no_copy_dispatch is commit_one_dispatch with the dispatch's two buffers made over host pages of their own (Objects::no_copy), so the commit counts the host imports its used buffers lie in (WorkCounts::host_imports_used), which commit_one_dispatch's buffers, the runtime's own, never reach. The group is declared in TIMED under CommandBuffer::commit; the API cost coverage is unchanged (commit was timed already). (cherry picked from commit 506eccf91672f23d8f669b7a519e5449735124a6) (cherry picked from commit cf0e5cf9513d17c21e539e0ed9354fc780066470) |
||
|
|
be47523f80 |
State queue sharing's residual stall and the unshared form for queues that must never wait
What: docs/FAST-PATHS.md's queue sharing row, docs/API.md's policy bullet and the runtime README's new_command_queue_unshared entry now state the residual stall exactly: once per logical queue that goes long, for a queue that joined its VkQueue during its short phase, about one long command buffer's length. They also say a queue that must never wait (a compositor's) is made with Device::new_command_queue_unshared. The row's cost column carries the measured rates. The queue_share example's rates mode takes --threads, --in-flight and --one-vk-queue for one shape. It prints each command buffer's GPU end and commit to its completed handler, the submission, scheduler and wake counts per command buffer, and the busiest threads' CPU from /proc (Linux). Why: on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, 3 runs a side), the trap and slow-alternating shapes cost a shared compositor 64 completions over 10 ms, at most 29.4 to 30.6 ms, in every run, with one join each. That is the first long command buffer of the application it joined during the application's short phase. PerQueue had none in 5 of those 6 runs and 4 in the sixth (at most 3.7 to 10.7 ms). An unshared compositor had none over 10 ms in any run. No join rule built on what a queue has shown can avoid the first one: the long command buffer gives no sign before it runs. A re-pick at submission would not either: the compositor holds about 4 uncompleted command buffers at each commit (p50 commit to handler 0.78 to 0.87 ms at a 208 us period), and the stall is all or nothing in a queue's own order. So the docs name the unshared form as the answer for such a queue. The probe settled the 2 threads x 3 in flight drop (15.4k against 26.0k a second in one run): it was the lock hold's warm-up. In the hold's first runs both policies ran slow (11.1k and 10.4k), and later runs gave Adaptive 46.5k and 39.7k against PerQueue's 25.2k and 26.5k. Two queues on one forced VkQueue ran 38.1k to 46.6k under PerQueue and 41.4k to 49.9k pinned under Adaptive, so one VkQueue is not slow in the runtime's path. No runtime thread was busy in the slow runs (scheduler 10%, handler threads 5%, waiters 3%), and every shape made one vkQueueSubmit per command buffer. Verified: tests::fast_paths, degradation_catalogue and degradation_sites (25 passed); clippy of the example with all features. (cherry picked from commit b1dbea95dad3a5a156191df01084db0f86cb67a0) (cherry picked from commit 24af60dbf8175da8e60ea24f38f9103c20c23e8b) |
||
|
|
510e0c0cca |
Share VkQueues between command queues where the GPU idles at each switch, with an unshared opt-out
What: a new DevicePolicy switch, queue_sharing: QueueSharingPolicy { Adaptive (default),
PerQueue }; exact_answers() selects PerQueue. Under Adaptive, on a device whose own self-check
finds its GPU idle when consecutive work comes from another VkQueue, a command queue chooses its
VkQueue again each time it makes a command buffer while it holds no other uncompleted one (the
slot take with held.all == 1, under its slots lock): it joins the busy VkQueue of its family
whose oldest batch has run under 0.5 ms, the most batches in flight first, then the latest
submission (Device::pick_vk_queue: one pass of atomics over the round robin's VkQueues, no lock).
A queue whose batch ran over 2 ms as its VkQueue's oldest is marked long by the waiter that saw
it complete, under the completion's pending lock, before the turn that finishes it
(command_buffer/completion.rs); no queue joins a long queue's VkQueue, and the long queue moves
once more at its next idle point, to the least recently used idle VkQueue no long or unshared
queue holds. Its mark moves with it and a dropped queue subtracts its marks. Presenting queues and
a queue that lent its VkQueue (with_vk_queue, pinned from then on) never move. A queue's vk_queue
is now an atomic; everything that reads it does so between a command buffer's make and its
completion, when no move can happen.
The self-check (queue_switch_check.rs) is the runtime's own, kept like the in-place check's, not
a DriverFact row: on a thread of its own, once per driver, release and runtime, 24 rounds of two
timestamp-only batches held behind one host-signalled gate on two same-family VkQueues against
24 on one; the switch cost is the difference of the median gaps; Idles above 20 us, DoesNotIdle
below, Unchecked where the device has no calibrated timestamps, no two VkQueues of one family, or
a run failed. Its verdict is written as one record in the shader cache's content directory and
read back as the next device of the same driver, release and runtime is made. Before the verdict,
every queue keeps the VkQueue it took at creation.
Device::new_command_queue_unshared(count): a queue that never moves and that no adaptive queue
joins; a queue already on its VkQueue leaves at its next idle point. Placement where the device
shares: a round-robin VkQueue no command queue holds, least recently used first; else one no
long or unshared queue holds, the fewest queues first; else the round robin's next. Why that
order: an empty VkQueue gives isolation at once, with no wait for another queue's idle point; of
the empty ones the least recently used is the one least likely to hold a moving queue's work in
flight (a queue that just left it may still have batches there, and the unshared queue would
wait behind those); where none is empty, the least held one has the fewest queues to move off,
each at its own next idle point, so isolation arrives soonest, and a VkQueue a long or unshared
queue holds is never taken since that would put the opt-out behind exactly the work it opts out
of. A queue's claim of a VkQueue and an unshared queue's are ordered so that two at once never
both succeed: each counts itself there first, then reads the other's count (SeqCst both sides).
Under PerQueue, and where the device does not share, it is
new_command_queue_with_max_command_buffer_count. A count of 0 and a lost device are refused.
Why: NVIDIA 615.71.09 on the RTX 5080 Laptop GPU leaves the GPU idle 56 to 62 us whenever its
next work comes from another VkQueue, so one VkQueue per command queue, round robin, capped eight
threads' one-draw command buffers at 25,800 to 29,500 a second (GPU idle 60% of its time at the
switches), where one VkQueue ran 54,700 to 58,700 (the audit that set this design). Moving only
at idle points keeps every queue's own order without a cross-queue fence. The cost is the
runtime Degradation kind QueueSharing ("queue-sharing", performance), announced once per device
at the first join, in CommandQueue::command_buffer on the making thread: the first long command
buffer of a queue that shared holds the command buffers committed behind it on its VkQueue for
its whole length. The opt-out exists so a compositor never pays even that one stall.
Counted: WorkCounts::queue_moves, queue_joins, queues_gone_long, long_queue_settles,
queue_moves_off_unshared, joins_withheld_from_unshared, queue_switch_checks_run and
queue_switch_checks_recalled. The policy keys no profile (tests::fast_paths), so
SEMANTICS_VERSION does not move. Docs: FAST-PATHS row, docs/API.md (the policy and the notice
catalogue), the runtime README (the opt-out, with_vk_queue's pin), queue.rs's module doc on
isolation; REFUSALS regenerated (the new site of MaxCommandBufferCount); api_surface and
api_signatures (additions only). The example queue_share runs the workloads under either policy.
Verified: cargo clippy --workspace --all-targets --all-features -D warnings, and the runtime and
validation crates with --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc --workspace
--all-features --no-deps; nextest of tests::queue_share (the choice, settling, the unshared order,
the record), tests::fast_paths, tests::degradation*, api_surface, work_counts: 66 passed. On the
RTX 5080 Laptop GPU (release) the check answered Idles at 51.3 us, and its form measured 49.0 to
50.7 us in five more runs, where a chained form measured 53.2 to 59.3 us. The device tests
(tests::queue_share_device, runtime_lane::command_queues::a_queue_joining_...) are not yet run
on a GPU in this commit.
(cherry picked from commit a2f17a5132faf0312fb3953d634e21c927cde62e)
(cherry picked from commit 862b2cb49a9481d0a2a19fb1bc3acec79932d1bd)
|
||
|
|
65c0371cbf |
submit_path: the committing threads' own CPU
The threads mode's committing threads ended before the process-wide reading after the run, and their per-thread CPU went with them, so the CPU that commit_and_submit moves onto them was not counted. Each thread now reads its own CPU (CLOCK_THREAD_CPUTIME_ID) before it ends, and the mode prints their sum per command buffer. The main thread is grouped by the name's prefix too, since a copied binary runs under another name. Verified: clippy -D warnings on the example; run on the 5080 for the M1 and wake numbers. (cherry picked from commit 7822ca3293633c6da2fa4a1a734e137dc792ddbc) (cherry picked from commit 951eb7841e4274bce6b276d36ae89245ad554ba4) (cherry picked from commit 9e2d82e104f88da4f98cc14073a48f3eaaff97d8) |
||
|
|
431ebb90ad |
submit_path: --at-commit and a threads mode
--at-commit makes the latency, cpu and threads modes commit with CommandBuffer::commit_and_submit instead of commit. The new threads mode runs the cpu shape (a 16-byte fill with a scheduled and a completed handler, never waited for) on 1 and on 8 threads at once, each with its own queue, and prints command buffers a second in all and the CPU per command buffer. These measure the committing thread's own submission. Verified: builds in release; run on the M3 Max and the RTX 5080 Laptop GPU for the M1 numbers. (cherry picked from commit b100c3aa5c52d7d071223f7b6e500902afba5ccf) (cherry picked from commit a3d3d6ca16bd783b23298ac4d14b9fbe127dfe84) (cherry picked from commit dca3e8460fb5dfdb5d0bef3131af99776aebaeb3) |
||
|
|
29b5417902 |
submit_path: time GPU end to the handler, a bare variant, idle wakes
The bench example gains what the numbers for the completion path need: - latency rows also time the command buffer's GPUEndTime to the handler's start, both on the runtime's host clock (host_time), next to commit to the handler's start; - --bare adds the same rows with no scheduled handler: a lone 16-byte fill and its one callback; - an idle mode: after one fill, wakes a second over 3 s with nothing committed, as voluntary context switches by thread group on Linux (/proc/self/task/*/status) and, everywhere, the scheduler's sleeps and sleeps ended at its slice from the work counts. macOS's per-process switch counts read back inconsistently, so none is printed there. Verified: built in release on the M3 Max and run against 17a1c34c1c (completion-seen calls mapped to completed handlers) and c87df4e91a. (cherry picked from commit 32643c1ccb4ff129a5c799aeca0f2fa85a7ee844) (cherry picked from commit 793f74e38f19a26cdf1c510489daae307fa62219) (cherry picked from commit 85547774368e2efc0d2d29aa2fba7c1075448d88) |
||
|
|
e1c53c37ed |
A compute variant works out its heap tables once, and its commands take the heaps lock once
Each compute command whose layout binds the device's texture or sampler table read the layout again for those bindings and the table kind (allocating their lists), and took the device-wide heaps lock three times: for the highest texture ID placed and the texture table, for the sampler table, and in heap_sets::bind. - heap_sets.rs: TextureTableAt and SamplerTableAt work out from a layout where it binds the tables, over how many entries and of which kind, and keep each table's descriptor once read (the device makes each table once and never replaces it). HeapTables holds both; texture_table and sampler_table (render's calls, unchanged) build them per call as before. - The highest texture ID placed, for UnnamedTexturesPastCapacity, is stored under the lock as textures are placed and unplaced (DeviceShared::heap_textures_end) and read without it, so the notice is made at the same commands. - pipeline/objects.rs: VariantObjects::heap_tables makes HeapTables at a variant's first command; compute's record takes it there. TextureTable and SamplerTable borrow the bindings. - WorkCounts::heap_tables_worked_out counts the layout reads. The same descriptors, sets and notices. heap_sets::bind keeps its one lock. Check that fails without it: runtime_lane::resource_ids::a_variant_reads_its_layout_for_the_device_tables_once (four dispatches of a kernel reading a texture handle: [1, 0, 0, 0] layout reads; with the per-call form beside it, [3, 2, 2, 2]). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (d6779a26d9) and after interleaved three times, us per dispatch (medians of 3 rounds; one thread, so no lock contention is measured): | workload | before | after | |---|---:|---:| | dispatch_handles | 1.075-1.115 | 1.047-1.076 | | dispatch_handles (process CPU) | 8.95-9.72 | 8.20-9.07 | | dispatch_static | 0.674-1.009 | 0.664-0.685 | dispatch_handles_rt_heap_tables_worked_out: 0.000 a dispatch after the first runs. Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 534/536 (the two failing the same at the base); resource_ids, heaps and argument-buffer lanes 153/155, the two (extended_range_two_planes::two_plane_heap_textures_read_and_write_as_metal_does, argument_linear_samples::heap_linear_samples_answer_as_slot_samples) failing the same at the base. (cherry picked from commit b9f35448fd3e947bb02a440a79eec2f9caf705ca) (cherry picked from commit c327b2e68c82f88698e85637569461b102bc51be) (cherry picked from commit c6ad3ecd67471216711b5410fbf35201c423f091) (cherry picked from commit 78be3664f4474a26221b82842cbe5c8df76fead3) |
||
|
|
05d0732d6b |
host_ab: dispatch_handles, dispatches of a kernel reading a texture through a handle
The encode workload's dispatch_handles variant dispatches tiny_handle_kernel, which reads a resident texture through its handle in an argument buffer (Gpu::texture_id writes the gpuResourceID on both sides), so each dispatch binds the device's texture table: the per-command heap-table cost is measured. encode takes the library to make its pipeline only where the variant runs. Verified: the example builds (clippy, all features). (cherry picked from commit 1d8f613081eec7cae21b1279e8661dfa2ab4b50d) (cherry picked from commit ec5573c6f17c7f404729a9811025beb688f46250) (cherry picked from commit de3aaea45f86a76432e6c459262f5612845d0194) (cherry picked from commit ca61dcb9423979f8397c674ef8a6b0809a1c99fd) |
||
|
|
81681968e4 |
Compute encoders look at their resident textures once a change, and usage shadows read without a lock
Each compute dispatch walked every resident texture for its shadows (shadow::shadow_uses), taking each texture's usage-shadow mutex, and each dispatch reading texture handles walked them again for one a carrier holds (pvrtc::degrade_unreadable); each encoder open walked every resident resource for shadowed textures (Residency::shadows). - shadow.rs: ResidentShadows keeps the resident textures' shadow copies, listed again only where the residency's generation or the device's count of usage shadows made (DeviceShared::usage_shadows_made) moved; shadow_uses_of takes the bound textures fresh, then the kept list, in the order shadow_uses took them. - pvrtc.rs: ResidentUnreadable keeps the first resident texture a carrier holds, found again only where the generation moved (a carrier and a decoded twin are fixed at a texture's making); the announcement is made at the same dispatches as before. - compute/live.rs: the encoder's kept state holds both lists, emptied when it goes to the spares. - texture/usage_shadow.rs: the usage shadow is a OnceLock read without a lock, made under its own mutex, and counted on the device once readable. - residency.rs: Residency::shadows walks the textures alone, in the order they were made resident. - WorkCounts::resident_textures_looked_at counts the looks. Bound textures are still looked at per command, now without a lock each. The same copies, barriers and announcements at the same commands. Render's draw and tile dispatch keep calling shadow_uses (render code; they can take ResidentShadows the same way). Check that fails without it: runtime_lane::dispatch_work::dispatches_list_what_their_encoder_made_resident_once_a_change now also makes 16 textures resident and counts the looks: (1, 0 per offset move, 1 after a buffer made resident); with the list made at every dispatch, each offset move looks again (1 for 0). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (1b3fe1c315) and after interleaved twice, us per dispatch (medians of 3 rounds): | workload | before | after | |---|---:|---:| | dispatch_resident_textures_4096 | 35.4-35.7 | 0.76-0.78 | | dispatch_resident_textures_256 | 2.63-2.69 | 0.64-0.65 | | dispatch_resident_256 | 0.633-0.640 | 0.640-0.653 | | dispatch_resident_moving_256 | 1.569 | 1.575-1.581 | | dispatch_static | 0.655-0.669 | 0.673-0.676 | Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 533/535 (the two failing the same at the base); the shadow, usage-shadow and carrier lanes 52/52. (cherry picked from commit b01779101c7b6e05d435274ddd929da7441816df) (cherry picked from commit 0c35f13441cf9d4c8d1b788632b5edf65afaa78f) (cherry picked from commit 686656d2b2899865da6e5425125cdaf973e154c4) (cherry picked from commit a984fef4d783b985883318703f93b0f72c55e90d) |
||
|
|
255bf1401b |
host_ab: dispatch_resident_textures variants, 256 or 4096 textures made resident
The encode workload's dispatch_resident_textures_256 and _4096 make 4-by-4 RGBA8 textures resident (Gpu::use_textures, useResources:count:usage: on both sides) before the dispatches, so the per-command look at the resident textures (their shadows, their carriers) is measured. Verified: the example builds (clippy, all features). (cherry picked from commit 0e5d4af70d96037a4e4b37b20e385f94b883f1a2) (cherry picked from commit ac301360190ebbcce5a78c779c380a34c17c7326) (cherry picked from commit 1aba21ca33e4d78094ec95b1c02a5fb6e533d9ca) (cherry picked from commit e55669c56870f4127a1a264e447c8dff7bb2cf4f) |
||
|
|
a4546da224 |
Compute dispatches keep their bind state between dispatches, and pipelines keep four plans
A compute encoder's dispatch that did not take what the last one settled rebuilt its whole bind
state, listing every resource the encoder made resident, and each pipeline state kept one plan, so
per-dispatch cost grew with the resident count and two encoders of one pipeline with different
resident sets planned again at every dispatch.
- compute/live.rs: the encoder keeps its bind state (LiveDispatch), brought in place at each
dispatch as a render encoder's draw does (live_bind.rs): the kernel table is read again only
where its stamp, interface, sampler maps or no-copy moves changed, and only the slots calls
changed where the table keeps them; the used resources are listed again only where the
residency's generation, a no-copy move or an indirect command buffer's slot changed; the shape
is kept while no change may have changed it. Debug builds check the whole state against one
built from scratch at every dispatch. The state goes to the device's spares at the encoder's
end (four kept), with its memo let go first, so a kept state holds nothing alive.
- DispatchMemo stays the "nothing changed" shortcut, now owned by the live state.
- pipeline/mod.rs: a pipeline state keeps four plans, least recently used first out, found by
identity and then compared in place (BindState::position_of_shape), with the same key.
- The ICB and host-step dispatch paths keep the fresh path.
- WorkCounts: dispatch_shapes_made, dispatch_shapes_found, dispatch_used_resources_listed.
- residency.rs: the Generations doc says what is listed once per change, and where.
The same Vulkan commands, barriers, notices and refusals at the same calls; retains unchanged.
Checks that fail without it:
- runtime_lane::dispatch_work::dispatches_list_what_their_encoder_made_resident_once_a_change:
with the residency reuse forced off, every offset change lists again ((1,0,1) for (0,0,1)).
- dispatches_take_what_their_state_planned_for_the_same_shape gains a third encoder of the first
shape: with one kept plan it plans again ("an encoder of the first shape", 0 for 1).
Release, M3 Max, MoltenVK 1.4.2, host_ab encode (3 rounds, median, us per dispatch), base 096b427da3:
| workload | before | after |
|---|---:|---:|
| dispatch_resident_moving_0 | 2.090 | 1.757 |
| dispatch_resident_moving_16 | 2.570 | 1.754 |
| dispatch_resident_moving_256 | 11.472 | 1.764 |
| dispatch_resident_moving_4096 | 209.803 | 1.799 |
| dispatch_offsets | 2.186 | 1.929 |
| dispatch_churn | 2.164 | 1.928 |
| dispatch_static (memo hit) | 0.846 | 0.848 |
| dispatch_resident_4096 (memo hit) | 0.961 | 0.807 |
host_ab calls: many_dispatch 6397 -> 4095 ns and 74 -> 49 allocations; many_dispatch_resident
5331 -> 3496 ns, 78 -> 50; wide_dispatch 2825 -> 2293 ns, 40.9 -> 36.6. percall allocation
counts unchanged.
Verified on MoltenVK (with the tracker change that follows also applied): the runtime GPU suite
1504/1504; the validation runtime lanes, but for two failures that fail the same at the base
(function_tables::tables_and_handles_answer_as_metal_s_do,
predication::every_dispatch_form_runs_in_each_pass_past_the_copies).
(cherry picked from commit 8f350dddbe5c1cb3f5a486413b19ff23aa4f16c6)
(cherry picked from commit 5b3671810c7d658fd4223d5a6c97c1e33443e8a2)
(cherry picked from commit 03fe129bd31904ddf5013631ce104bb47438eaa9)
(cherry picked from commit 6457fa412ca00092e5b0a8603e05cbd99cd130b4)
|
||
|
|
f2097a3b2e |
host_ab: dispatch_resident_moving variants, the output's offset moved each dispatch
The encode workload's dispatch_resident_moving_{0,16,256,4096}: as many
dispatches of the tiny kernel after none, 16, 256 or 4096 buffers made
resident, each after set_buffer moved the output buffer's offset. The
existing resident variants change nothing between dispatches, so every
one after the first takes the dispatch memo and none shows what a
dispatch that changes a binding costs at a resident count: these do.
Verified: built in release; the variants run on the M3 (MoltenVK) and
print dispatch_resident_moving_*_encode.
(cherry picked from commit fea089d4527bab194df36adb68b1b02bdc7d7cc3)
(cherry picked from commit e5732c19aa1b21c56cc5fa8d1bb1c3ce21e32c0e)
(cherry picked from commit 09da9fc3166c4f3c8b2e4e26d5fe68620228014b)
(cherry picked from commit 09dab5495d35b14ed952fa67257809aa271e6357)
|
||
|
|
5bf9843569 |
host_ab: offset-only draws, and draws on 1 to 8 threads at once
The encode workload gains `draw_offset`: one vertex buffer's offset changes before each draw (`setVertexBufferOffset:atIndex:`), the consumer's measured per-draw shape, between `static` (nothing changes) and `bind` (buffer and texture change). A `threads` workload draws the encode workload's static and offset draws on 1, 2, 4 and 8 threads at once, each through a command queue of its own (`Gpu::with_own_queue`) into its own target, of its own rectangles, texture and sampler, once through one shared pipeline state and once through a pipeline state of each thread's own. Per case, over 3 runs: the draws a second of all threads together, each thread's CPU time per draw and the process's. The trait's device, libraries and render pipeline states are `Sync` for it (Metal's are; Metal's buffers and textures are not marked so in objc2-metal, which is why each thread makes its own). Verified: clippy -D warnings on the example (both sides compile on macOS); `draw_offset` ran on the M3 Max and the RTX 5080 Laptop (numbers in the next commit). (cherry picked from commit 5ae9a2d98135b7129b0f44b4ab2b98982f2588d7) |
||
|
|
d5c71b9848 |
Add the submit_path example: a command buffer's fixed cost on the submit and completion path
What: crates/metal2vulkan-runtime/examples/submit_path.rs, registered in the crate's manifest (autoexamples is off). Modes: latency (one thread commits a 16-byte fill with a scheduled and a completed handler, or with --seen a completion-seen handler instead, and blocks on a condition variable the handler signals: commit to handler start at idle gaps of 0, 100 us, 300 us and 2 ms, p50/p90/p99 over 2000), cpu (the same command buffers as fast as the slots allow, never waited for: command buffers a second and CPU per command buffer by thread group, from /proc/self/task/*/schedstat on Linux, else the process's CPU less the committer's), empty (commit and wait of a command buffer with nothing encoded, back to back and at a 300 us gap; then never waited for, with the queue submissions made). Why: the consumer's per-command-buffer path (record, add handlers, commit, never wait) had no measurement in the tree that runs on both the M3 Max and Linux; host_ab is being changed elsewhere. Verified: built in release on the M3 Max and run there (the numbers are in the change reports, not here); clippy clean with all targets. (cherry picked from commit 067b6a7792210909bbf4f1e66bf2eb9b39334c0d) |