Files
metal2vulkan/docs
Anees Iqbal a2b99ee4f6 Report each write to a log of host pages in one batched call
The consumer measured DirtyCommit::report_host_writes at 77.7% of its present path on the
RTX 5080: PagesLog::wrote_but called the source's hook once per run of the object's window in
a guest RAM's log, about 9,000 calls a report for a 3840x2400 BGRA8 surface over scattered
4 KiB pages. PagesLog::wrote, wrote_as and a shadow's report did the same.

DirtyPages gains wrote_runs(&[Range<u64>]) and wrote_runs_as(&[Range<u64>], writer), whose
defaults call wrote or wrote_as once a run, in order, so existing sources keep working. Every
write the runtime reports now comes to each log as one call carrying all its runs there: each
range of a command buffer's writes in place (the bytes no shadow wrote, the gaps between the
shadows' writes, in order), each shadow's write to the other logs, a copied host buffer's merge
back (all its blocks, one call per log and copy, where it was one call per run of each block), a
CPU write, and a shadow's copy back or merge (one run). For each source, the runs, their order
and their writers are what the per-run calls carried. The runs gather in a thread-local buffer
kept for the thread's next report, so a warm report allocates nothing (wrote_but also no longer
builds a Vec per range to cut out the shadows' writes: one sorted list, swept). The internal
DirtyHook calls the batched forms alone; its per-run methods went.

The read side needs no batching: changed and changed_except already hand back every run of a
query in one call. watch stays per run: a copied host buffer watches its runs once, at its
making, not per report.

Docs: the trait's contract for the runs (never empty, each non-empty, in the order of the
object's bytes, apart in the object, not sorted by offset over scattered pages), its Batches
paragraph, HostMemory::with_dirty_pages, the runtime README and HOWTO's guest RAM log; the
api_signatures table blessed (two trait items).

Tests: dirty_runs checks, over a memory log and a guest RAM log of 24 scattered pages, that a
command buffer's report, a write with a shadow's merge inside it, a copy's merge back of three
blocks and a CPU write each reach each log in one call per range carrying exactly the runs
worked out from the window, and that a log keeping only wrote/wrote_as hears every run in the
same order with the same writers. The bench gains a batched trivial log.

(cherry picked from commit b69d6b70c49af0b0ab08db5fe2f8b78cd61ed2fe)
2026-11-05 18:59:20 -08:00
..