Engineering Blog

Engineering: React Reconciliation with Streaming LLMs

How we mitigated vDOM diffing bottlenecks during high-velocity stream generation.

The 100 TPS Bottleneck

When rendering a Chat UI for an LLM that streams at 100+ Tokens Per Second, the native React Reconciliation cycle quickly becomes the primary bottleneck.

Standard state updates trigger a full virtual tree diff. When streaming raw markdown into a Markdown renderer that translates Abstract Syntax Trees (ASTs) on the fly, performing this every 10 milliseconds obliterates main thread performance.

Mitigation via Debounced Mutation

"Updating DOM states dynamically requires batching chunks outside of the render cycle, committing only visually distinct layout differences."

— Duplex Engineering

We established an accumulator buffer running independently of the React lifecycle. We throttle visual commits to a 16ms tick (matching a 60 FPS requestAnimationFrame cycle), batching the accumulated chunks as a single flush.