Files
metal2vulkan/crates
Anees Iqbal c1d9da2653 Kept variants prune only the region keys the device ledger let go, not every kept pipeline
A full region ledger (`pipeline/region_ledger.rs`) lets one key go at each region pipeline a
dispatch makes, and the lookup after it settled the kept variants by walking every region pipeline
every kept instance holds, asking the ledger of each (its lock, a clone of the key's two Vecs and
a hash): `compute::record` -> `begin_region_pipeline` -> `region_ledger::let_go` ->
`Kept::settle` -> `Entry::prune` -> `RegionLedger::lists`. On the consumer's Iris Xe, a guest
compute benchmark's timed pass spent 0.70 CPU-s there (0.46 at the earlier pin), 36 us a
dispatch in one workload (6 at the earlier pin), 12 to 30 in four others.

Now the ledger names each key that leaves its list, popped past its bound or forgotten by its
memo's eviction or removal (`Unlisted`), and the settle asks the ledger of those keys alone,
destroying a kept instance's region pipeline at a key not listed again. What triggers a prune
(keys past the bound) and what a kept instance keeps (only the region pipelines the ledger lists)
are unchanged. The named keys are bounded at the ledger's bound; past it (a run of host steps'
makings, which settle nothing) the settle walks every kept region pipeline, as before. A kept
instance destroyed whole un-lists its keys without naming them (`forget_destroyed`).

Test: region_widths' `a_full_ledger_s_settle_looks_at_the_keys_it_let_go_alone` keeps a released
kernel's 256 region pipelines under a device bound of 256, then makes another kernel's 64 keys,
each letting one go: the settles must ask the ledger of at most 64 keys (a test-only count of
the prune's lookups), and the kept instance must hold 192.

Verified (msi, lavapipe, m3-max-30414 at 0674dd4287, the same code but for one line: a drain
of the named keys, now `mem::take`, as clippy asked): the new test and region_widths, kept_variants,
compute, compute_bind_memo, compute_instantiated, compute_parked, dispatch_pending,
dispatch_tracking, spares_compute and pipeline::kept: 22/22. The negative control (the whole walk
at each prune, steelbrain/gbdisp-ctl) and the release A/B of both run in m3-max-30415. No
WorkCounts field, Degradation kind or public item changes.

Landed (main): touched tests 22/22 on lavapipe in m3-max-30414 at
0674dd4287 (one clippy line apart). Clippy rerun, the hand negative
control (steelbrain/gbdisp-ctl 3ae942101c, expected 14,368 lookups) and
the release A/B (m3-max-30415) run after landing. No RUNTIME bump: the
same region pipelines are destroyed at the same prunes; answers, recorded
commands and WorkCounts are unchanged.
2026-11-14 15:32:44 -08:00
..