commit 62709d0deefba724be60743649962c604f808d87
parent b792987a36a8ed5e352b0f523bf89b451c9d7ddc
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sun, 14 Jun 2026 07:36:29 -0700
doc(plan): FRONTEND-SHAPE §D.8 — P1c: gap is a UNIFORM ~2.8x constant factor (lex 2.69x / rest 2.95x), -E was serialization-contaminated; no structural halving exists, 1.5x is a long-horizon incremental goal; structural hunt closed
Diffstat:
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/doc/plan/FRONTEND-SHAPE.md b/doc/plan/FRONTEND-SHAPE.md
@@ -194,6 +194,49 @@ gap into lex / pp / parse+emit and says where the remaining excess lives and whe
it is attackable. Until P1c, do **not** invest in the scanner build — a −12 % lever is
only worth it if the other phases are also tunable; otherwise the floor is ~2.5×.
+### D.8 P1c result (2026-06-14): the gap is a UNIFORM constant factor — floor confirmed
+
+`-E` is the **wrong instrument**: it is dominated by **text serialization**, and kit's
+serializer is *cheaper* than tcc's — kit `-E` 0.93 B **<** tcc `-E` 1.15 B — which
+masks the compile-path gap entirely. **Discard the §2 `-E`-derived phase ratios
+("lex+pp 2.8×, emit 7×") — serialization-contaminated.** Using only the clean
+isolations (raw-lex harnesses + full `-c`, no serialization; tcc `-c` re-measured =
+0.6635 B):
+
+| slice | kit | tcc | ratio | share of kit |
+|---|--:|--:|--:|--:|
+| raw lex (harness) | 0.489 B | 0.182 B | **2.69×** | 26 % |
+| everything else (`-c` − raw-lex) | 1.42 B | 0.482 B | **2.95×** | 74 % |
+| **whole `-c`** | **1.91 B** | **0.664 B** | **2.88×** | 100 % |
+
+**The gap is a uniform ~2.8× constant factor.** kit and tcc spend their instructions
+in nearly identical *proportions* (~26 % lex / ~74 % rest in **both**); kit is simply
+~2.8× denser **everywhere**. There is **no disproportionately-bad phase to crush** —
+"emit 7×" was a serialization artifact. This is the signature of **pervasive
+engineering-style overhead** (context-struct indirection, bounds checks, composable
+functions + call overhead, growable containers, the public-API / value-stack / type-
+universe layers, the kept vtable seam) vs tcc's hyper-tuned monolith — *not* an
+algorithm or representation localizable to one place.
+
+**Conclusion — the answer to "what halves `-c`":** nothing structural does. Halving
+the total means roughly halving kit's instruction density **pervasively, in every
+phase** — i.e. tcc's monolithic engineering — incompatible with the standing
+constraints (keep module separability, the seven backends, the `CgTarget` seam; no
+fusion). What *is* available:
+- **One concrete one-time lever:** a tcc-class scanner (word-at-a-time / computed-goto;
+ drop per-token loc + punctuator spelling-intern) → lexer 2.69×→~1×, i.e. **≈ −12 %**
+ of `-c`. Real, worth banking; not a halving.
+- **The incremental touch-once grind** (the PERF campaign) is the only thing shown to
+ move the *constant factor*: 3.08×→2.64× tcc over ~22 commits (~−14 % Ir). Reaching
+ 1.5× that way is **many more multi-week waves** — a long-horizon destination, not a
+ single refactor.
+
+**1.5× tcc is a long-horizon incremental goal, not a structural one.** Recommended
+posture: bank the scanner lever (−12 %), continue the touch-once grind, treat "within
+1.5× of tcc" as a multi-campaign destination — unless the modularity constraints are
+relaxed (a tcc-style monolithic hot path), which is explicitly out of scope. **The
+structural hunt (§D) is closed; the path forward is incremental.**
+
---
## 0. Verified current state (what §4.3 already bought)