HeadlinesBriefing favicon HeadlinesBriefing.com

Rust WASM Parser Rewrite in TypeScript Boosts Speed 3x

Hacker News •
×

We swapped our Rust-based WASM parser for TypeScript and gained 3x faster performance. The openui-lang parser, which converts LLM-generated DSLs into React components, suffered from WASM's JSON serialization overhead. Every parse call incurred a mandatory boundary cost: copying strings between JS and WASM, serializing/deserializing JSON. Rust parsing itself was never the bottleneck.

Benchmarks showed WASM + JSON was 20-61µs per call; TypeScript (re-parsing) was 9-19µs. The real win came from streaming optimizations. Caching completed statements reduced total parse cost from 316µs to 69µs for a contact-form fixture.

Eliminating WASM eliminated the boundary, but the core issue was data transfer, not computation. This experience clarified WASM's niche: compute-bound tasks with minimal interop, like image processing or cryptography, where boundary costs are amortized. For parsing, V8's JIT made Rust's speed advantage irrelevant.

The lesson: profile where time is actually spent.