record_host_ram_copy spent most of its encode on per-run bookkeeping (a profile of 8100
single-page runs on lavapipe, release, frame pointers): chunk_ranges' BTreeMap entry a piece, a
Vec and a sort a chunk (46%), in_imports' BTreeMap lookup a piece (14%), the scatter's overlap
check sorting every host range (14%), plan's BTreeMap entry a table entry (10%), and pieces'
binary search over the chunks a run (9%).
- touched_ranges: pieces of whole pages from a page mark their pages in a bitmap of their chunk,
read back in order; only the other pieces (rows inside pages) are sorted. It gives the ranges
chunk_ranges gives, byte for byte (so every use and barrier is as before), and whether two
pieces share a host byte, exactly: a page marked twice, another piece's bytes in a marked page,
or two other pieces that overlap.
- in_imports looks a piece's imports up in a vector by chunk.
- plan buckets its entries by array of imports and window in a vector, in the same order.
- pieces looks for a run's chunk first where the piece before it lies.
Test: copy::tests::touched_ranges_are_the_chunks_ranges_and_their_overlap_in_one_pass (whole
pages, rows sharing a page, overlaps of each kind, and 2000 random mixes over four chunks, against
chunk_ranges and share_a_byte). Timings: see the lane's report.
Evidence (lane jobs, msi lavapipe): m3-max-32324: clippy cpuicd -D warnings 0; host_ram tests 93/93 incl.
copy::tests::touched_ranges_are_the_chunks_ranges_and_their_overlap_in_one_pass (byte-exact ranges and overlap flag vs
chunk_ranges + share_a_byte: whole pages, rows sharing a page, each overlap kind, 2000 random mixes over 4 chunks).
Release medians, one job m3-max-32339, parent's copy.rs vs this, 200 CBs of copy_runs_to_host_ram with 8100 single-page
runs, call CPU: 1 chunk 750.6 -> 351.1 us (92.7 -> 43.3 ns a run); 128 chunks 1523.7 -> 1097.6 us (188 -> 135 ns a run).
Uses and barriers unchanged by construction. 3090 run: m3-max-32374.
Lane commit: 6c02be1492.