khauma's profile
Kahlil Wallace@khauma•Mar 22
7.6K
Post cover image

Rewriting our Rust WASM Parser in TypeScript

Avatar of hnHacker News•From openui.com•Mar 21•7m read time

A team built a custom DSL parser in Rust compiled to WASM, then discovered the bottleneck wasn't computation but the WASM-JS boundary overhead. Attempting to skip JSON serialization via serde-wasm-bindgen made things 30% slower due to fine-grained boundary crossings. Rewriting the parser in TypeScript eliminated the boundary entirely, yielding 2.2-4.6x faster per-call performance. They also fixed an O(N²) streaming problem by caching completed statement ASTs, reducing total streaming cost by 2.6-3.3x. Key lessons: WASM shines for compute-bound tasks with minimal interop, not for frequently-called parsers on small inputs where boundary overhead dominates.

1 Comment

Sort:

khauma's user avatar
Kahlil Wallace
@khauma
Joined Jan 30. 2025
7.6K

A nerd who loves software development but is down for longboarding, bouldering or martial arts!

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard