Files
metal2vulkan/crates
Anees Iqbal eb25ca898d The tracker orders each command by one use list, kept in the encoder's storage
Each ordered command built its use list twice (EncoderUses::barrier, then record_reaching), each
time through a fresh Vec and a fresh hash map, then a sort. The two lists differ only for
untracked uses.

- tracker.rs: EncoderUses::order compares and records a command in one call. The uses are merged
  in place (merge: a stable sort by key, then each key's equal ranges joined), into two lists the
  encoder keeps and clears per command; the second list (what the command is recorded with) is
  the compared one where every use is tracked, and made apart, in its own kept storage, only where
  one is not.
- encoder.rs: track calls order.

The same uses in the same order, so the same barriers: merging_in_place_keeps_each_key_and_range_once_in_order
checks the merge against the map-based form it replaces over 2000 random commands.

Check that fails without it: tests::tracker::an_encoder_orders_its_commands_in_storage_it_keeps
(with a fresh Vec per command, the storage moves at the second command).

Release, M3 Max, MoltenVK 1.4.2, host_ab, before and after interleaved three times (each a median of
3 rounds):

| workload | before | after |
|---|---:|---:|
| many_blit_copy (ns) | 786-824 | 645-654 |
| wide_blit_copy (ns) | 535-570 | 384-396 |
| many_dispatch_resident (ns) | 3458-3595 | 3260-3414 |
| wide_dispatch (ns) | 2398-2527 | 2148-2301 |
| dispatch_resident_moving_256 (us/dispatch) | 1.78-2.39 | 1.65-1.69 |

Allocations per call (percall, deterministic): dispatch 18.16 -> 14.16, copy_buffer_1k 6.07 ->
2.08, fill_buffer_256 8.06 -> 4.06, copy_buffer_to_texture 12.56 -> 8.63, fill_in_own_encoder
20.6 -> 17.6; calls many_blit_copy 14 -> 11, wide_blit_copy 6.5 -> 2.5.

Verified: the runtime's tracker and host_aliases tests; the runtime GPU suite on MoltenVK
1504/1504.

(cherry picked from commit a4f9f1c9a908c6289d4096cd37c32fa7a8866b94)
(cherry picked from commit 55b4ba442f60e0a39630639ec383d760c8e2b945)
(cherry picked from commit 4be1a7d13048620e22a628ec2dbb13e76660451b)
(cherry picked from commit 56649bbf80d15bb6a0dbe0decfa898e5def0ce0f)
2026-11-03 01:40:26 -08:00
..