Topics / runtimes

Languages and runtimes

The work a language runtime does on your behalf: scheduling goroutines, collecting garbage, and running portable bytecode safely and fast.

Dives
6
Levels
51
Notes
5
Reading
4.5h
Start with Inside V8
How to read thisEvery line is a diveEach tick is one level, drawn at the layer of the stack it explains. Longer lines go further down, from why a thing exists to the silicon that runs it.6 dives · 51 levels

The path

Read in this order and each dive leans on the ones before it. Every dive also stands on its own.

  1. 01

    What V8 does with your JavaScript

    One distance function, four execution tiers, and an assumption that breaks. Step through real bytecode, build hidden classes, feed an inline cache, and follow a deoptimization down to the machine instructions that caused it.

    Idea to Machine

    43 min9 levels

  2. 02

    Go concurrency, from go keyword to OS thread

    What makes goroutines and channels different, the patterns they unlock and the bugs they invite, then down through the G-M-P scheduler, the inside of a channel, OS threads and the netpoller, to the two instructions that make stacks growable.

    Idea to Machine

    45 min8 levels

  3. 03

    Go’s garbage collector, from GOGC to the cache line

    Follow a 64-byte cache entry through allocation, concurrent marking and sweeping. Break a collector, tune a heap goal, read real runtime output, and see why Green Tea changes the order in which memory is touched.

    Idea to Silicon

    45 min8 levels

  4. 04

    Rust ownership: the checks and the machine

    Follow a batch of log lines through moves, borrow checking, threads and async suspension. See what the compiler proves, what a future stores, and the instructions that remain.

    Idea to Machine

    42 min8 levels

  5. 05

    Zig comptime: the compiler runs your code

    Build a tiny binary protocol with types as values, a derived packet codec and a CRC table. Follow ordinary Zig code through compile-time evaluation into the bytes and instructions that survive.

    Idea to Machine

    40 min8 levels

  6. 06

    WebAssembly, top to bottom

    Start with real C zlib compressing your text in this tab. Then go down through the JavaScript boundary, the module format and the stack machine to the guard pages and x86-64 an engine uses to run it fast and safely.

    Idea to Machine

    40 min10 levels

Notes

Practical answers in languages and runtimes.

  1. Note3 min read

    Find why Node and V8 deoptimize a function

    Use V8 optimization traces to identify the invalidated assumption, then reproduce it with a controlled input change before changing application code.

  2. Note3 min read

    Cross-compile C and Zig with Zig 0.17.1

    Select the target explicitly with zig cc -target or a build script using standardTargetOptions. Verify the file format separately from whether the artifact runs on the target.

  3. Note4 min read

    Fix “borrowed value does not live long enough” in Rust

    Keep the owner alive through the last borrow use, or return owned data. Five examples cover locals, borrowed structs, closures, temporaries and iterators.

  4. Note3 min read

    Tune Go GC with GOGC and GOMEMLIMIT

    Use GOGC to trade heap growth for collection frequency and GOMEMLIMIT to constrain Go-managed memory. Set container headroom explicitly: Go 1.27.3 does not derive this limit from cgroups.

  5. Note3 min read

    Find and fix a goroutine leak in Go

    Compare goroutine stacks after work has drained, identify the missing exit path, and cancel and join workers before returning.