How we made JSON.stringify more than twice as fast
V8 more than doubled JSON.stringify throughput on the JetStream2 json-stringify-inspector benchmark by adding an iterative, side-effect-free fast path that skips the general serializer's defensive checks. Supporting changes include templatizing the stringifier on one-byte vs two-byte strings, SIMD and SWAR scanning for escapable characters, and a fast-json-iterable flag on hidden classes that lets keys be copied without checks. Numbers are now converted with Dragonbox instead of Grisu3, and output goes to a segmented Zone-allocated buffer to avoid realloc-and-copy. The fast path ships in V8 13.8 (Chrome 138) and applies only without replacer/space arguments, custom toJSON, indexed properties or ConsString-like strings.
Related posts
- Celebrating 10 years of V8 · V8
V8 easyNoviceV8 grew over ten years from a secret project started in 2006 on a Danish farm into a JavaScript and WebAssembly engine supporting eight instruction sets, embedded by both Chrome and Node.js. Key milestones include the Irregexp regex engine, the Crankshaft and later TurboFan optimizing compilers, the Ignition interpreter, the incremental and then Orinoco parallel/concurrent garbage collectors, idle-time GC, code caching, Liftoff, and Spectre mitigations. V8 Bench scores rose 4× from 2008 to 2018, with dips from the initial ES2015 features and Spectre mitigations. The curve flattens after 2013 because the team shifted from synthetic micro-benchmarks to real-world performance, and Speedometer 1 scores rose another 4× over 2013–2018.
- V8 release v6.9 · V8
V8 easyNoviceV8 v6.9 embeds built-in functions directly into the binary on x64, so all Isolates share one copy instead of each holding up to 700 KB on its own heap. Across the top 10k sites this cut median V8 heap size by 9%, and 10% of sites saved 3.7 MB or more. Liftoff, a new baseline WebAssembly compiler, speeds startup by over 10×. DataView methods were reimplemented in Torque and inlined by TurboFan to match TypedArray speed, and concurrent, incremental and parallel WeakMap processing roughly halves Mark-Compact GC pauses, with a linear-time fallback replacing worst cases that could take seconds. The release also adds Array.prototype.flat and flatMap.
- 500x faster postMessage(string)
Bun mediumAdept
Bun v1.2.21 makes postMessage(string) between workers nearly independent of string size, up to 500x faster with ~22x less peak memory on 3 MB strings (593 ns vs 326,290 ns in 1.2.20). JavaScriptCore strings are already immutable with atomic reference counts, so Bun skips Structured Clone serialization and shares the StringImpl pointer directly. Before sharing, it forces the lazy hash computation and marks the string never-atomicize. The fast path applies only to plain strings of at least 256 characters sent alone within the same process; atoms, symbols, substrings and ropes still get copied.
- Land ahoy: leaving the Sea of Nodes
V8 hardMasterV8 is replacing Sea of Nodes in its Turbofan optimizing compiler with Turboshaft, a traditional control-flow-graph IR. The JavaScript backend and the entire WebAssembly pipeline already run on it, and Maglev is taking over the JS frontend. After more than a decade with Sea of Nodes, the team found its theoretical benefits largely unrealized for JavaScript. Checks, loads and stores keep most nodes pinned to the effect or control chains, memory operations rarely float, and the graphs are hard for engineers to read, debug and lower. Explicit control and effect chains make lowerings error-prone, while a CFG stays closer to both the source code and the emitted assembly.
- Speculative Optimizations for WebAssembly using Deopts and Inlining
V8 hardMasterV8 in Chrome M137 adds speculative call_indirect inlining and deoptimization support for WebAssembly, using runtime call-target feedback gathered by the Liftoff baseline compiler so TurboFan can inline up to four likely callees behind cheap instance and target checks. When an assumption fails, the Deoptimizer serializes the optimized frame into a FrameDescription, rebuilds the matching Liftoff stack frame and resumes in baseline code mid-function. This lets the optimizer drop generic slow paths that would otherwise block further optimization. The gains matter most for WasmGC languages like Dart, Java and Kotlin: over 50% average speedup on Dart microbenchmarks and 1–8% on realistic applications, with one microbenchmark dropping from 675 ms to 90 ms.