🧼 split layout and input entrypoints#37
Conversation
commit: |
ghostdevv
left a comment
There was a problem hiding this comment.
There are quite a few references to both wasm.ts and clayterm.wasm still
a4e9caf to
0c58432
Compare
31d049e to
0bbf6d0
Compare
cowboyd
left a comment
There was a problem hiding this comment.
Looks good to me. So tiny! 🤩
|
@cowboyd ah I need to rerun those numbers after rolling back the more aggressive stuff! still tiny but not quite this tiny (yet) |
Merging this PR will degrade performance by 30.86%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | UTF-8 3-byte character |
85 µs | 176.6 µs | -51.86% |
| ❌ | Simulation | UTF-8 4-byte emoji |
85.5 µs | 173.2 µs | -50.62% |
| ❌ | Simulation | Kitty protocol (CSI u with modifiers) |
97.6 µs | 185.5 µs | -47.38% |
| ⚡ | Simulation | long input burst (200 bytes) |
979.3 µs | 536.1 µs | +82.66% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ref/opt-split (51f4d26) with main (ebaf397)
Building on #50 (brotli+z85 encoding), this PR splits the WASM compilation into two scoped modules and exposes them as separate export subpaths, enabling per-consumer dead-code elimination and per-module opt tuning.
module-layout.candmodule-input.c./layoutand./inputexport subpaths exposed viabuild-npm.ts, allows downstream bundlers to tree-shakewasm.ts; updated.gitignoreandMakefileclean targets accordinglyPer-consumer DCE
Consumer that import only one subpath no longer need to load the other module's WASM.
main)clayterm/inputclayterm/layoutFull bundle (JS + WASM), gzipped: input-only 47.8 kB → 8.5 kB (−82%); layout-only 48.8 kB → 45.4 kB (−7%).
Honest size note
Now that brotli+z85 (#50) is on
main, the split does not reduce total install size.mem/utf8/wcwidthare duplicated across both modules, so the combined WASM is ~equal (42.1 kB split vs 42.4 kB unified, brotli) and the full package is marginally larger (115.4 kB → 121.5 kB unpacked, +5.3%). The wins here are scoping and per-module tunability, not aggregate size. Narrower compilation units also let--gc-sectionsapply more aggressive DCE per module.