📋 Context & Problem Description
Recent Playwright resource benchmarks reveal that while Gutter TinyGo builds are highly optimized for bundle size (407 KB gzip vs Go std's 1.8 MB gzip), they consume significantly more memory than Go std at scale.
At 10,000 items, TinyGo's heap expands to 48 MB (52.6 MB total RAM), compared to Go std's 36 MB heap (40.1 MB total RAM).
This is due to LLVM/TinyGo's conservative GC implementation, which defers sweep cycles to reduce footprint and size, causing memory accumulation when allocating thousands of element structs during hydration.
💡 Proposed Solution & Implementation Plan
- TinyGo GC Selector in CLI:
Allow selecting the garbage collector algorithm in gutter build and gutter run:
--gc=conservative (default)
--gc=leaking (useful for high-speed, short-lived tasks where memory recovery is not required)
- Explicit GC Triggers:
Provide a helper to trigger an explicit GC sweep on the client (e.g. right after hydration completes or route transition finishes) to release unneeded structs:
// Internally wraps runtime.GC() on WASM target
gutter.TriggerGC()
🎯 Impact & Benefits
- Better RAM Management: Prevents memory ballooning on large-scale pages using Gutter with TinyGo.
- Flexible Builds: Empowers developers to choose the right GC strategies for their workloads.
🏷️ Suggested Labels
performance, cli, wasm
📋 Context & Problem Description
Recent Playwright resource benchmarks reveal that while Gutter TinyGo builds are highly optimized for bundle size (407 KB gzip vs Go std's 1.8 MB gzip), they consume significantly more memory than Go std at scale.
At 10,000 items, TinyGo's heap expands to 48 MB (52.6 MB total RAM), compared to Go std's 36 MB heap (40.1 MB total RAM).
This is due to LLVM/TinyGo's conservative GC implementation, which defers sweep cycles to reduce footprint and size, causing memory accumulation when allocating thousands of element structs during hydration.
💡 Proposed Solution & Implementation Plan
Allow selecting the garbage collector algorithm in
gutter buildandgutter run:--gc=conservative(default)--gc=leaking(useful for high-speed, short-lived tasks where memory recovery is not required)Provide a helper to trigger an explicit GC sweep on the client (e.g. right after hydration completes or route transition finishes) to release unneeded structs:
🎯 Impact & Benefits
🏷️ Suggested Labels
performance,cli,wasm