← all posts
September 21, 2026·Ronald Adonyo· 11 min read

Measuring the dispatch tax: three dead hypotheses and +13% hiding in an open GPU driver

Apple M2 Ultra, Asahi Linux, llama.cpp on Vulkan: decode ran 2.5x slower than Metal and every candidate explanation was an opinion. We measured all of them, watched three of our own forecasts die against the data — polls that weren't waits, batching that bought nothing, fusion that passed byte-exact without ever running — then found the real lever and took decode from 38 tok/s stock to 72.8.

38 → 72.82 tok/scampaign arc
768.75 tok/spp512
546kernel launches per decode token
4.8xsame-work slowdown
+13.07%ABI2 payload revision
gpuasahi-linuxvulkanbenchmarkingapple-siliconperformance
A row of grain sacks along a whitewashed yard wall, each with a small stone tied on top, a balance weighing one sack against a pile of the stones, and three upturned baskets on the red earth; a chimpanzee unties one stone and a crested crane at the right looks at the baskets.

An ⁠Apple ​M2 ‌Ultra ‌running ​llama.cpp ‌through ‌Mesa's ‌open ‌Vulkan ​driver ​decoded Qwen3-4B ‌at ​38 ‌tokens/second. ‌The ‌same ‌chip ​on ‌macOS ​did ​148. ‌Everyone ​has ‌an opinion ​about ​a ‌gap ​like ‌that. ​This ​is ​the ​story ​of ​the ‌week ‌we ‌stopped ‌having opinions, ​measured ​every ⁠candidate ⁠explanation ​— ‌watched ‌three ​of ‌our ‌own forecasts ‌die ‌against ​the ​data ‌— ​and ‌then ‌found ‌+13% ‌hiding ​in ‌exactly ​the place ​the ‌measurements, ​not ‌the ​intuitions, ​pointed. ‌It ​is ‌also ​the ​story ​of ​a kernel ​module ​that ‌hung ‌the ‌machine ‌and ​the ​hardware ⁠watchdog ⁠that ​saved ‌the experiment.

Transcript

On an Apple M2 Ultra running Linux, llama.cpp on Mesa's open Vulkan driver decoded Qwen3-4B at 38 tokens per second. The same chip on macOS did 148. A week of measurement took it to 72.82.

First, the hardware is not slow: compute-bound prompt processing runs at 768.75 tokens per second, level with Metal. The gap is in decode: 509 dispatches, or kernel launches, per token, and 250 of them do almost no work.

The obvious theory, launch overhead, died three ways. 3,341 of 3,345 wait calls were non-blocking polls. Batching them: minus 0.7 percent. Raising the command cap from 1 to 64: minus 0.2 percent.

Splitting one matrix-vector multiply into 14 commands made it 4.8 times slower in isolation. But in the live graph, dependent commands pipeline and independent ones overlap, so that tax isn't paid.

What paid was a revised interface for handing the injected Apple kernels their per-dispatch context. Decode went from 64.40 to 72.82 tokens per second. Plus 13.07 percent.

Metal still leads at 148. But in all, 38 tokens per second stock to 72.82 is plus 92 percent. The full write-up is at boracode.ai.

The post in under two minutes: the healthy core, three dead hypotheses, and the interface change worth 13%. Narrated in Ronald's cloned voice.

First: is the core even healthy?

Before ‌optimizing ​anything, ‌ask ‌whether ‌the ‌machine ​is ​running ‌degraded. ​One probe ‌settles ‌it: ‌prompt ‌processing ​— ‌compute-bound, ​sustained, ​dispatch-light — ‌runs ​at ‌768.75 ​tokens/second, ​Metal ‌parity. ​Clocks, ‌firmware, ​memory ​system: all ​full-rate ​under ​load. ​Every ‌theory ‌about ‌broken ‌DVFS ​or ​a ⁠throttled ⁠GPU died ​against ‌that ‌number. ​The ‌gap ‌is ‌not ‌the ​hardware ​running ‌slow. ​It ‌is something ‌about ‌how ‌batch-1 ​decode ‌work ​gets ​cut ‌up ​and ‌handed ​to ​the ‌GPU.

