Write the tile creation's audited split into its row, and what it waits on

Content: the tree of `development` at 17e6acb63f, unchanged.
This commit is contained in:
Anees Iqbal committed 2026-10-26 13:19:22 +02:00
1 parent ec36f6b0e2
commit 450fed9725
1 file changed
+1 -1
@@ -338,4 +338,4 @@ compute_pipeline_bindings 23.6x PER CASE WE ARE 6.5x FASTER: 0.15x over the 13 c
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
render_pipeline_with_reflection 5.30x PER CASE WE ARE 12.5x FASTER: 0.080x over the one case that makes it, Metal 28.4 ms against our 2.3 ms, because Metal compiles the AIR at `library` (28.1 ms, 27.3 of it blocked) where we spend 0.26 ms. This row exists because the gate is per call, NOT because the call costs us anything against Metal. One call over one case (render-state-texture-accesses), Metal 213.0 us against our 1128.1 us = 5.30x; 4.35x (198.3 against 862.9) in the other undegraded pass, and 0.060x a case there. ONLY 61% OF OURS IS OUR OWN CPU: 690.6 us ours against 437.5 us BLOCKED, the only blocked half among this file's pipeline rows. The counters put one VkPipeline and two VkShaderModules inside the call (creation_pipelines_made 1, variant_pipelines_made 1, shader_modules_made 2), so the wait is the driver's Metal compile -- read off the counts, not measured -- and the case never draws (no cmd_bind_pipeline), so it is one of the never-drawing creations render_pipeline's census declares not a defect. NOT A PROCESS WARM-UP: both legs run their 8 rounds in one process and the figure is the median of the rounds' medians, and the round medians span 790-1865 us at 19:57 and 835-925 us at 16:06, never the 1.0-13.7 ms a process's first creation costs. STALE AND CORRECTED: the 14.7x this row quoted, 291 us against 4274 us with 3946 us of it our own CPU, is reproducible from NO stored recording in this tree; the three stored whole-set passes read 7.19x (degraded 07:44), 4.35x and 5.30x, so this call has been UNDER the 10x margin in every stored pass and the row is in the band, not Known The same pipeline-creation path as render_pipeline plus reflection; listed separately because one call is too thin a measurement to fold into that row
tile_pipeline 4.42x PER CASE WE ARE 31x FASTER: 0.032x over the one case the gate judges, Metal 22.3 ms against our 0.715 ms, because Metal compiles the AIR at `library` (22.2 ms, 21.6 of it blocked) where we spend 0.12 ms; 0.290x over all 8 cases that make the call (Metal 250.8 ms against our 72.7 ms), 0.284x in the other undegraded pass. BUT THE CALL IS 83% OF OUR OWN CASE: 596.8 us of our 715.1 us, three calls flat at about 200 us each against Metal's 29.5 us median -- 4.42x, and 4.45x (165.5 against 736.8) in the other undegraded pass, the two agreeing to 0.7%. ALL OF OURS IS OUR OWN CPU AND NONE OF IT IS WORK: per_state pipelines reads 0, so NO VkPipeline is made inside the call, and functions_shared 3 with shader_modules_made 1 and shader_modules_shared 2, so nothing is translated either -- a tile-order-* case earlier in the round translated the kernel. So this row measures the WARM CREATION FLOOR that compute_pipeline_with_stage_input's row leaves open and declines to fund on its own family, here on the family where the call IS our whole spend and with no driver work inside it at all, which is a cleaner isolation than the render path's 240-285 us (that one has MoltenVK's vkCreateGraphicsPipelines on the calling thread). UNAUDITED: the split of that 200 us -- key derivation, the artifact decode and cache/scan.rs's linear module scan, vkCreateShaderModule, the cache's disk read. THREE CALLS IS 3 OF THE 10 the suite makes: seven calls in seven cases are withheld because our leg announces metal2vulkan-degrade-render-pass-split and -tile-dispatch-scratch, and -device-nan-encoding on the two blur cases; the withheld seven read 8.25x and 7.57x over the two undegraded passes, so the withheld half agrees in magnitude and is 5x more evidence than the row used to claim. NOT A PROCESS WARM-UP: the median round's three calls are flat (596.8 us over three against a 203.3 us median) and the round medians span 185-247 us. STALE AND CORRECTED: the 11.9x this row quoted, 192 us against 2292 us, is reproducible from NO stored recording in this tree; the three stored passes read 8.31x (degraded 07:44), 4.45x and 4.42x, all under the 10x margin The same pipeline-creation path for tile pipelines. The two undegraded passes read it 4.42x and 4.45x -- 3.1x above the band and under the margin -- so it is the BAND and not the margin that keeps this row, and the quiet passes agree to 0.7% rather than straddling it
tile_pipeline 4.42x PER CASE WE ARE 31x FASTER: 0.032x over the one case the gate judges, Metal 22.3 ms against our 0.715 ms, because Metal compiles the AIR at `library` (22.2 ms, 21.6 of it blocked) where we spend 0.12 ms; 0.290x over all 8 cases that make the call (Metal 250.8 ms against our 72.7 ms), 0.284x in the other undegraded pass. BUT THE CALL IS 83% OF OUR OWN CASE: 596.8 us of our 715.1 us, three calls flat at about 200 us each against Metal's 29.5 us median -- 4.42x, and 4.45x (165.5 against 736.8) in the other undegraded pass, the two agreeing to 0.7%. ALL OF OURS IS OUR OWN CPU AND NONE OF IT IS WORK: per_state pipelines reads 0, so NO VkPipeline is made inside the call, and functions_shared 3 with shader_modules_made 1 and shader_modules_shared 2, so nothing is translated either -- a tile-order-* case earlier in the round translated the kernel. So this row measures the WARM CREATION FLOOR that compute_pipeline_with_stage_input's row leaves open and declines to fund on its own family, here on the family where the call IS our whole spend and with no driver work inside it at all, which is a cleaner isolation than the render path's 240-285 us (that one has MoltenVK's vkCreateGraphicsPipelines on the calling thread). AUDITED, AND THE 200 US IS GONE AT THIS TIP. The split, by src/bin/tile-pipeline-split.rs's parts mode (300 iterations after a discarded warm-up, load 18.7, p10-p90 within 5%): key derivation 0.42 us for the function's and 0.96 us for the pipeline's, the warm link from an already compiled stage 2.50 us, one artifact decode with cache/scan.rs's scan 9.75 us (the function's, scan_relocatable) or 9.79 us (the pipeline's, scan_words), the artifact encode 7.63 us, and about 22 us for the rest of of_kernel -- against 215 us for the cold translation, as contrast. TWO LEADS THIS SENTENCE CARRIED ARE RETIRED BY COUNT: vkCreateShaderModule is not per creation (shader_modules_made 1 with shared 2 over the three calls, so the module and its layouts cost 100-190 us ONCE per distinct module and are the whole of the first call's excess), and keep_room and the neutrals are not inside the call at all (pooled_memory_blocks_made, pooled_backings_made, addressable_buffers_made and sampler_sets_made all 0 inside every call over four rounds of the whole set; the recording's pooled_memory_blocks_made 3 are the case's). THE 203.3 US IS A 2026-10-24 19:57 FIGURE AND THREE LANDINGS HAVE PASSED UNDER IT: f96d799144 stopped two DeviceProfile fingerprint derivations per creation (62.6 us each on the committed moltenvk-m3 profile, about 125 us for a compute creation by its own commit message), c1cf1a09c9 stopped a module being relocated once per pipeline, ee518a6383 the render stage digests. The suite's own instrument at this tip, our leg, the whole set, 3 runs, reads the call at 42.8 us (on_cpu 43.0, blocked 0) against Metal's 29.5 us median -- 1.45x, where band() is 1.43x -- read at a one-minute load of 34.46 against the recording's 2.63, so a re-read on a quiet host can only be lower. THIS ROW NEEDS A RE-RECORD UNDER QUIET_ENOUGH AND WILL PROBABLY RETIRE ITSELF; it is kept because no stored whole-set pass has been taken since those three landings, not because 200 us was reproduced. What a creation can still reach 200 us by is the artifact write falling onto the calling thread when the cache queue is at its bound: over 3,992 creations on fresh keys, the 2,672 whose artifact the cache thread took cost a median 42.6 us and the 1,320 that wrote their own 223.9 us, partitioned by the counter and not by cost. It did not fire in the suite's shape (0 over all four rounds) and NO COST RECORD CAN SEE IT, because writes_on_thread is a ShaderCacheStatistics field where a record carries WorkCounts. THREE CALLS IS 3 OF THE 10 the suite makes: seven calls in seven cases are withheld because our leg announces metal2vulkan-degrade-render-pass-split and -tile-dispatch-scratch, and -device-nan-encoding on the two blur cases; the withheld seven read 8.25x and 7.57x over the two undegraded passes, so the withheld half agrees in magnitude and is 5x more evidence than the row used to claim. NOT A PROCESS WARM-UP: the median round's three calls are flat (596.8 us over three against a 203.3 us median) and the round medians span 185-247 us. STALE AND CORRECTED: the 11.9x this row quoted, 192 us against 2292 us, is reproducible from NO stored recording in this tree; the three stored passes read 8.31x (degraded 07:44), 4.45x and 4.42x, all under the 10x margin The same pipeline-creation path for tile pipelines. The two undegraded passes read it 4.42x and 4.45x -- 3.1x above the band and under the margin -- so it is the BAND and not the margin that keeps this row, and the quiet passes agree to 0.7% rather than straddling it, both taken before the three 2026-10-26 landings the measured field now names. WHAT IT WAITS ON IS ONE WHOLE-SET PASS ON A HOST UNDER QUIET_ENOUGH, which is expected to retire it; and, if that pass keeps it, writes_on_Line truncated