📝 Three quarters of the buffer gather's repeat windows have new bytes in them, so the content cache is closed and the 91% recurrence was never the size of the prize

x86 macOS / Linux Vulkan, macos-13, sustained-animation probe, two driven boots,
21 204 real comparisons. Documentation only.

    boot     audit_ok   audit_moved   seed   restart   unchanged share
    1           2 827         8 771      7       436            24.4 %
    2           2 915         6 691      8     1 100            30.3 %

A comparison is a fold of a sampled window against the previous fold of the same
window with no declared write between them. Unlike `gather_witness`'s audit —
whose comparison ran zero times across three consecutive boots, so its
`unsound=0` was never a measurement — this one ran twenty-one thousand times and
`restart` is 4-10 % rather than the dominant column.

## It closes the declaration-invalidated cache

Three quarters of the windows the guest declared nothing about had their bytes
change between two binds. One boot read `quiet_rate=1.000` with `wrote=17` in a
census second whose audit found 379 moved windows against 138 still ones. A
cache invalidated by `writeInvalidates` would have served stale vertex data on
most of its hits, which is a wrong frame that then persists.

That is the cheap route closed. The sound route — the hypervisor dirty bitmap —
remains barred by its own cost: `MAX_TRACKED_WINDOWS` is 256 because
`reims_vgpu_dirty_harvest` walks every armed page on the BQL thread at each
register write, and this rail's ~1 900 windows of ~38 pages would put ~72 000
pages into a walk the whole VM waits on.

## And it retires the number the roadmap was built on

`buffer_gather_working_set` measures 91 % of gathers as repeats of a window
already assembled, and this crate's notes have been reading that as the size of
the prize — "the largest single removable item this device has". It is not: a
repeat whose bytes moved must be re-copied by any cache, sound or not. At ~27 %
of repeats unchanged, the ceiling on a content cache with a perfect oracle is
0.91 x 0.27 = 25 % of this rail's gathers — ~5 100 a second of ~20 800, and
~105 000 of its ~427 000 transfer regions. Against ~288 MiB of device-local
memory held across submissions and a harvest cost over 1 900 windows, that is a
bad trade and it is now written down as one.

`recur` is the population a cache would be *asked* about and never the
population it would serve. All three module docs now say so — the working-set
census, `gather_phase`'s "what to do next", and the freshness split itself.

So three quarters of this rail's traffic is the guest genuinely changing its
vertex and constant data. The way to make that cheaper is to move it more
cheaply, which is what the compute gather does, and not to try not to move it.
The remaining change on that rail is the destination arena, worth ~35 % of one
of a dispatch's four cost columns — which should be weighed against the
writeback rail, whose own ablation is worth ~30 Hz.

Also fully-qualifies the intra-doc links these two new modules add, which do not
resolve from a `//!` doc as bare names.

Tests: unchanged, 1949 passed / 0 failed.

Not verified: macos-13 and one probe. The audit samples one window in 64 by a
finalised hash, so it is a spread of the population rather than all of it; and
it cannot distinguish a window whose addresses were re-resolved from one whose
bytes were rewritten — both are cases a cache may not serve, so both count as
moved, which makes 27 % an upper bound on the unchanged share rather than a
lower one.
This commit is contained in:
Anees Iqbal committed 2026-08-11 11:17:01 +03:00
1 parent 474858f14c
commit 69273d22b0
4 files changed
+67 -21

No files matched your search