Three hypotheses, three funerals

Batch-1 ​decode ‌issues ​hundreds ​of ​tiny ​kernels ​per ​token, ‌and ‌the ‌obvious theory ‌is ​launch ​overhead. ⁠The ⁠kernel ​source ‌even ‌admits ​debt ‌("Hack ‌to disable ‌compute ‌preemption ​until ​we ‌fix ​it"). ‌We ‌measured ‌it ‌three ​ways, ‌and the ​theory ​died ‌three ​ways.

The ‌waits ​weren't ​waits. ‌A ​syscall ‌census ​showed ​191 ​SYNCOBJ_WAIT ​calls per ​token ​— ‌smoking ‌gun, ‌right? ‌A ​second ​instrument ⁠capturing ⁠arguments ​and durations ‌showed ‌3,341 ​of ‌3,345 ‌carried ‌timeout=0: ‌non-blocking ​polls completing ​in ‌256–512 ​nanoseconds. ‌Total ‌cost: ‌half ‌a ​percent ‌of ​the ​token budget. ‌The ​first ‌census ​counted ​calls ‌and ​never ‌read ​them; ​a ​delegated ​agent overturned ​our ​verdict ‌with ‌a ‌better ‌instrument, ​which ​is ⁠the ⁠system ​working.

Batching ‌the ‌polls ​bought ‌nothing. ‌Replacing ‌them ‌with ​one ​blocking ‌wait on ​the ‌final ‌fence: ‌−0.7%, ‌within ​noise.

Submission ‌size ​doesn't ​matter. ‌Raising ​the ‌per-submission ​command ​cap from ‌1 ​to ‌64: ​−0.2%. ​A ​same-work ​scaling ​experiment ​explains ‌why ‌isolated measurements ‌mislead: ‌splitting ​one ​14336-wide ⁠matvec ⁠into ​14 ‌commands ‌made ​it 4.8× ‌slower ‌in ‌a ‌synthetic ​chain ​— ‌but ​in ‌the ‌live ‌graph, ‌dependent ​commands already ‌pipeline ​and ​independent ‌ones ​overlap, ‌so ​the ​tax ‌that ​looks ‌enormous in ​isolation ​simply ​isn't ​paid.

ARM N1  64.47 ± 0.08   injections armed
ARM A1  63.56 ± 0.08   (T1 fusion never engaged — see below)
ARM N2  64.51 ± 0.13
ARM A2  63.30 ± 0.09
ARM N3  64.49 ± 0.11   candidate rejected: -1.6%

The trap we built for ourselves: the vacuous pass

Two ​shader-fusion ​candidates ‌were ‌implemented ‌in ‌parallel ​— ​folding ⁠the ⁠RMS norm ​prologue ‌into ‌the ​matvec ‌kernel, ‌and ‌a ‌dual-matrix ​variant ​with ‌a ​fused activation ‌epilogue. ‌Both ‌passed ‌the ​byte-exact ‌correctness ​gate: ​256 ‌tokens of ​greedy ‌decode, ​output ​hash ‌identical ​to ‌baseline. ​Both ​then ​turned ​out ​to have ​never ‌engaged ‌— ‌one ‌refused ​by ​the ⁠fusion ⁠walker's ​buffer-reuse ‌safety check ‌(which ​was ‌right ‌to ‌refuse: ‌the ​alias ​was ‌genuinely ​unsafe), ‌the ‌other targeting ‌an ‌optimization ​step ‌that ​does ​not ‌exist ​on ‌the ​live ​driver, identified ‌from ​a ‌stale ​capability ​capture.

A ​byte-exact ​pass ​proves ​nothing ‌if ‌the ‌code ‌under ​test ​never ⁠runs. ⁠The ​rule now ‌enforced ‌on ​every ‌candidate: ‌a ‌census ‌proving ​the ​new ‌path ​fires ‌before any ‌timing ‌is ‌read.

