RUNTIME 2270: an encoder's open looks at the encoders ended since the open before, not every earlier one

Every compute and render encoder's open built what it starts with (the shadowed textures
its command buffer's ended encoders made resident) from scratch: the command buffer's
joined residency, then each ended encoder not joined yet, one shadows_onto each. The joined
residency advances only where the command buffer's own work reads it, so a command buffer
of n compute encoders walked n(n-1)/2 ended encoders: at Geekbench Fluid's ~2300
one-dispatch encoders a command buffer, the open grew to ~2.9 us a dispatch on lavapipe
(866 ns at 6 encoders), and reims's decodeperf profile (M3, MoltenVK) put
inherited_residency and shadows_onto at 762 of open_compute's 874 samples.

The command buffer now keeps what its next compute and its next render encoder start with,
with the number of ended encoders it took in (State::inherits): an open takes in the
encoders ended since, each once, in the order they ended, and hands out a copy (a count:
the residency's resources are shared until one copy changes). It is let go of where the
joined residency or an ended encoder's residency may change: joined_residency (every read
that joins, the heaps' textures made since, the first submission, a re-encode) and a
re-encode's splice of an encoder's residency. The result is the one the walk made: the
joined residency's shadows first, then each ended encoder's onto them in order, usages and
stages joined as before.

Counted: WorkCounts::ended_residencies_looked_at (an ended encoder's residency looked at for
an open's inherited shadows). Tests (tests::joined_residency): 64 encoders with a read of
the residency after the 32nd look at 62 residencies (the walk: 992); a shadowed texture made
resident for reading, then writing, reaches the next encoder with its usage widened.

RUNTIME_VERSION 2270: an encoder open inherits residency incrementally (the same result).

Also (compenc): dispatch_chain gains --host (each encoder call and the commit timed on the calling thread, commit_and_submit, per-thread CPU on Linux), --binds 4|tex (four buffers, or the Geekbench compute shape: 2 textures, a sampler, an output buffer and setBytes) and --pages (buffers over host pages).

Verified (compenc, msi lavapipe): touched tests 165/165 (m3-max-28544) incl. tests::joined_residency: 64 encoders with a residency read after the 32nd look at 62 ended residencies; a shadowed texture made resident READ then WRITE reaches the next encoder as written. Negative control (drop the slots every open, m3-max-28547): 992 vs 62, fails. Release dispatch_chain --host --only encoders --dispatches 2300 --binds 4, ns a dispatch: open 2862 -> 573, encode 7332 -> 5004, thread CPU 7532 -> 5205 (jobs 28534/28545); ended_residencies_looked_at 1.00 a dispatch. SR-like (6 encoders a CB) unchanged (866 -> 913). Clippy x3 and rustdoc run after landing.

Squashed from steelbrain/compenc d0d524b6de..84b304c5e3.
This commit is contained in:
Anees Iqbal committed 2026-11-14 01:18:32 -08:00
1 parent 343a4f95e1
commit d166086d92
7 files changed
+625 -26

No files matched your search

@@ -626,6 +626,8 @@ impl State {
segment.executions_at = moved(segment.executions_at);
}
}
// What the next encoders start with is found again from the residencies as they are left.
self.inherits = [None, None];
let record = &mut self.ended[at];
record.executions = first.start..first.start + count;
record.keys = keys;