@@ -104,13 +104,18 @@
//!
//! # Which is why the next change is not in this file
//!
//! Fewer dispatches has a floor of one per draw (the destination arena, ~35 %
//! of `record`), and a ceiling of **none at all**:
//! [`super::pools::buffer_gather_working_set`] measured 91 % of this rail's
//! gathers as repeats of a window it already assembled. A content cache removes
//! the dispatch, the run table, the descriptor set and the GPU copy together,
//! and it makes every column above moot rather than smaller. Build that before
//! anything else here.
//! Fewer dispatches has a floor of one per draw — the destination arena, ~35 %
//! of `record`. It does **not** have a ceiling of none: the content cache that
//! would have removed the dispatch, the run table, the descriptor set and the
//! GPU copy together is closed, because
//! [`crate::runtime::buffer_gather_freshness`]'s audit found only ~27 % of this
//! rail's repeats unchanged. Three quarters of it is the guest genuinely
//! changing its vertex and constant data, and moving those bytes more cheaply is
//! what this rail is for.
//!
//! So the destination arena is the remaining change here, and it is worth ~35 %
//! of one of four columns. Weigh that against the writeback rail, whose own
//! ablation is worth ~30 Hz, before spending a day on it.
//!
//! # This measures the planning, not the copy
//!
@@ -53,11 +53,16 @@
//!
//! 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.
//! * **A cache of unbounded size would be *asked* for 91 % of the gathers.** It
//! would not serve them. `crate::runtime::buffer_gather_freshness`'s content
//! audit — 21 204 comparisons over two driven boots — found only **~27 % of
//! repeats unchanged**, so the ceiling on a content cache with a perfect
//! oracle is `0.91 x 0.27 = 25 %` of the gathers, not 91 %. A repeat whose
//! bytes moved has to be re-copied by any cache.
//!
//! Read `recur` as *the population a cache would be asked about* and never as
//! the population it would serve. This distinction is the whole reason that
//! audit exists: the number here was being quoted as the size of the prize.
//! * **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
@@ -10,7 +10,7 @@
//! on whether the *bytes* moved in between, and nothing has measured that.
//!
//! This crosses the two. For each bind that takes the gather rail it compares
//! the owning buffer object's [`super::buffer_write_gen`] stamp against the one
//! the owning buffer object's [`crate::runtime::buffer_write_gen`] stamp against the one
//! this window carried the last time it was gathered, and reports the split:
//!
//! | route | meaning |
@@ -84,16 +84,52 @@
//!
//! So the 86-89 % above is **not** a licence, and the two orders of magnitude
//! between the boots' bump rates is the reason to say so out loud rather than
//! quote the higher one. The next instrument is a content audit on the same
//! shape [`super::gather_witness::AUDIT_STRIDE`] uses: fold a sampled `quiet`
//! window's bytes and check whether they moved. If they did, this design is
//! closed and the cache needs the hypervisor half after all — which is a
//! different and much more expensive problem, because that bound is a harvest
//! cost and not a resize.
//! quote the higher one.
//!
//! # The audit ran, and it closes the design — twice over
//!
//! Two driven macos-13 boots, 25 census seconds each, **21 204 real
//! comparisons** (a fold of a sampled window against the previous fold of the
//! same window, with no declared write in between):
//!
//! ```text
//! audit_ok audit_moved seed restart unchanged share
//! boot 1 2 827 8 771 7 436 24.4 %
//! boot 2 2 915 6 691 8 1 100 30.3 %
//! ```
//!
//! Unlike [`crate::runtime::gather_witness`]'s audit — whose comparison ran **zero**
//! times across three consecutive boots, so its `unsound=0` was never a
//! measurement — this one compared twenty-one thousand times, and `restart` is
//! 4-10 % rather than the dominant column. The reading is real.
//!
//! **First conclusion: the declaration is not a complete account.** Three
//! quarters of the windows the guest declared nothing about had their bytes
//! change between two binds. One boot read `quiet_rate=1.000` with `wrote=17` in
//! a census second whose audit found 379 moved windows against 138 still ones —
//! which is exactly the false positive this module's wiring check was written to
//! catch, arriving through the other door. A cache invalidated by
//! `writeInvalidates` would have served stale vertex data on most of its hits.
//!
//! **Second conclusion, and the larger one: there was never 91 % of work to
//! remove.** `buffer_gather_working_set` measures 91 % of gathers as repeats of
//! a window already assembled, and this crate's notes have read that as the
//! size of the prize. It is not: a repeat whose bytes moved has to be re-copied
//! by any cache, sound or not. **~27 % of repeats are unchanged**, so the
//! ceiling on a content cache with a *perfect* oracle is about
//! `0.91 x 0.27 = 25 %` of this rail's gathers — ~5 100 a second of ~20 800, and
//! ~105 000 of its ~427 000 transfer regions.
//!
//! Against that, a sound cache needs the hypervisor half (a harvest cost over
//! ~1 900 windows, not a resize) and ~288 MiB of device-local memory held across
//! submissions. **Do not build it.** Three quarters of this rail's traffic is
//! the guest genuinely changing its vertex and constant data, and the way to
//! make that cheaper is to move it more cheaply — which is what the compute
//! gather does — rather than to try not to move it.
//!
//! # Why the hypervisor witness is not the instrument here
//!
//! [`super::gather_witness`] answers the same question soundly for the sampled
//! [`crate::runtime::gather_witness`] answers the same question soundly for the sampled
//! rails, and its `MAX_TRACKED_WINDOWS` of 256 is a **harvest** bound rather
//! than a memory one: `reims_vgpu_dirty_harvest` walks every page of every armed
//! set on the BQL thread at each register write that hands the device work. The
@@ -45,7 +45,7 @@
//!
//! One entry per `(task, object)` the guest has declared a write to. A task's
//! entries go when the task does, which is the same lifetime `bound_buffers`
//! retires on and the only announcement this device gets. Past [`Self::MAX`] the
//! retires on and the only announcement this device gets. Past [`BufferWriteGens::MAX`] the
//! map is **cleared** rather than partially evicted: forgetting one object would
//! make its next comparison read as clean, which is the direction that reports a
//! cache hit for a window whose bytes moved. A clear makes every comparison read