The consumer's 4K boot on the RTX 5080 at the stock vm.max_map_count was
unusable past its import gate: about 680 MiB of live copies (2,934 made)
were compared whole at every commit and every completion, costing about
half a core on both sides. Until the GPU copy is wired, three exact cuts,
plus the dirty-log reports change 1 needs (the consumer's audit, A to C).
- Change 3, a page-at-a-time compare (copied.rs sync): each 4 KiB page is
compared whole (slice equality, vectorized), and the byte-exact merge
runs only inside a page that differs. Same bytes as before; unit-tested
against the old routine on random data, both sides changed included.
- A, the copies' merge-back is reported: each copy keeps its pages'
DirtySource and a writer id. sync collects the runs it wrote, and
merge_back reports them with wrote_as before the completion is visible.
Bytes a read-only copy drops are not reported.
- B, the runtime's own CPU writes into logged pages are reported:
replaceRegion into a heap's shadow texture (texture/heap.rs), the argument
encoder and copyParameterDataToBuffer, as buffer_texture.rs already did.
- C, GPU writes into logged pages imported in place are reported: each
command buffer's written uses over memory with a dirty source, as writer 0
(the consumer's own writes, which every copy counts). They are reported at
commit, before signals in the completion turn, and at completion, minus the
shadows' own copy-backs. Collection is on while copies or such imports are
live. Past the use cap, each written import is reported whole. A texture's
use is reported as its whole buffer or heap (correct, coarse). This also
closes the texture-shadow gap for pages reached through two imports.
- Change 1, the log gates the copy in: where a copy's pages have a log
(HostRam::with_dirty_pages, or the object's HostMemory::with_dirty_pages),
a commit compares only the pages the log reports written since the copy
last agreed. It uses one stamp per log and commit for every copy, waited
for as the shadows' gated copy-in waits (DirtyPages::wait). A false wait,
a copy's first copy in, bytes no log covers, and a copy that merged back
1 MiB or more since its last copy in compare everything. The copy in now
runs before the commit's second state-lock block, since it may wait up to
the log's bound.
- Change 2, merge-back skips copies no finished batch may have written. Its
"may write" is the bindings' write answers plus unnamed reach: a command
buffer with a function that reads addresses (a root table), or one that
executes an indirect command buffer, counts every copy as written.
WorkCounts (new): copied_copy_in_bytes_skipped, copied_merges_compared,
copied_merges_skipped. RUNTIME_VERSION 1705. Docs: copied.rs (Cost,
Coherence), dirty_pages.rs' trait doc (what the runtime reports), FAST-PATHS
(copied-host-pages known gap; the shadow gap closed), HOWTO copied host
buffers.
Measured, release, 680 MiB of live copies (2,049), median of 7, copy in /
merge back in ms:
- RTX 5080 laptop host (Core Ultra 9 275HX):
- nothing changed: 231.8 / 231.6 before; 0.16 / 0.00 with all three;
- 1% of pages changed: 233.7 / 233.8 before; 3.43 / 33.0;
- one copy redrawn: 254.6 / 261.6 before; 29.4 / 34.1.
- M3 Max:
- nothing changed: 314.5 / 314.0 before; 0.12 / 0.00;
- 1% of pages changed: 321.4 / 321.4 before; 4.54 / 18.5;
- one copy redrawn: 353.9 / 395.4 before; 39.4 / 54.9.
The merge-back figures are with the batch naming what it writes. A real
frame's skip rate was not measured; the new counters show it.
Verified:
- M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu, under memcap and maclock: the
runtime lib suite passes 1445, 2 skipped.
- RTX 5080 Laptop, NVIDIA 615.71.09, one 42 s hold: copied|dirty_pages|
host_ram|event 101 pass.
- New tests: 6 plain gating and merge-skip tests; a contract test that a
concurrent CPU write survives both ways, log on and off; 7 device tests of
the B and C reports, the gated copy, a read-only batch skipped, and an
unnamed write still merged back.
- Negative controls, each shown failing then passing once restored: gate
forced off; A's report removed; C's registration or completion reports
removed; the shadows' copy-backs not subtracted; B's heap report removed;
merge skip forced off; unnamed reach ignored.
- clippy plain and --cfg m2v_gpu (Mac, and msi niced), rustdoc -D warnings,
api_signatures, api_surface, fast_paths.
Lane commits: ws/cpusync-lane (180fc103c1 .. 59d82299ad, 9 commits).
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: bb00ae47f6, then 2b8ad3ab58 (the re-pin).