[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

ref(opt): build input.wasm for size

layout.wasm must stay -O2: Clay_EndLayout is the render hot path and its
speed on heavy layouts comes from -O2's inlining/unrolling. -Os/-Oz both
regress dashboard/diff-render by 24-32% (CodSpeed), so size-optimizing it
is a net loss. input.wasm is opt-insensitive in the benchmarks, so build
it -Oz for a free size win. Levels stay overridable via LAYOUT_OPT/INPUT_OPT.

Nate Moore (Jun 1, 2026, 3:41 PM -0500) 7d8f1a37 8aad2225

+18 -7
+18 -7
Makefile
··· 1 1 CC = clang 2 2 3 - CFLAGS = --target=wasm32 -nostdlib -O2 \ 4 - -ffunction-sections -fdata-sections \ 5 - -mbulk-memory \ 6 - -DCLAY_IMPLEMENTATION -DCLAY_WASM \ 7 - -Isrc -I. 3 + # Per-module optimization levels. layout.wasm holds Clay_EndLayout (~33% of the 4 + # code and the entire render hot path); on heavy layouts its speed comes from the 5 + # inlining/unrolling that only -O2+ does — -Os/-Oz regress dashboard/diff-render 6 + # by 24-32%, so layout must stay -O2. input.wasm is the trie + input state machine, 7 + # whose benchmarks are insensitive to opt level, so it is built -Oz for size. 8 + # Override on the command line to A/B on CodSpeed, e.g. `make LAYOUT_OPT=-O3`. 9 + LAYOUT_OPT ?= -O2 10 + INPUT_OPT ?= -Oz 11 + 12 + CFLAGS_BASE = --target=wasm32 -nostdlib \ 13 + -ffunction-sections -fdata-sections \ 14 + -mbulk-memory \ 15 + -Isrc -I. 16 + 17 + LAYOUT_CFLAGS = $(CFLAGS_BASE) $(LAYOUT_OPT) -DCLAY_IMPLEMENTATION -DCLAY_WASM 18 + INPUT_CFLAGS = $(CFLAGS_BASE) $(INPUT_OPT) 8 19 9 20 LDFLAGS_COMMON = -Wl,--no-entry \ 10 21 -Wl,--import-memory \ ··· 54 65 @echo "Built input.wasm ($$(wc -c < input.wasm) bytes raw, $$(gzip -c input.wasm | wc -c) bytes gzip)" 55 66 56 67 layout.wasm: $(DEPS) 57 - $(CC) $(CFLAGS) $(LAYOUT_LDFLAGS) -o $@ src/module-layout.c 68 + $(CC) $(LAYOUT_CFLAGS) $(LAYOUT_LDFLAGS) -o $@ src/module-layout.c 58 69 59 70 input.wasm: $(DEPS) 60 - $(CC) $(filter-out -DCLAY_IMPLEMENTATION -DCLAY_WASM, $(CFLAGS)) $(INPUT_LDFLAGS) -o $@ src/module-input.c 71 + $(CC) $(INPUT_CFLAGS) $(INPUT_LDFLAGS) -o $@ src/module-input.c 61 72 62 73 layout.wasm.ts: layout.wasm 63 74 deno run --allow-read --allow-write tasks/bundle-wasm.ts layout.wasm layout.wasm.ts