Lands steelbrain/orch-stitched-copies (cherry-picked a779b1824a..c5192a2cae):
- a commit's copy in asks only the copies its command buffer's used keys reach (every copy where a
command may reach memory no use names); merge back was already by written keys;
- a few changed pages find the bytes they meet in a copy stitched from thousands of runs through
an index of the runs by offset, not a walk of every run;
- a copied host buffer reads the caller's pages before it maps its own memory, so a mapping the
runtime makes cannot fill an unmapped page of the caller's and make a buffer Metal refuses.
Verified, release, gem10 (m3-max-5734), the stitched bench (512 copies x 640 runs, 1280 MiB),
base 018900246e vs fix, medians of 15, 3 alternating rounds:
0 pages written: 0.224 ms -> 0.003 (8 copies used) / 0.031 (every copy reached)
16 pages written: 1.21 ms -> 0.005 / 0.266
256 pages written: 2.37 ms -> 0.039 / 2.23
4096 pages written: 6.19 ms -> 0.156 / 6.0
Lavapipe (ms01 m3-max-5735): copied, dirty, host_ram_copy, host_memory, degrade_notices 154/154.
M3 (m3-max-5724): host_memory's half-mapped refusal 0 failures in 20 (it failed before the fix).