Files
metal2vulkan/docs
Anees Iqbal 347b9870c4 Keep a host step's chunks only where two steps read the records alike, and copy the residency once an execution
A host step that compared a kept chunk's records and found them changed recorded every chunk
apart again, each into a secondary of its own, to keep: on the replayed-frames page at 5000
resident pairs on the M3 that cost 23.3 ms a step where the records changed at each frame,
against 18.3 ms recorded inline (one binary, keeping switched off by a temporary patch). Phase
timers put the difference in a copy of the residency per chunk and its drop (2.9 ms over 20
chunks), a fresh 11 MB copy of the records (about 1.1 ms more read), resolutions and contexts.

Two changes:

- RenderExecution::steady decides before recording. A step keeps chunks only where the records
  hold, chunk by chunk, the bytes a kept recording was made from or else those the last step
  read, compared whole. Else the execution records inline, as before keeping, and each chunk's
  records are copied into the bytes the last step read (IndirectCommandBuffer::
  written_bytes_into, no new pages after the first), for the next step's comparison; a recording
  whose records changed is forgotten and counted recorded again. So records that change at each
  step cost the step one copy of them beside today's inline recording, and a step records apart
  and keeps only what two steps read alike. The chunk store keeps those bytes per chunk
  (KeptChunks::look_up_step, read); a chunk recorded apart keeps them as its recording's bytes,
  copying nothing again.
- The chunks an execution records apart carry the encoder's residency from one to the next with
  the bind state (replay_encoder takes it owned), so an execution copies the command buffer's
  residency once, as one recorded inline does.

The kept-steps lane now counts chunks recorded apart to keep (WorkCounts::kept_contexts_made):
the first frame records inline, the second apart, the third runs kept; a records change records
inline, then apart, then kept; another input's change records apart at once; and records that
change at each step record inline each frame, keeping nothing, each frame drawing what a fresh
page draws.

Verified: clippy, plain and under --cfg m2v_gpu, on this Mac. The lanes and the page's timings
on the M3 follow.

(cherry picked from commit b9b1c0aab9728e57e517cb6f0abdfc1df44e9b03)
2026-11-05 02:08:23 -08:00
..