Files
metal2vulkan/crates
Anees Iqbal 6e88d181dd Record each pipeline state creation, and warm a device from an earlier process's records
DeviceOptions::pipeline_records (and RawDevice::pipeline_records) hands a
hook an opaque PipelineRecord once per pipeline state creation that made its
state. That covers compute, render, mesh and tile states, the
additional-binary-functions forms, and a render state's draw-time twins (the
one-sample and factor-scaling ones). A failed creation and a binary
archive's add make none. A record holds the descriptor field by field
("M2VPREC\0", RECORD_FORMAT 1, the library table by content hash, SHA-256),
read back and compared at its making. Its libraries are kept once in the
shader cache's content directory. to_bytes and from_bytes carry it between
processes.

Device::warm(records, byte_budget) stands in for Metal's own pipeline caches
across processes:
- One background thread per device (utility QoS on macOS, Urgency::Warm in
  the making budget) runs each record's creation under the default options
  and drops the state. Translations, creation records and driver
  pipeline-cache data are then in place before the program asks.
- The guest sees nothing of it: no identifier, resource ID, sampler number,
  neutral, room, stand-in copy, kept-variant traffic, live-variant sharing,
  announcement or record.
- It stops at byte_budget of added driver data.
- An unread record is counted, and the device's first is announced as the
  warning metal2vulkan-warm-record-unread; nothing fails.
- WarmStatistics and Device::warm_statistics report the pass.

Ports dev-perf 14df1fb5fe and 66fe0ada29 without per-entry stamps.
Development's build directory names the translator, and its creation records
name RUNTIME_VERSION, so no entry of another translator or runtime version
is ever found, and dev-perf's re-translate-and-compare check has nothing to
do. Adapted:
- the memo is asked but never hands a warm thread a live variant the
  program holds;
- a warm thread's waits rank Urgency::Warm, not Program (making.rs), and the
  pipewait creation bound still applies on warm threads;
- unread records are announced.
DeviceOptions' and RawDevice's Debug are hand-written. PipelineRecord is
among the consumer auto-trait checks. api_signatures re-blessed; runtime
README and HOWTO updated. RUNTIME_VERSION 1707.

Verified on the M3 Max (MoltenVK 1.4.2), on development 2e2e238346:
- 140 device tests and 500 plain tests pass.
- Five sabotages each fail their guard: an archive add making a record; a
  pass answering Warmed without creating; no unread announcement; a warm
  state taking an identifier; a warm thread taking a live variant.
- clippy plain and --cfg m2v_gpu, and rustdoc -D warnings, clean.
- Release, 5 runs of the cross-process test, three creations (render,
  compute, indirect compute):
  - after a warm pass: 3.11-3.42 ms, with 0 stages decoded, 0 translated, 0
    directory lookups and 0 driver caches loaded;
  - unwarmed over the same directory: 4.19-4.32 ms (6 lookups, 2 loads);
  - cold: 4.98-5.10 ms.
  Small shaders, and Metal's own cross-process compiler cache serves all
  three legs.

Lane commits: ws/warmrec-lane (8d106f29ab hook, 30de4fc948 warm).

One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 8c709f27a7, then e2f0f2a3d9 (the re-pin).
2026-10-29 15:43:56 +02:00
..