Each copy by a kept plan uploaded the plan's table into its command buffer's arena: 8100
entries of 16 bytes for a layer, past the arena's 32 KiB so a chunk of its own (a new Shared
buffer) and a 130 KB copy, 22.5 us of a 74 us call at 1 chunk and of 191 at 128 (probe
m3-max-32988, steelbrain/dl2-probe4, not landed), for bytes the plan held and never changed.
KeptPlan keeps them in a buffer of its own (table_kept, a OnceLock), made at its first reuse
by KeptPlan::table_buffer: the arena's class (Shared, default cache, untracked, by
unzeroed_buffer_with, so the GPU reads it from the same memory), written once before any
command reads it and never again. record_dispatches takes the table as bytes to upload (the
full path, as before) or as that buffer (Table::Kept), which each command buffer that binds
it retains, so a plan the LRU or the RAM's end lets go of frees it once they complete. Two
encoders' first reuses at once keep the one set first. A plan never reused makes none. The
tables count in MOST_PLAN_BYTES already, so the device memory kept is at most that and each
buffer's rounding. A recovery carries the RAM's use to a new RamOnDevice on the next
generation (RamUseCell::carry), whose plans start anew, so no old generation's table is bound.
New counter WorkCounts::host_ram_copy_tables_kept; api_signatures.tsv blessed; the module
docs, KeptPlan's and HOWTO's say what memory the plans keep.
Tests (device): a_plan_keeps_its_table_in_a_buffer_from_its_first_reuse (planned, first reuse
keeps it +1, later reuses +0, bytes each time); a_kept_table_a_command_buffer_bound_outlives_
its_plan (command buffers held by a shared event bind it, eight other copies push the plan
out, the bytes after the signal); a_recovery_starts_a_ram_s_plans_and_their_tables_anew
(recover_for_test: the first reuse after keeps a table of its own).
Verified: m3-max-33015 (msi, at 612f09e48a): the runtime crate on lavapipe 2811/2811, clippy
cpu-icd, plain and gpu configurations clean, Rustdoc clean; the API tests 15/15 (m3-max-33048),
whose recovery test printed no skip line. Medians (m3-max-33017, msi, before/after interleaved,
us per call): one chunk, copy alone 60.6/59.6 -> 44.4/41.6, the copy after a fill 58.1/58.2 ->
44.3/41.6; 128 chunks about 10 us lower on average, within the runs' spread.