JS vs Rust: Fast Trading Charts
November 2026
Those that are interested become interesting. So, in a constant pursuit of trying to become interesting, my latest weekend project took me down a rabbit hole: measuring the performance of React vs Rust (WebAssembly, or Wasm) in the browser for trading charts.
Trading charts tend to have some operations on the heavier side. Hyperliquid can support around 200k orders a second, and the biggest equity exchanges peak at over 1M messages a second. Of course you can move a lot of the compute to the server, but tasks like re-bucketing data for every pan and zoom level of a depth chart or heatmap make more sense on the client.
Instinctively, I just assumed that JavaScript would be slow and Rust/Wasm would be fast. Likely the result of years of JavaScript hate and Rust hype from armchair software engineers who have used neither. The spoiler is that tuned JS gets you close to the same performance as Rust for realistic amounts of data. On a single chart, a user wouldn't notice the difference. But I wanted to find where the edges are.
A quick TL;DR on how Rust and Wasm work: you write your logic in Rust, compile it to Wasm, and use a small bit of glue code to bridge calls between Rust and JS. The Rust code has its own space in memory to read and write, but it can't do any of the chart drawing itself; it still has to hand that off to JS.
Knowing this, I figured the compute would be the slowest piece, and slow enough in JS that the cost of bridging to faster Wasm code would be worth it.
The first quick lesson worth covering is the feed format. Switching from JSON to binary raised the highest healthy trade rate 5x for React and 10x for Rust. With JSON, Rust was actually the slower one, because every message crossed the bridge as a string, and JS's JSON.parse is already highly optimised native code. My initial theory was showing its first signs of weakness.
The first real test used a liquidity heatmap, and we monitored how many frames were dropped while zooming and panning around. Each frame has to recompute the heatmap for the current zoom level and pan position. The initial results were poor. Drawing the heatmap cell by cell in JS dropped about half the frames, and Rust was even worse, because every cell was a call over the bridge. Some frames took up to 400 ms.
But this was a naive approach. I mentioned earlier that Rust runs in its own space in memory. Rust talking to JS over the bridge is slow, but JS can read the memory Rust writes to directly. So instead of making calls over the bridge, we compute the heatmap as a bitmap in Rust, then draw that onto the canvas. (A bitmap, or pixel buffer, is just 4 bytes per pixel in memory. Rust paints all ~1M pixels itself, then the canvas copies the finished picture in one call.) This was a huge improvement. With 20M updates of history, a frame now took 36 ms and only 9% of frames dropped, and it stayed fully smooth up to 5M updates.
I wondered: could we borrow the same idea in JS? With the bitmap approach, JS took 76 ms per frame and dropped 24% of frames at 20M updates, and stayed smooth up to 2.5M updates. Once again, a significant improvement on the default cell-by-cell approach.
Across the whole project, a better data structure or algorithm gave a 5–100x speed-up, compared with just 1–2x from switching language.
We're already fast enough for any reasonable requirements. But you won't find reasonable men on the tops of tall mountains. So can we push this even further?
Enter the GPU. I've heard lots of good things about GPUs.
WebGL gives us access to the GPU, so we can write a shader in the OpenGL Shading Language (GLSL) that recomputes the heatmap for every frame. The idea is to build the data grid once, in Rust or JS, copy it to the GPU, and let a small GLSL program recompute the heatmap for the current pan and zoom, with every pixel worked out in parallel.
No dropped frames, about 8 ms of GPU time per frame, and smooth all the way up to 20M+ updates. It made no difference whether Rust or JS built the grid; they drew equally fast. Rust did hand the grid to the GPU about 3x faster (94 vs 265 ms), but built the grid 2x slower (989 vs 468 ms), so JS + WebGL was actually ready first.

The memory profile of all the tuned versions is fairly similar: for 20M updates, it's about 380 MiB. WebGL is the one exception, because it keeps a second copy of the data grid (about 230 MiB) on the GPU.
For a single chart with an unreasonable amount of history, JS + WebGL is plenty. But is there a use case within reasonable bounds? Multi-chart views are exactly that. This pursuit of unreasonable performance was not in vain yet.
Multi-chart views
Traders are a unique breed. They like to ingest as much information as their grey matter can hold: multiple charts for multiple markets, multiple views of a single market, multiple charts of multiple views of multiple markets.

Sixteen markets, each on its own feed at 5k trades/s, on 1-second candles: Canvas 2D charts fed by the Rust/Wasm pipeline, holding 60 fps.
When you have many charts drawn from a single feed, for example 1s, 5s, 1m and 5m candles all for a BTC perp market, WebGL is significantly better. At 32 charts it ran at 60 fps using less than 10% of the main thread. Lightweight Charts, by comparison, fell to about 40 fps, with over a third of its frames late, and our plain Canvas 2D chart used about 20%. With a single feed, it doesn't matter whether JS or Rust powers the data; they perform the same. But when you jump to multiple feeds, say 16 different markets all at once, the bottleneck becomes taking in the data, and a Rust data pipeline nearly halves the main-thread load compared with JS. Rust is so good at handling multiple feeds that, at the heaviest load we tested (16 feeds at 50k trades a second each), a Rust-powered Canvas 2D chart outperformed even the JS + WebGL combination. The catch is memory: with a feed per chart, the Rust pipeline used up to about twice as much.
So where does that leave us?
The browser's limits were much further out than I expected. I was genuinely surprised that a well-thought-out JS implementation holds its own against moving compute-heavy tasks into Rust. A small proud moment for the unsung hero that is JavaScript and its V8 buddy. For a single chart with realistic message flow, the Lightweight Charts library and some tuned JS code is plenty: a 5–100x improvement from changing the data structure, against 1–2x from changing language. Rust starts to shine when the shape of the problem changes, and taking in data, rather than drawing it, becomes the bottleneck. WebGL is a great little party trick to keep in your back pocket, but it honestly feels like overkill for trading charts. Of the combinations we tested, Rust with a Canvas 2D context seems like the sweet spot. It's overkill for a single chart, but it nearly halves the main-thread load when you have many charts on many data feeds, and it doesn't stray into the complexity of GPU shader programs. It's the Goldilocks zone. But only reach for Rust/Wasm or the GPU if you're actually hitting a slowdown.
A note about the research workflow
Tokens not consumed overnight are tokens wasted.
I had an agent run these tests overnight in a continuous research loop, chasing faster and faster results. In the mornings I'd give it a steer, like suggesting it look into WebGL, but the rest of the tweaks and bug fixes happened inside the autonomous loop. Over the two nights of research, a single session ran 20 subagents and spent nearly 600M tokens. That's fairly conservative consumption, to be honest: each experiment lived in its own worktree, and the benchmark runs took up most of the time while the agents sat idle waiting for them.
As with all my Claude sessions, I collected the logs. You can build a simple server and point OTEL_EXPORTER_OTLP_ENDPOINT at it. That means you can go back afterwards and ask Claude to improve the research loop itself.
I originally set up the research repo to follow autoresearch. Once the research was done and written up, I went back and autoresearched the autoresearch. With the logs it's possible to hill-climb towards better research agents, and I was particularly interested in one question: can we do the same research and get the same results for fewer tokens? The answer was yes: about half the cost, with the same outcome.
The biggest improvement was replacing the single agent running the loop, with its ever-growing context, with a deterministic workflow in a small Python script. Each step runs in a fresh session, so context stays clean and each agent can focus on its one job. The script runs the evals and decides what passed, not the agent.
Evaluating harness and agent tweaks against tasks you've already run, and already have logs and outcomes for, creates an extremely powerful self-improving loop.