diff --git a/crates/reims-vgpu/src/backend/vulkan/engine/gather_phase.rs b/crates/reims-vgpu/src/backend/vulkan/engine/gather_phase.rs index c3066363a..2900b516d 100644 --- a/crates/reims-vgpu/src/backend/vulkan/engine/gather_phase.rs +++ b/crates/reims-vgpu/src/backend/vulkan/engine/gather_phase.rs @@ -34,6 +34,46 @@ //! factor and a reader comparing one to `record_us` per draw would conclude the //! parts do not sum. //! +//! # What it said, and why it was worth building +//! +//! Two driven macos-13 sustained-animation boots, ~21 000 dispatches a census +//! second each, agreeing to a hundredth of a microsecond: +//! +//! ```text +//! us/dispatch share +//! record 0.376 39 % +//! plan 0.350 37 % +//! stage 0.150 16 % +//! dset 0.082 9 % +//! 0.959 +//! ``` +//! +//! **The descriptor set is already nearly free, and the fix this crate had +//! written down was aimed at it.** `env::COMPUTE_GATHER` named the destination +//! arena — the change that makes all three bindings constant so a draw needs one +//! set instead of 1.4 — as "the candidate that survives the arithmetic without a +//! reading". It attacks the 9 % column. Recycling the sets, which cost four +//! lines, had already taken `vkAllocateDescriptorSets` and its matching free out +//! of the steady state, and what is left of `dset` is one +//! `vkUpdateDescriptorSets` of three buffers. +//! +//! The two that matter are: +//! +//! * **`plan`, and it is entirely this crate's own code.** No driver call is in +//! it: a `Vec` built from the copy regions, a second `Vec` inside +//! [`super::guest_scatter::build_gather_run_tables`] holding those runs with +//! their two indices exchanged, and the table's own `Vec` — three heap +//! allocations and three passes over ~13 runs, to produce ~200 bytes. +//! * **`record`, which is four driver calls** — bind pipeline, bind set, push, +//! dispatch. The pipeline bind is the same handle every time and only the +//! first of a draw's dispatches needs it. Beyond that this column falls only +//! with the dispatch *count*, which is what the destination arena would buy +//! after all — 1.4 down to 1.0, so ~30 % of it, and not the 9 % column it was +//! proposed for. +//! +//! `stage` at 0.150 is the shared run-table arena, already amortised over a +//! draw's 1.4 dispatches, and there is nothing left in it to remove. +//! //! # This measures the planning, not the copy //! //! Every part here is CPU time spent *arranging* a copy the GPU makes later, in diff --git a/crates/reims-vgpu/src/backend/vulkan/engine/pools/buffer_gather_working_set.rs b/crates/reims-vgpu/src/backend/vulkan/engine/pools/buffer_gather_working_set.rs index c38071f2b..2110b8c0f 100644 --- a/crates/reims-vgpu/src/backend/vulkan/engine/pools/buffer_gather_working_set.rs +++ b/crates/reims-vgpu/src/backend/vulkan/engine/pools/buffer_gather_working_set.rs @@ -41,6 +41,40 @@ //! one. Both are on the same line for that reason, and `gathers` beside them is //! what makes the recurrence rate readable as `1 - distinct / gathers` for this //! window rather than quoted from a boot nobody can re-run. +//! +//! # What it said +//! +//! Two driven macos-13 sustained-animation boots, a census second each: +//! +//! ```text +//! distinct=1897 mib=287.7 gathers=20771 mib_moved=3520.5 recur=0.909 dropped=0 +//! distinct=1781 mib=271.7 gathers=19452 mib_moved=3307.5 recur=0.908 dropped=0 +//! ``` +//! +//! Three things follow and they do not all point the same way. +//! +//! * **A cache of unbounded size would serve 91 % of the gathers**, which is +//! ~3.2 GB/s of GPU copy and ~90 % of this rail's ~427 000 transfer regions a +//! second. That is the largest single removable item this device has, on the +//! arithmetic that `render_writeback`'s own ablation established — region +//! count, not bytes, is what the rail is bound by. +//! * **It is 91 % and not the 99.2 % the buffer rail is usually argued from.** +//! The older figure came off a window-drag probe and a census that no longer +//! exists; this is the sustained-animation population. Quote the one whose +//! probe is named, per `AGENTS.md`: they are two workloads and both are real. +//! * **Unbounded means 288 MiB of device-local memory**, held across +//! submissions, on a host whose whole gather pool is transient today. That is +//! the number a cap has to be argued against, and it is large enough that the +//! cap will bind — so the eviction policy is part of the design and not a +//! detail to add later. `dropped=0` says the 1 897 is a count and not a floor. +//! +//! Recurrence is about **keys**, not bytes: it says the same window comes back, +//! not that its contents are unchanged. What would make a hit sound is +//! [`crate::runtime::gather_witness`], which already carries exactly this +//! argument for the sampled rails — the hypervisor dirty bitmap for guest CPU +//! stores and [`crate::runtime::host_writes`] for this device's own. Its +//! `MAX_TRACKED_WINDOWS` is 256 against the 1 897 here, so adopting it is a +//! resize as well as a wiring. use std::collections::HashMap;