Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 10 min read Case study mediumAdept

Adding the V8 CPU Profiler to v8go

Exposing V8's CPU profiler through v8go, the Go library for running JavaScript in V8 isolates via Cgo, came down to a choice between lazily fetching each profile node property with its own Cgo call or eagerly building the whole call tree in C++ and rebuilding it in Go from a single pointer. Cgo calls cost roughly 54 ns Go-to-C and 149 ns C-to-Go, which made eager loading look like the obvious winner. Benchmarks showed lazy loading was actually faster on a small profile (~20µs vs ~25µs), and eager loading only pulled ahead on a large tree from the Hydrogen starter template (~60µs vs ~90µs). Keeping getters over private fields leaves room to offer both modes, and the broader lesson is to benchmark rather than trust intuition and to use inputs that reflect real usage.

Related posts

  • How Bun supports V8 APIs without using V8 (part 1)

    Bun hardMaster

    Bun, which runs on JavaScriptCore, implements a growing subset of V8's C++ embedding API so Node.js native modules like cpu-features load without V8. The post contrasts JSC and V8 value representation, calling conventions, isolates/contexts and handle-based lifetimes. It then shows why an initial approach of reinterpreting JSC's 8-byte JSValue as V8's Local<T> pointer failed. V8's inline header functions such as Object::GetInternalField dereference Local pointers and read map and instance-type fields at fixed offsets, so Bun's in-memory layouts must match what V8's compiled-in inline code expects.

  • V8 release v6.9 · V8

    V8 easyNovice

    V8 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.

  • Celebrating 10 years of V8 · V8

    V8 easyNovice

    V8 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.

  • Giving V8 a Heads-Up: Faster JavaScript Startup with Explicit Compile Hints

    V8 mediumAdept

    Chrome 136 ships Explicit Compile Hints, which let developers mark a JavaScript file for eager compilation by placing the magic comment `//# allFunctionsCalledOnLoad` at the top. Eager compilation avoids a duplicate lightweight-then-full parse and moves compile work onto a background thread interleaved with network loading, instead of blocking the main thread on first call. In V8's experiment, 17 of 20 popular pages improved, with an average 630 ms reduction in foreground parse and compile time. Apply it sparingly to a core file because over-compiling costs time and memory, and verify the effect with `--log-function_events`. Per-function hints are planned.

  • Bun v1.3.7

    Bun mediumAdept

    Bun v1.3.7 upgrades JavaScriptCore, which brings faster async/await (35%), Array.from, padStart/padEnd, array.flat and better ARM64 codegen using ccmp/ccmn chains. It also speeds up Buffer.from() with arrays by up to 50% and Buffer.swap16/swap64 by 1.8x and 3.6x through CPU intrinsics. New APIs include Bun.wrapAnsi (33–88x faster than the wrap-ansi npm package), native JSON5 parsing and imports, and Bun.JSONL with streaming parseChunk. For diagnostics there is Markdown CPU and heap profile output, --heap-prof heap snapshots and the node:inspector Profiler API. Compatibility fixes cover header case preservation in fetch, S3 presign options, bun pm pack lifecycle scripts, Indic grapheme clustering and Next.js 16 timer internals.

The quest for software engineering knowledge.

Look:
Layout: