Skip to content

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

Box2D 6 min read Deep dive mediumAdept

Replay

Box2D's new Replay system records a full binary snapshot of world state followed by opcodes and arguments for every API call, including steps, forces, impulses, body creation and queries with their callback results. Because the engine is deterministic across platforms and thread counts, a single snapshot plus the call log is enough to reproduce a user's bug in a live simulation. Per-step transform hashes validate that determinism. The Replay Viewer generates key frames at load time within a memory budget for fast scrubbing, and the snapshot/restore API is now exposed for rollback. Index-based handles, POD data in arrays and events instead of callbacks make serialization cheap, though friction mixing, filter and pre-solve callbacks are not yet recorded.

Assumes: physics engine basicsC programmingdeterministic simulation

Related posts

  • Box2D 3.2

    Box2D easyNovice

    Box2D 3.2 runs roughly three times faster than 3.1, with the speedup broken down by source: contact recycling (~40%), solver algorithm refinement (~20%), AVX2 runtime dispatch (~15%), solver optimization (~10%) and broad-phase optimization (~10%), which compound multiplicatively. Following Jolt, body positions now use double precision while heavy math stays single-precision, raising the usable world size from about 16km to 1000km with little performance or memory cost. The release also adds recording and replay for debugging, which lays groundwork for snapshot/restore features such as rewind and networking, plus a new dynamic character mover.

  • We Put a Distributed Database In the Browser – And Made a Game of It!

    TigerBeetle easyNovice

    TigerBeetle's deterministic simulator, the VOPR, is compiled to WebAssembly via Zig and wrapped in a playable browser game that runs real TigerBeetle replicas across three levels. The levels run under perfect conditions, then Jepsen-style network faults, crashes and latency, and finally up to 8% read and 9% write storage corruption per replica. The VOPR mocks all network and storage I/O in a single process, verifies linearizability and dilates time: 3.3 seconds of simulation covers 39 minutes of real-world testing, and a day covers two years. Getting the whole cluster under WebAssembly's 2 GiB memory limit was the main porting challenge, and the post contrasts VSR's round-robin view changes with Raft's randomized elections.

  • Memory snapshots: Checkpoint/restore for sub-second startup

    Modal mediumAdept

    Modal cuts serverless container cold starts roughly 2.5x by checkpointing a gVisor container's full process tree and filesystem mutations just before it accepts a request, then restoring it instead of re-running Python's syscall-heavy import path (import torch alone makes 26,000 syscalls through OverlayFS and a FUSE lazy-loading server). Restore speed depends mostly on getting the main process's memory pages into the page cache. gVisor loads pages in the background, prioritizing faulting pages, while the FUSE layer aggressively preloads the pages file. Snapshots are created on demand per worker because of CPU feature, NVIDIA driver and runtime compatibility. GPU state can't be saved, so models are loaded into CPU RAM before the snapshot and moved to the GPU after restore via snap=True/snap=False lifecycle hooks.

  • GPU Memory Snapshots: Supercharging sub-second startup

    Modal mediumAdept

    Modal's GPU memory snapshots extend its gVisor-based checkpoint/restore to capture GPU state, using NVIDIA's new CUDA checkpoint API (driver branches 570/575) to lock CUDA processes, copy device memory, kernels, streams, contexts and memory mappings to host memory, then snapshot CPU and GPU state together. Restoring skips expensive warm-up such as torch.compile, CUDA graph capture and moving weights from CPU to GPU, which removes the earlier split between pre- and post-restore setup methods. Reported cold starts drop by up to 10x, for example Parakeet from about 20s to 2s, vLLM with Qwen2.5-0.5B from 45s to 5s, and a compiled ViT from 8.5s to 2.25s. The feature is in alpha and is enabled with an experimental flag.

  • Protocol-Aware Deterministic Simulation Testing

    TigerBeetle hardMaster

    TigerBeetle's deterministic simulator (the VOPR) has full visibility into each replica's consensus and storage state, so it can check invariants that black-box tools like Jepsen or Antithesis cannot see through user-facing APIs. For safety, it asserts that every committed WAL entry has matching checksums across replicas, that LSM manifest structure is consistent everywhere, and that replicas are byte-for-byte identical, which goes deeper than the cheaper production checks that crash a diverging backup. For liveness, it enforces per-replica invariants: a replica with an uncorrupted WAL must never need cluster coordination to recover, and missing blocks must be repaired from intact copies on other replicas whenever any copy still exists.

The quest for software engineering knowledge.

Look:
Layout: