Files
metal2vulkan/docs
Anees Iqbal f19c613fe1 RUNTIME 2489: A compute or render encoder's core is made in the box it lives in: one 3 KB copy per encoder fewer
EncoderCore (2984 bytes, -Zprint-type-sizes on msi) was built by value in
EncoderCore::open, copied out of it in the returned Result, and copied again
into its box (EncoderCore::boxed / boxed_in) by the compute and render opens:
two 3 KB memcpys per encoder. A pinned LBR profile of a guest-shaped compute
stream (dispatch_chain --host 400 --only encoders --dispatches 5 --groups 64
--states 3 --binds tex-moved, msi lavapipe) put libc copies under
EncoderCore::open (~110 ns) and open_compute (~98 ns) per guest dispatch, one
encoder each.

EncoderCore::open_placed takes a place closure that puts the core where it
lies, the box for compute (parked room or the device's spares) and render
(spares), so the core moves once. open keeps the by-value form for the blit
encoder (HeldCore). Nothing else changes: the same fields, the same order
under the same lock, the same boxes.

Test: tests::compute_parked::a_compute_encoder_core_lies_in_the_box_its_command_buffer_parked (three
encoders of one command buffer find their core at one address; it pins where the core lies, not the
copy count). RUNTIME_VERSION 2489.

Verified: msi m3-max-38102: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0;
lavapipe debug (cfg m2v_cpu_icd) compute, dispatch, encoder, tracker and render suites 190/190. Pinned
interleaved A/B (msi lavapipe, release, taskset -c 0-7, 5 base/tip pairs, guest shape dispatch_chain
--host 400 --only encoders --dispatches 5 --groups 64 --states 3 --binds tex-moved, --runs 30): the open
call 640 -> 574 ns per guest dispatch (-66 ns); thread_cpu per dispatch within run-to-run noise (6137
vs 6240, range 5615-6681). Profile at the base (m3-max-38071, LBR): open copied the 2984-byte core out in
its Result (~110 ns) and open_compute again into its box (~98 ns).
2026-11-16 15:48:59 -08:00
..