diff --git a/crates/metal2vulkan-conformance/known-slow-calls.tsv b/crates/metal2vulkan-conformance/known-slow-calls.tsv index 626337cbe..cb0b6810c 100644 --- a/crates/metal2vulkan-conformance/known-slow-calls.tsv +++ b/crates/metal2vulkan-conformance/known-slow-calls.tsv @@ -333,7 +333,7 @@ # waiting on what Metal does, what we do instead, and where the fix belongs function_facts 8.9x PER CASE WE ARE 25x FASTER: 0.04x over the 15 cases, Metal 343 ms against our 13 ms, because Metal compiles their AIR at `library` (21-24 ms a case) where we spend 0.05-0.25 ms. This row exists because the gate is per call, NOT because the call costs us anything against Metal. 15 calls over 15 cases, one each, Metal 216 us against our 10430 us, EVERY microsecond of ours our own CPU and nothing blocked. LOCALISED to the AIR decode: 14 of the 15 cases run 19.0x to 101.6x, and the one that does not is function-facts-visible at 0.2x -- a library's visible function, whose properties are a constant and need no decode. It is the only case of the family we are faster than Metal on. 40.6x in the other undegraded pass; the 89.5x on record elsewhere is the degraded pass and is not reproducible RE-MEASURED after the memo fix landed, over the whole set in release on this M3 Max, 8 rounds: 8.9x against the 48.4x this row used to quote, our leg 10,429.8 us to 2,840.9 us over the same 15 call(s). The pass was NOT judged -- the host's load moved 3.19x mid-leg with eight other lanes on it -- so the figure is what was read and not a verdict; what stands behind the fix is still the count (tests::derived_once), and our own absolute cost falling needs no denominator. The suite's our_function_facts reads five MTLFunction property getters, and each recomputed the function's properties from scratch -- a full AIR decode, for the module-sourced functions newLibraryWithAIR makes -- so one call decoded one function's AIR five times, six with the constants dictionary, and ten for a specialized function, which decodes again to specialize. Metal answers every getter from the MTLFunction it already made. FIXED in metal2vulkan-runtime/src/library.rs, which now memoizes the properties on the function object as Metal holds them, and held by a count rather than a time (tests::derived_once, a table of getters each held to one derivation; with the memos bypassed its five rows read 10, 10, 2, 2 and 2). The constants dictionary named above is now memoized too, and the library's reflectionForFunctionWithName: with it. What the fix is proven by is the count, not a ratio: reading the getters computes the properties once where it computed them ten times, which is deterministic and needed no quiet host. The RATIO has not been re-measured and this row deliberately quotes no expectation for it, because the per-case figure above says the ratio was never a cost in the first place. Whoever re-measures should replace the 48.4x with what they read and leave the per-case line, which is the half that decides whether anything is wrong function_facts_from_descriptor 5.7x PER CASE WE ARE 50x FASTER: 0.02x over the 7 cases, Metal 156 ms against our 3.8 ms, for the same reason as function_facts. The row is the gate's, not a cost. 7 calls over 7 cases, one each, Metal 94 us against our 3111 us, all of it our own CPU and nothing blocked; every one of the 7 is over the margin, 21.9x to 40.9x. 28.5x in the other undegraded pass; the 86.2x on record elsewhere is the degraded pass RE-MEASURED after the memo fix landed, over the whole set in release on this M3 Max, 8 rounds: 5.7x against the 33.0x this row used to quote, our leg 3,110.5 us to 777.2 us over the same 7 call(s). The pass was NOT judged -- the host's load moved 3.19x mid-leg with eight other lanes on it -- so the figure is what was read and not a verdict; what stands behind the fix is still the count (tests::derived_once), and our own absolute cost falling needs no denominator. The same cause as function_facts and the same fix: newFunctionWithDescriptor: answers through the same our_function_facts, so it paid the same five-to-ten AIR decodes a call. Listed separately because the two calls are measured over different cases and a reader should not have to infer that one row covers both. Re-measurement is owed on the same terms as function_facts's -render_pipeline 31.0x THIS IS THE ONE ROW IN THIS FILE THAT CARRIES THE CLUSTER'S REAL COST, and the per-case breakdown of the two worst cases says so without ambiguity. integer-vertex-attributes is 3.62x a case: Metal 37.8 ms (library 23.5, render 7.6, 64 render_pipeline calls 1.7) against our 136.8 ms (64 render_pipeline calls 87.3, render 15.9, library 0.2, elsewhere 33.7), so render_pipeline is 85.6 ms of our 99 ms excess and 85.6 of our 103.1 ms in calls is our OWN CPU, not waiting. vertex-format-constant-step is 3.08x with the same shape (render_pipeline 71.2 ms of the excess). PER CASE over the blend sweeps 0.68x, two of them the wrong way (blend-sweep-write-masks 1.55x, blend-sweep-operations 1.25x) while carrying Metal's 27 ms library handicap. 660 calls over 120 cases, Metal 28606 us against our 886266 us, of which 831583 us is our own CPU. ATTRIBUTED, by the per-call cost against how many the case makes: Metal's median falls and ours does not. Metal costs a median 122.3 us a call in the 66 cases that make one, 31.0 us in the 11 that make 5 to 15 and 26.1 us in the 6 that make 36 or more -- which is the mix of its three cheap answers and not an amortization. Measured on Metal's own API with no Vulkan in the process (`probes/metal_pipeline_marginal_cost.m`), those three are an identical descriptor, memoised at 5-11 us; a change that reaches only a small stage, 45 us for a vertex format where a blend state over the same pair is 3.1 seconds; and an AIR some earlier process compiled, MTLCompilerService keying its output on the AIR and keeping it across processes, 27 us warm against 4052 us cold. A distinct fragment-side state on a cold machine gets none of them and costs what compiling a new function costs. The header says the rest. Ours costs 1686.0, 1277.5 and 1205.6 us over the same three groups, flat to within 1.4x. The ratio therefore climbs 13.8x, 41.3x, 46.1x with the call count while our own per-call cost barely moves, and on a case that makes ONE render pipeline we are faster than Metal (render-draw-forms-lines 0.4x). compute_pipeline is 0.4x at 26.2 us a call against Metal's 71.8, so this is the render path and not pipeline creation in general The cases that make many are the sweeps, which vary only pipeline state over one vertex-and-fragment pair (blend-sweep-*, vertex-format-*, integer-vertex-attributes; the blend slot sweeps need nothing of the fragment function). Metal compiles the functions once and makes cheap state variants; our per-call cost says we do the per-pipeline work again for each. What it is NOT is the shader compile: the measurement carried our shader cache over between the cases of a round, so the second and later pipelines of a sweep meet a warm cache and still cost about 1200 us each. For integer-vertex-attributes the translation is now fully accounted and NONE of it is redundant, so no cache is missing there: the case is 2 entry points x 16 attribute formats x 2 step functions, and shader_modules_made reads 34 = 2 + 32. Its 32 PerVertex pipelines share 2 modules, because an integer format read into a float attribute is fetched by fixed-function input in its USCALED/SSCALED form and vertex_fetch_projection's fetch_of drops the format for a fixed-function attribute, so the format never reaches the compile key. Its 32 Constant-step pipelines cannot be: Vulkan has no constant vertex input rate, so metal::vertex::fetch_as returns Pulled for that step, a pulled fetch reads bytes and converts in the shader, and the projection then carries the attribute and layout -- so the format IS in the key and each of the 16 needs its own vertex translation. 2 + 32 is the measured 34 exactly, and the step function being free while the format is not is why. The doubled predicted pipeline below was therefore the ONLY redundant work in this case. What this does NOT explain is the blend sweeps, which read shader_modules_made 2 over 32 pipelines and pipeline_layouts_made 1, so their cost is not translation at all but the per-pipeline work with a module already in hand, and that is where the remaining narrowing sits. THE NEXT NARROWING, identified and deliberately not built: blend-sweep-write-masks varies only the color write mask over one function pair, and VK_EXT_extended_dynamic_state3's COLOR_WRITE_MASK_EXT is wired but made dynamic only in a pipeline that reads through snapshots (pipeline/graphics.rs, GraphicsState::snapshot_reads), which these states do not, so 32 write-mask values become 32 VkPipelines where one dynamic pipeline would do. It is NOT proposed on this evidence, for a reason the venue gives: these figures come from MoltenVK, where Metal holds the write mask in MTLRenderPipelineState, so a dynamic write mask there buys a pipeline per bind instead of per creation and may cost more. Collapsing 32 makings to 1 is a claim about a driver with real dynamic state 3, and it needs a release-mode measurement on such a driver before anything is built. Recorded here so the next reader starts from the condition and not from the ratio. The contrast with compute_pipeline_bindings sharpens it: there our own cost falls 35x from the first pipeline on a shader to the eighth, so for compute the expensive part is once per shader; here it does not fall at all across 64, so for render it is once per pipeline. Whatever a render pipeline redoes, a compute pipeline keeps. ATTRIBUTED AND HALVED by that counters run. Every creation made a predicted VkPipeline the draw never took and the draw then made a second, so the per-pipeline work was done twice: integer-vertex-attributes read creation_pipelines_made 64, creation_pipelines_drawn 0, variant_pipelines_made 128, and vertex-format-float4 45/0/90. The cause is the creation-time prediction (pipeline/predicted.rs), which guessed a triangle list for an Unspecified topology class; these families discard rasterization and draw points, so the guess missed 100% of the time. Fixed: the counters now read 64/64/64 and 45/45/45, with shader_modules_made (34, 10) and pipeline_layouts_made (2, 2) unmoved, so SPIR-V and layouts were already shared and only the wasted pipeline changed. The deterministic check is the recorded bound and not a new test: variant_pipelines_made is gated at its reading with the case alone (cost.rs MONOTONE), and the committed recording for integer-vertex-attributes now carries creation_pipelines_made 64 against variant_pipelines_made 64, so the doubling is gone from the blessed ceiling as well as from the code. WHAT REMAINS, and why this row keeps its figures: removing one of two pipelines per creation does not touch the flat per-call cost beneath it. Our cost per render pipeline is still flat to within 1.4x across 64 where Metal's falls 4.7x for the reasons above rather than by amortizing; about half of the 87.3 ms is expected to go and none of it is verified, because no window since has been judgeable. The blend sweeps that run the wrong way (write-masks 1.55x) make rasterizing states, read 32/32/32 before and after, and are NOT this cause. FOR THE OWNER: the cost half was not blind to this one, which is the lesson of the row -- it counted the second pipeline and recorded it as the bound, so a bound re-blessed from a measurement carries whatever waste the measurement had. The times half saw 3.62x on the case and judged nothing, because its margins are per call. THE CENSUS behind the fix, read offline from the committed recordings' own bounds and so load-independent: of the 356 cases that record making a predicted pipeline, 99 take every one, 206 never draw at all, and 51 mispredict a draw they do make, paying 121 pipelines twice. The 206 are NOT a defect -- a creation cannot know whether a draw will come, and paying the compile there is the point, since Metal pays it at library creation -- so the 121 are the whole of this bug and integer-vertex-attributes is 64 of them. A SECOND and distinct mispredict shape sits in the tail: 34 of the 51 are sample-positions-* and sample-fills-* cases wasting exactly 1 of 1, and GraphicsKey carries sample_positions and pass, neither of which a creation can know, so those cannot be predicted by a better guess at all; one pipeline a case, no per-case ratio, recorded here rather than fixed. THE CHECK REACHES EVERY CASE: all 1,122 recordings carry a cost record, vertex-format-float4, vertex-format-constant-step and the blend sweeps among them, so the bounds hold for every case this row quotes and not only for integer-vertex-attributes. AGENTS.md gives pipeline-creation time its own ceiling rather than the device API's, so the row records the gap meanwhile +render_pipeline 28.5x RE-MEASURED 2026-10-26 AND THE ROW'S OLD THESIS NO LONGER HOLDS ON ITS OWN EVIDENCE. It used to read that this is the one row carrying the cluster's real cost, because its two worst cases were 3.62x and 3.08x and two blend sweeps ran the wrong way. At this tip the two worst cases are 2.2x and 1.6x and BOTH blend sweeps run the right way (write-masks 0.8x, operations 0.6x), 7 cases are within 10x and 0 over it. It is still the dearest pipeline row per call and its per-case figures still go the wrong way on the vertex families, which is why it stays and stays first; it is no longer a row whose cases are 3x. The figures below marked ORIGINAL are the shape the row was written from and are kept only where the mechanism they establish still stands. ORIGINAL, integer-vertex-attributes at 3.62x a case: Metal 37.8 ms (library 23.5, render 7.6, 64 render_pipeline calls 1.7) against our 136.8 ms (64 render_pipeline calls 87.3, render 15.9, library 0.2, elsewhere 33.7), so render_pipeline is 85.6 ms of our 99 ms excess and 85.6 of our 103.1 ms in calls is our OWN CPU, not waiting. vertex-format-constant-step was 3.08x with the same shape (render_pipeline 71.2 ms of the excess). AT THIS TIP, `times --runs 8` over the 8 cases that make the call, 7 done by both legs: Metal 306 calls / 7,415 us / 22.166 us each against ours 306 / 123,747 us / 279.833 us each, 16.7x per call, 86.6% our own CPU; per case integer-vertex-attributes 2.2x, vertex-format-constant-step 1.6x, half4 1.4x, float4 1.3x, instance-step 1.3x, half-output-blends-r16f 0.7x (withheld, three notices), blend-sweep-write-masks 0.8x, blend-sweep-operations 0.6x. That run is a READING AND NOT A VERDICT: the host sat at a one-minute load of 12.6-13.5 and the instrument flagged its own floor at 2.09 instrument costs where the gate allows 1.0, so it asks to be re-run where the measuring thread keeps its scheduling class. The 28.5x in column 2 is the committed recordings instead, which are undegraded and a larger sample. PER CASE over the blend sweeps 0.68x in the original pass, two of them then the wrong way (write-masks 1.55x, operations 1.25x) while carrying Metal's 27 ms library handicap; both now run the right way. The committed recordings now hold 966 calls over 232 cases, Metal 47,861 us against our 1,361,843 us (28.5x), where this row's original pass saw 660 calls over 120 cases, Metal 28,606 against our 886,266 of which 831,583 was our own CPU. ATTRIBUTED, by the per-call cost against how many the case makes: Metal's median falls and ours does not. Metal costs a median 122.3 us a call in the 66 cases that make one, 31.0 us in the 11 that make 5 to 15 and 26.1 us in the 6 that make 36 or more -- which is the mix of its three cheap answers and not an amortization. Measured on Metal's own API with no Vulkan in the process (`probes/metal_pipeline_marginal_cost.m`), those three are an identical descriptor, memoised at 5-11 us; a change that reaches only a small stage, 45 us for a vertex format where a blend state over the same pair is 3.1 seconds; and an AIR some earlier process compiled, MTLCompilerService keying its output on the AIR and keeping it across processes, 27 us warm against 4052 us cold. A distinct fragment-side state on a cold machine gets none of them and costs what compiling a new function costs. The header says the rest. Ours costs 1686.0, 1277.5 and 1205.6 us over the same three groups, flat to within 1.4x. The ratio therefore climbs 13.8x, 41.3x, 46.1x with the call count while our own per-call cost barely moves, and on a case that makes ONE render pipeline we are faster than Metal (render-draw-forms-lines 0.4x). THE ROW'S OLD CLOSING ARGUMENT IS REFUTED: it read that compute_pipeline is 0.4x at 26.2 us a call against Metal's 71.8, so this was the render path and not pipeline creation in general. The committed recordings now read compute_pipeline at 9.50x, 465 calls over 274 cases, Metal 65.0 us a call against our 617.5. Render is worse, not uniquely wrong, and the contrast no longer licenses the conclusion. WHAT A WARM RENDER CREATION IS, measured in four shader-cache cells (`src/bin/render-pipeline-split.rs`): 240-285 us of our own CPU against Metal's 22.2 us for an entire creation, 11-13x, with NO translation, NO VkShaderModule, NO linked-use question and NO driver compile in the call (`driver_pipeline_hits` 1, `misses` 0 on every warm call). The driver IS asked -- one VkPipeline per creation, made on the CALLING THREAD because `RenderVariant::make_at_creation` hands its one piece to `pipeline_pool.join_all(.., first_here = true)` and `pool.rs:361-364` runs the first piece there -- so `our own CPU` in this row has never meant `our code`. Cold additions: our translation plus the linked-use questions 75-155 us a creation; a driver compile with MTLCompilerService already holding the AIR ~23 us; the first compile of that MSL ever 55 ms a creation, or 4.2 ms wall against 0.46 ms CPU where the wait is XPC. WHAT IS LEFT THAT IS OURS: exactly two shader-cache artifact lookups find nothing usable per creation, in all four cells and both cases including fully warm (64 misses over 32 calls, 128 over 64) against one that hits, and bounding the memo to one byte adds one more hit and no further miss, which proves the two are not the stage functions. They are `Sources::render`'s two `load_render_pipeline` calls (`pipeline/render.rs`'s `RenderVariant::compiled`), which miss BY DESIGN because `pipeline/sources.rs:240-250` stores the artifact only where re-linking it would translate -- so a sweep over one vertex-and-fragment pair RE-LINKS its pipeline from two cached stage functions on every creation, and that link plus the state's construction is the 240-285 us. `ShaderCacheOptions::memory_capacity` does fire here (it caps `PipelineMemo`, `shader_cache/mod.rs:368`, default 256 MiB / 4096 entries; zero is refused at device creation, so one byte turns it off) and is worth one artifact read a creation, under the noise floor. `cache/scan.rs`'s linear scan is NOT on the warm path at all: it runs only on an artifact decode and a warm creation decodes none The cases that make many are the sweeps, which vary only pipeline state over one vertex-and-fragment pair (blend-sweep-*, vertex-format-*, integer-vertex-attributes; the blend slot sweeps need nothing of the fragment function). Metal compiles the functions once and makes cheap state variants; our per-call cost says we do the per-pipeline work again for each. What it is NOT is the shader compile: the measurement carried our shader cache over between the cases of a round, so the second and later pipelines of a sweep meet a warm cache and still cost about 1200 us each. For integer-vertex-attributes the translation is now fully accounted and NONE of it is redundant, so no cache is missing there: the case is 2 entry points x 16 attribute formats x 2 step functions, and shader_modules_made reads 34 = 2 + 32. Its 32 PerVertex pipelines share 2 modules, because an integer format read into a float attribute is fetched by fixed-function input in its USCALED/SSCALED form and vertex_fetch_projection's fetch_of drops the format for a fixed-function attribute, so the format never reaches the compile key. Its 32 Constant-step pipelines cannot be: Vulkan has no constant vertex input rate, so metal::vertex::fetch_as returns Pulled for that step, a pulled fetch reads bytes and converts in the shader, and the projection then carries the attribute and layout -- so the format IS in the key and each of the 16 needs its own vertex translation. 2 + 32 is the measured 34 exactly, and the step function being free while the format is not is why. The doubled predicted pipeline below was therefore the ONLY redundant work in this case. What this does NOT explain is the blend sweeps, whose cost is the per-pipeline work with a module already in hand -- though the module count never licensed that inference and the row used to rest it on one: it read shader_modules_made 2 over 32 pipelines and pipeline_layouts_made 1, where write-masks' bounds now read shader_modules_made 4, shared 61, layouts 3 and `functions_translated` 29, a counter that did not exist when the row was written (added at 170988e1ae), and a cold cell reads one translation per creation, 32 of 32. Identical SPIR-V is why only a few modules are made, and that is where the remaining narrowing sits. THE NEXT NARROWING, identified and deliberately not built: blend-sweep-write-masks varies only the color write mask over one function pair, and VK_EXT_extended_dynamic_state3's COLOR_WRITE_MASK_EXT is wired but made dynamic only in a pipeline that reads through snapshots (pipeline/graphics.rs, GraphicsState::snapshot_reads), which these states do not, so 32 write-mask values become 32 VkPipelines where one dynamic pipeline would do. It is NOT proposed on this evidence, for a reason the venue gives: these figures come from MoltenVK, where Metal holds the write mask in MTLRenderPipelineState, so a dynamic write mask there buys a pipeline per bind instead of per creation and may cost more. Collapsing 32 makings to 1 is a claim about a driver with real dynamic state 3, and it needs a release-mode measurement on such a driver before anything is built. Recorded here so the next reader starts from the condition and not from the ratio. The contrast with compute_pipeline_bindings sharpens it: there our own cost falls 35x from the first pipeline on a shader to the eighth, so for compute the expensive part is once per shader; here it does not fall at all across 64, so for render it is once per pipeline. Whatever a render pipeline redoes, a compute pipeline keeps. ATTRIBUTED AND HALVED by that counters run. Every creation made a predicted VkPipeline the draw never took and the draw then made a second, so the per-pipeline work was done twice: integer-vertex-attributes read creation_pipelines_made 64, creation_pipelines_drawn 0, variant_pipelines_made 128, and vertex-format-float4 45/0/90. The cause is the creation-time prediction (pipeline/predicted.rs), which guessed a triangle list for an Unspecified topology class; these families discard rasterization and draw points, so the guess missed 100% of the time. Fixed: the counters now read 64/64/64 and 45/45/45, with shader_modules_made (34, 10) and pipeline_layouts_made (2, 2) unmoved, so SPIR-V and layouts were already shared and only the wasted pipeline changed. The deterministic check is the recorded bound and not a new test: variant_pipelines_made is gated at its reading with the case alone (cost.rs MONOTONE), and the committed recording for integer-vertex-attributes now carries creation_pipelines_made 64 against variant_pipelines_made 64, so the doubling is gone from the blessed ceiling as well as from the code. WHAT REMAINS, and why this row keeps its figures: removing one of two pipelines per creation does not touch the flat per-call cost beneath it. Our cost per render pipeline is still flat to within 1.4x across 64 where Metal's falls 4.7x for the reasons above rather than by amortizing; about half of the 87.3 ms was expected to go, and it is now SEEN TO HAVE GONE: integer-vertex-attributes' render_pipeline calls read 27,064 us against the 87,324 recorded here, a 3.2x drop, and write-masks 13,094 against 64,019, a 4.9x drop -- per creation 1,364 to 423 us and 2,000 to 409 us. Read at load 12.6-13.5 with the instrument flagging its floor, so a reading and not a verdict, and part of it is the two removals that landed at ee518a6383 (stage digest derivations 32 to 0 over a 16-sibling sweep, pipeline-artifact encodes 16 to 0) which every recording in this file predates. The old claim that our cost is flat to within 1.4x across 64 while the ratio climbs 13.8x, 41.3x, 46.1x with the call count is gone: the 7 sweep cases now sit in a 14.1-18.6x band. The blend sweeps make rasterizing states, read 32/32/32 before and after, and are NOT this cause; they no longer run the wrong way at all (write-masks 0.8x, operations 0.6x). FOR THE OWNER: the cost half was not blind to this one, which is the lesson of the row -- it counted the second pipeline and recorded it as the bound, so a bound re-blessed from a measurement carries whatever waste the measurement had. The times half saw 3.62x on the case and judged nothing, because its margins are per call. THE CENSUS behind the fix, read offline from the committed recordings' own bounds and so load-independent: the committed bounds now hold 511 cases that record making a predicted pipeline, 162 taking every one, 12 taking some but not all (19 wasted) and 337 recording no take, where the census this fix was built from read 356 cases, 99 taking every one, 206 never drawing and 51 mispredicting a draw they did make, paying 121 pipelines twice. Bounds alone cannot split `no take` into `never draws` and `mispredicted every one`, so the totals have moved and the 206/51 split cannot be restated from them. The 206 are NOT a defect -- a creation cannot know whether a draw will come, and paying the compile there is the point, since Metal pays it at library creation -- so the 121 are the whole of this bug and integer-vertex-attributes is 64 of them. A SECOND and distinct mispredict shape sat in the tail and NO LONGER APPEARS: no sample-positions-* or sample-fills-* row reads a partial take any more, where 34 of the 51 once wasted exactly 1 of 1, and GraphicsKey carries sample_positions and pass, neither of which a creation can know, so those cannot be predicted by a better guess at all; one pipeline a case, no per-case ratio, recorded here rather than fixed. THE CHECK REACHES EVERY CASE: every recording carries a cost record (1,122 when this was written), vertex-format-float4, vertex-format-constant-step and the blend sweeps among them, so the bounds hold for every case this row quotes and not only for integer-vertex-attributes. AGENTS.md gives pipeline-creation time its own ceiling rather than the device API's, so the row records the gap meanwhile compute_pipeline_bindings 23.6x PER CASE WE ARE 6.5x FASTER: 0.15x over the 13 cases, Metal 320 ms against our 49 ms, every case between 0.01x and 0.32x, because Metal compiles their AIR at `library` (22-27 ms each) and we translate it here (1.0-6.9 ms). There is no cost gap to attribute. 13 calls over 13 cases, ONE call each, Metal 1755 us against our 41471 us, of which 40054 us is our own CPU: Metal a median 136.5 us a call against our 3004.8 us. The family has 15 cases and all 15 record the call on both legs; 12 are over the margin, 12.4x to 43.3x, and three are under it -- function-bindings-argument-buffer 0.3x, function-bindings-data-types-tables 1.5x and function-bindings-visible-function-table 1.7x. The sums above are that pass's 13. LOCALISED, by the one control the suite already contains: compute_pipeline_reflection_under makes the SAME runtime call (new_compute_pipeline_state_with_function_and_reflection) over the same three shader families and reads 0.7x -- because its cases make EIGHT each where these make one. On texture-slots, ours costs 1922 us for the one call here and 55 us a call over the eight there, while Metal costs 88 us and 29 us. OUR FIRST PIPELINE ON A SHADER COSTS ABOUT 1900-6900 us AND THE SECOND ONWARDS ABOUT 55 us; Metal's first costs 88-190 us. 21.7x in the other undegraded pass This is a first-use cost on a shader, not a per-pipeline one, and the 22x is what it looks like undiluted: each function-bindings-* case uses a different shader and makes exactly one pipeline, so each pays the whole of it, while compute_pipeline_reflection_under's cases spread the same cost over eight and it disappears. The 35x our own figure amortizes across those eight says the repeated part is small and the once-per-shader part is large. ATTRIBUTED, and it IS the AIR-to-SPIR-V translation. Driving the same call over the family's own fixtures, in release under m2v_gpu on an M3 Max with a shader-cache directory per fixture, the one translation of the kernel is 66-88% of the cold creation: 1.0-5.3 ms of 1.4-8.8 ms. functions_translated reads 1 with functions_shared 0 on the first creation and 0 with 1 on the second, in every fixture, so the 35x this row inferred from timings is now a count -- one translation a shader and none thereafter, 1.4-8.8 ms against 11-41 us. It is once per shader because the memo key is FunctionCompileKey (AIR hash, entry name, constants, profile fingerprint, canonical lowering inputs, linked functions) in Sources::function. The same run retires two leads this row carried. No VkPipeline is made in this call at all -- creation_pipelines_made 0 and variant_pipelines_made 0, because without requiredThreadsPerThreadgroup the dispatch-making predicts nothing -- so no SPIR-V-to-MSL and no Metal compile is inside the figure, which is why all of it is our own CPU. And the binding reflection is not where to look: it costs 0.7-3.9 us off the compiled stage, where deriving it from AIR would cost 82-604 us, and this path never does that. The richness of the reflected arguments does not survive either: tables_in_arguments and textures translate in 1.16 and 1.01 ms while this row's per-call figures put them 21x apart. ONE TRANSLATION PER SHADER IS THE FLOOR, and moving it to library is refused -- we translate only the entry a pipeline asks for, which is why our library costs 0.09-0.78 ms against Metal's 22-27 ms, and reflection/encoder_types is the proof: six entries over 157 KB of AIR, one per case, so an eager library translation would make each of those cases pay all six. AGENTS.md's only numeric ceiling is 20 seconds and 500 MiB per translation attempt, and 6.9 ms is 0.03% of it, so this row's gap is a per-call ratio and not a bound anything exceeds. THE PER-CALL FIGURES ABOVE SHOULD NOT BE REASONED FROM: the recorded 144 us for data-types-tables, 36 us for argument-buffer and 157 us for visible-function-table are not reproducible -- a cold measurement of that same fixture reads 1.42 ms -- and neither cache warmth nor case order explains them, since function_bindings is the first family in cases.rs to make a pipeline on any of these shaders compute_pipeline_with_stage_input 5.7x PER CASE THIS IS THE ONE THAT MOVES, and attribute-format-fetches is the case to chase: it is 2.7x (Metal 48.3 ms against our 132.1 ms) while its sibling attribute-format-class-crossings is 0.3x and attribute-stride-* is 0.2x and 0.0x, so the pair is 1.73x and the family total is the only one of the pipeline rows that goes the wrong way. 112 calls over the 7 cases that measure (8 make it; attribute-stride-inline-bytes is unmeasured, a known gap at known-gaps.tsv line 83), Metal 4082 us against our 23147 us; 5.8x in a second pass of the same selection. THE CALL IS OURS AND IT IS 9% OF THE CASE. No VkPipeline is made inside the call at all: variant_pipelines_made, driver_pipeline_hits and driver_pipeline_misses read 0 on every one of fetches' 29 calls in three cache cells and two runs (src/bin/stage-input-split.rs), because the creation predicts a region's pipeline only where the descriptor states requiredThreadsPerThreadgroup (pipeline/dispatch_making.rs). The cells split the 394 us call 62% our AIR-to-SPIR-V translation / 38% the rest of it with a module in hand, and the cold cell's 394 us equals the suite's own 404 us, which says the suite measures our cold translation every round -- run.rs::open gives each round a fresh ScratchCache while MTLCompilerService is cross-process and permanently warm. THE CASE IS THE DRIVER'S, off the calling thread: of fetches' 83.8 ms excess, 63.5 ms is elsewhere against Metal's, 11.4 ms is in-call CPU (29 x 244 us translation + 29 x 149 us warm path) and 11.5 ms is more blocked at wait. attribute-format-class-crossings makes 16 such calls and never dispatches, so its elsewhere is 0.265 ms a row against fetches' 2.367: about 2.10 ms a row arrives with the dispatch, where the counters put 29 pooled VkPipeline makings -- 61 of the 63.5 ms, an upper bound since the cache writer runs there too. WHAT IS LEFT THAT IS OURS: a warm creation that translates nothing and asks the driver for nothing still costs 149-190 us against Metal's 38.5 for the whole creation, which is 4.3 ms of the 83.8 and is unexplained. STALE AND CORRECTED: 19.9x over 37152 us and 48 calls, the family figure 1.92x (an average of a case 3x FASTER than Metal with one 2.7x slower, which is why a family figure is not a finding here), "all of it our own CPU", 936.1 us on attribute-stride-buffer's one call (now 370.0) and "a ONE-call case costs us more per call than the 29-call case" (now inverted, 370.0 against 404.0). Metal's own one-call figure moved 83.4 to 130.7 us. Measured over an 8-case selection, 8 rounds, twice, one-minute load 6.9 and 6.1, instrument 0.238-0.244 us; NOT a whole-set pass Our cost rises with the siblings in the two format sweeps only, and the probe in the previous column refutes that as the mechanism: what rises is the module translation, not the pipeline and not the sibling count, and a call that is cheaper than Metal's alone cannot be explained by pipeline creation being expensive. The two cases that make many are attribute-format sweeps over one kernel (attribute-format-fetches, attribute-format-class-crossings), so what varies between siblings is the stage-input descriptor alone. ANSWERED, and it is not the stride: measured on an M3 Max via MoltenVK, driving the cases' own descriptors through the runtime, attribute-format-fetches' 29 rows carry 29 distinct attribute-format tuples over ONE constant stride and make 29 shader modules with none shared -- one per row, irreducible, because the format is the decode -- while attribute-stride-* uses MTLBufferLayoutStrideDynamic, already the pushed form, and makes 1 module over 29 creations. Pool::has_room is ruled out too: the device's kept pools hold 3 blocks and 3 free ranges that never move over 400 creations. Nothing in WorkCounts rises over 410 creations and per-creation cost is flat across eight groups of 50. What remains is that each of this case's siblings is a cold shader where the one-pipeline cases hit a module the round already made: a cache-warmth difference between cases, not a structure that grows with the siblings. THAT CONTRAST IS NOW INVERTED and the warmth reading with it: the ONE-call attribute-stride-buffer costs 370.0 us a call against the 29-call case's 404.0, so a one-call case no longer costs more per call -- it reads a process warm-up rather than a cold shader, the first call of a process costing 1.0-13.7 ms while the first call on a shader in steady state costs 394 us mesh_pipeline_bindings 19.8x PER CASE WE ARE 2.3x FASTER: 0.43x over the 2 cases, Metal 45.4 ms against our 19.4 ms. 16 calls over 2 cases, 8 each, Metal 962 us against our 19070 us, all of it our own CPU: 60.2 us a call against our 1191.9 us. Both cases are over the margin, 20.3x and 19.2x. 18.5x in the other undegraded pass Mesh pipeline creation with reflection, for an object-and-mesh stage pair. THE COUNTERS HALF IS BLIND TO THIS COST, which is the finding and the reason the row is not attributed. The case makes 8 states from ONE descriptor, varying only MTLPipelineOption -- the same shape as pipeline-options-texture-slots, where the 8 compute states cost 4 us each after the first and the counters read creation_pipelines_made 1, variant_pipelines_made 1, shader_modules_made 1. Here all 8 cost about 1390 us (median 1341 against a per-call mean of 1392, so none of them is a first-use outlier) and `cost --show` moves only 16 of the runtime's 471 counts, 4 of them in the translation region: shader_modules_made 4 with 28 shared and pipeline_layouts_made 1 with 7 shared, so modules and layouts ARE reused, and creation_pipelines_made and variant_pipelines_made do not move at all although their doc covers a render state's predicted key. ATTRIBUTED, and this row's own elimination of reflection was the error that hid it. The claim here was that reflection is cached on the PipelineKey and not the options, so the 8 states should share a key: true of the render path and false of the mesh path, which never built a key at all. The 8 shared nothing. Each state, and each read of a getter, did a full AIR decode of the object, mesh and fragment stages, reaching neither the shader cache nor any memo, while the drawing path went through the cache under render_descriptor_key -- so the 11.1 ms of wall that no counter accounted for was those decodes. Mesh reflection is now routed through the cache and memoized, and it is held by a count: tests::mesh_reflection_derived holds 2 states and 4 getter reads to 1 derivation, reads 0 with the routing removed, and a companion requires two different descriptors to derive 2 so the key cannot be too coarse. So the per-creation counter this row asked for is NOT owed: the cost is attributed and a derivation count holds it. The lesson the row keeps is that eliminating a cause by reading the path that caches it, rather than the path the case takes, eliminated the actual cause