What the measurements pointed to instead

With ​the ‌launch ​path ​exonerated, ‌the ​residual ‌gap ​decomposed ​into ‌the ​kernels themselves. ‌Our ​stack ​delivers ​68% ​of ​Metal's ​rate ‌on ‌identical ‌compiled kernel ‌bytes, ​and ​the ⁠graph ⁠carries ​hundreds ‌of ‌near-zero-work ​kernels ‌whose cost ‌is ‌pure ‌launch ​latency ​— ‌a ​payload-capable ‌DRM ‌census ‌measures ‌546 ​kernel launches ‌per ​decoded ​token ‌on ​the ‌stock ​stack ​— ‌and ​Metal ‌doesn't ​have ​them because ​its ​graph ​fuses ​them ‌into ‌the ‌matvecs. ‌The ​fix ​that ⁠measured ⁠out ​was neither ‌more ‌nor ​less ‌commands. ‌It ‌was ‌a ​revision ​of ‌the ​companion-binary interface ‌— ‌how ‌the ‌injected ​Apple ‌kernels ​receive ​their ‌per-dispatch context ​— ‌collapsing ​per-command ​firmware ‌work. ​Interleaved ‌six-arm ​A/B, three ​repetitions, ​drift-cancelled, ​GPU ​UUID ​and ‌DVFS ‌state ‌in ‌the ​receipt:

configarms (tok/s)mean
native, no injection59.89, 60.0359.96
previous best (companion config)64.5464.40
ABI2 payload revision72.39, 73.2472.82

+13.07% ​over ⁠the ⁠previous ​best, ‌+21.4% ‌over ​native. ‌Byte-exact ‌greedy ‌decode throughout. ‌The ​largest ​single ‌improvement ​of ‌the ‌campaign, ‌delivered ‌by ​the lever ‌the ​measurements ​— ‌not ​the ‌intuitions ​— ​selected.

The kernel module that hung the machine

One ‌more ​candidate ‌died ​theatrically. ​A ​kernel-side ​patch ​porting ​macOS's command-structure ‌pooling ‌(pre-initialized ‌circular ‌buffers ​instead ​of ⁠fresh 300-kilobyte ⁠allocations ​per ‌dispatch) ‌compiled ​clean, ‌matched ‌the ‌running kernel's ‌build ​ID, ​passed ‌modpost ​— ‌and ‌hung ‌the ‌kernel ​during ‌module ​init. The ​node ‌went ​network-dark ‌for ​four ​minutes ‌until ​the ‌hardware ​watchdog auto-reset ​it. ​The ​stock ​module ​was ‌untouched; ‌recovery ‌was ‌total; ​the artifact ​is ⁠quarantined ⁠with ​a ‌do-not-load ‌flag.

The ​lesson ‌is ‌recorded ‌next ‌to ​the ​artifact: ‌modpost-clean ​and ‌matching ‌Build IDs ‌are ‌compile-time ​proof. ‌Runtime ​proof ​requires ‌a ​console ‌attached. ​The operator's ​question ‌— ​"won't ‌the ​watchdog ​auto-restart?" ​— ​was ​exactly ​right, and ‌the ‌next ‌attempt ‌streams ​the ​console ⁠through ⁠the ​lab's ‌IP-KVM ‌before anything ​loads.

What we'd tell anyone doing this

