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).
This commit is contained in:
1 parent
d4fa99a14c
commit
6e88d181dd
32 files changed
+3122
-94
No files matched your search
@@ -108,6 +108,24 @@ second process does not translate it again. It cannot be turned off.
|
||||
is still queued, which costs the next process those translations and nothing else.
|
||||
`Device::shader_cache_statistics` counts the entries queued, those a creation wrote itself past
|
||||
the queue's bound, and the bytes written.
|
||||
- **Pipeline records and warming.** A device with `DeviceOptions::pipeline_records` set hands
|
||||
that hook a `PipelineRecord` at each pipeline state creation, and keeps each library a record
|
||||
names in the directory once, named by its content hash, beside the driver's data: a record holds
|
||||
the descriptor and the libraries' hashes, not their bytes, so its size is the descriptor's. The
|
||||
libraries count against `capacity` with everything else; a record whose library was evicted
|
||||
names one the directory no longer holds. Keep a VM's records in the order they came
|
||||
(`to_bytes`), and at its next boot hand them to `Device::warm(records, byte_budget)` on a device
|
||||
over the same directory: one background thread makes their translations and predicted
|
||||
`VkPipeline`s before the guest asks, below every other making, until the driver data it added
|
||||
reaches the budget, and the guest sees nothing of it. What it makes is what the guest's own
|
||||
creation of each descriptor makes on this build: a record holds a descriptor, never a
|
||||
translation, so records kept across an update are warmed by the new translator, and the pass
|
||||
reads no translation of another translator and no creation record of another
|
||||
`RUNTIME_VERSION`. A record it cannot read is counted and dropped, the device's first said once
|
||||
as the `Warning` `metal2vulkan-warm-record-unread`; nothing it meets fails or ends the run.
|
||||
`Device::warm_statistics` counts the records made, those that could not be (a stage the compile
|
||||
layer compiled already), the libraries written, each warmed record's outcome and the driver
|
||||
bytes added.
|
||||
- **When it fills or a write fails.** Each device says so once, through its `MessageSink` (or on
|
||||
stderr) as a `Warning`: `id_name` `metal2vulkan-shader-cache-evicted` when the directory reaches
|
||||
its cap, and the degrade notice
|
||||
|
||||
Reference in new issue
Block a user