We rewrote our Rust WASM parser in TypeScript and it got faster
31–40 of 239 posts
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#32Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#33The real win here isn't TS over Rust, it's the O(N²) -> O(N) streaming fix via statement-level caching. That's a 3.3x improvement on its own, independent of language choice. The WASM boundary elimination is 2-4x, but the algorithmic fix is what actually matters for user-perceived latency during streaming. Title undersells the more interesting engineering imo.
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#34The port had been done in a weekend just to see if we could use Python in production. The C++ code had taken a few months to write. The port was pretty direct, function for function. It was even line for line where language and library differences didn't offer an easier way.
A couple of us worked together for a day to find the reason for the speedup. Just looking at the code didn't give us any clues, so we started profiling both versions. We found out that the port had accidentally fixed a previously unknown bug in some code that built and compared cache keys. After identifying the small misbehaving function, we had to study the C++ code pretty hard to even understand what the problem was. I don't remember the exact nature of the bug, but I do remember thinking that particular type of bug would be hard to express in Python, and that's exactly why it was accidentally fixed.
We immediately started moving the rest of our back end to Python. Most things were slower, but not by much because most of our back end was i/o bound. We soon found out that we could make algorithmic improvements so much more quickly, so a lot of the slowest things got a lot faster than they had ever been. And, most importantly, we (the software developers) got quite a bit faster.
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#35Why not a shared buffer? Serializing into JSON on this hot path should be entirely avoidable
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#36Rewrite bias. Yoy want to also rewrite the Rust one in Rust for comparison.
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#37Earlier quoted context omitted.
same for uv but no one takes that message. They just think "rust rulez!" and ignore that all of uv's benefits are algo, not lang.
That's a pretty big claim. I don't doubt that a lot of uv's benefits are algo. But everything? Considering that running non IO-bound native code should be an order of magnitude faster than python.
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#38> Attempted Fix: Skip the JSON Round-Trip > We integrated serde-wasm-bindgen So you're reinventing JSON but binary? V8 JSON nowadays is highly optimized [1] and can process gigabytes per second [2], I doubt it is a bottleneck here. [1] https://v8.dev/blog/json-stringify [2] https://github.com/simdjson/simdjson
Re: We rewrote our Rust WASM parser in TypeScript and it got faster
#39Am I mistaken or isn’t TypeScript just Golang under the hood these days?