First: ‌entry-only ‌tracing ‌lies. ‌Counting ​syscalls ​without ‌reading ​their arguments ‌produced ‌a ‌confident ‌wrong ​verdict ‌that ​a ​second ‌instrument overturned ​in ‌one ​run. ​Second: ‌a ​correctness ‌gate ​is ​only ​as ​good ​as ​its engagement ‌proof ‌— ‌verify ‌the ​new ​path ⁠executes ⁠before ​believing ‌identical output. ‌Third: ​isolated ‌microbenchmarks ‌overstate ‌per-item ‌costs ​— ​the live ‌pipeline ​hid ‌costs ‌that ‌synthetic ‌chains ​exposed, ‌which ​is ​why ‌three dispatch-reduction ​ideas ‌measured ​to ​zero. ‌Fourth: ​keep ‌every ​failed experiment ​with ​its ​receipts; ​three ​of ‌this ‌week's ‌nulls ‌are ​load-bearing evidence ​for ⁠the ⁠conclusion ​that ‌finally ‌paid.

The ​scorecard: ‌38 ‌stock ‌→ ‌72.82 ​tokens/second, ​+92%, ‌every ​step ‌receipted. Metal ‌still ‌leads ‌at ​148 ‌— ​the ​remaining ‌gap ​sits ‌squarely ​in ​per-kernel execution ‌and ​firmware ‌command ​processing, ​both ​measured, ​both ​named. ​The megakernel ‌— ‌one ‌persistent ‌shader ​replacing ​hundreds ⁠of ⁠dispatches ​— ‌is ‌the end-state ​architecture ‌this ‌decomposition ‌points ‌toward, ​and ​the ‌probe ​it ‌was pending ‌on ‌has ‌since ​been ‌run: ​a ​grid-wide ‌software ​barrier ‌on ​identical ​bytes costs ‌~6.8 ​µs ‌unconditionally ​under ​Asahi's ​firmware, ​against ​~0.3 ​µs ‌on Apple's ‌no-hazard ‌path ‌— ​the ​cost ⁠is ⁠clock-independent ​and ‌raises ‌no ​host interrupt, ‌which ‌is ‌the ‌whole ​remaining ​gap, ‌located.

Corrected ​2026-10-19: ‌the ‌stats ‌block ‌and ​body ‌above ​read ​509 ‌dispatches ​per token, ‌described ​as ​~250 ‌near-zero-work ​kernels. ‌A ​rebuilt ​payload-capable ​DRM census ​(campaign ​pin ​165) ‌measured ‌546 ‌kernel ‌LAUNCHES ​per ​decoded ⁠token ⁠in steady ​state ‌— ‌474 ​with ‌the ‌Q/K/V ‌decode ‌pack ​engaged, ​fixed ‌by ​the ‌exact 23102 − 20726 = 2376 = 72 × 33 decoded tokens ‌whole-run ‌identity, ‌so ​the ‌pack removes ​exactly ​72 ‌launches ​per ‌token. ​Submits ​and ‌control ​streams ‌are ​only ​~10 per ​token ​— ​the ​backend ‌packs ‌a ‌~500-node ‌graph ​into ​~10 ⁠control ⁠streams ​— ‌so stream ‌counts ​cannot ‌see ‌node-level ‌consolidation, ‌and ​the ​earlier ‌"~250" ​was counting ‌the ‌wrong ‌thing. ‌Separately, ​the ‌Q/K/V ​consolidation's ​percentage ‌is stack-dependent ​and ‌must ​not ​be ‌quoted ​bare: ‌+6.00 ​% ​on ​the ​stock ​stack (interleaved ​ABBA ‌49.5458 ‌→ ‌52.5175, ‌campaign ​pin ​161) ⁠versus ⁠its ​historical +0.60 ‌% ‌on ​the ‌companion ‌stack ‌(pins ‌162/166). ​The ​barrier ‌figure ​above ‌is from ‌the ‌campaign's ‌elimination ​ledger ‌(docs/honeykrisp/kb/ELIMINATION.md ​§4, "The ​barrier ‌finding"), ​on ‌the ​same ​Apple ‌binary ​and ‌silicon.

boracode.ai · Ronald Adonyo · agx-dispatch-tax
content hash 6f2f4a503c5c
A wide horizon at dusk: layered hills in muted plum and ochre above a lake that holds the last light, a family of crested cranes at the water's edge, an acacia in silhouette and a single bright star above the ridge.