---
title: "Determinism"
description: "Box2D v3 achieves algorithmic, multithreaded and cross-platform determinism by default with no noticeable performance cost, verified in CI by a 'Falling Hinges' test that checks the sleep step count and a transform hash across MSVC, Clang, GCC, x64 and ARM."
url: "https://swe.quest/articles/determinism-30e0d5f0db824bbe"
canonical: "https://box2d.org/posts/2024/08/determinism/"
source: "Box2D"
published: "2024-08-27"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 8
tags: ["gaming","c-cpp","concurrency","testing","ci-cd"]
---

# Determinism

A post on [Box2D](https://swe.quest/sources/box2d.md), published 2024-08-27, 8 min read, Deep dive. Original: [https://box2d.org/posts/2024/08/determinism/](https://box2d.org/posts/2024/08/determinism/)

## Summary

Box2D v3 achieves algorithmic, multithreaded and cross-platform determinism by default with no noticeable performance cost, verified in CI by a 'Falling Hinges' test that checks the sleep step count and a transform hash across MSVC, Clang, GCC, x64 and ARM. Multithreaded determinism comes from per-thread bit arrays merged with bitwise OR rather than atomic appends or sorting, keeping contact order tied to creation order. Cross-platform determinism works without fixed-point math by avoiding fast-math, disabling FMA (-ffp-contract=off) and using custom trig approximations, since atan2f differs across platforms while sqrtf is consistent. Roll-back determinism for client-side prediction in multiplayer is not yet supported because of the engine's internal state.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Games](https://swe.quest/tags/gaming.md) (Domains)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- floating-point arithmetic
- multithreading basics ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))
- rigid body physics engines

## Keywords

Box2D, fused multiply-add, fast-math, GitHub Actions, atan2f, client-side prediction

## Related posts

- [Box2D 3.2](https://swe.quest/articles/box2d-3-2-6bf0b6359f7de39c.md): Box2D · 2026-10-18 · Easy · 2 min read · Games, Performance engineering, C & C++
  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.
- [Replay](https://swe.quest/articles/replay-cd1e00a39568cbbd.md): Box2D · 2026-06-07 · Medium · 6 min read · Games, Debugging, C & C++, Data structures
  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.
- [Box2D 3.1](https://swe.quest/articles/box2d-3-1-d8698258cbab254f.md): Box2D · 2025-04-19 · Medium · 2 min read · Games, Performance engineering, C & C++
  Box2D 3.1 fixes most bugs and build problems from 3.0 and adds an experimental geometric character mover built from collision queries and a specialized solver that runs outside the physics world.
- [Turbocharging V8 with mutable heap numbers](https://swe.quest/articles/turbocharging-v8-with-mutable-heap-numbers-d32025b1d5ea1f1c.md): V8 · 2025-02-25 · Hard · 5 min read · Runtimes & VMs, Compilers, JavaScript, Performance engineering, Memory management
  V8 eliminated a performance cliff in JetStream2's async-fs benchmark caused by a custom Math.random whose \`seed\` lives in a ScriptContext slot.
- [This Month in Ladybird - August 2026](https://swe.quest/articles/this-month-in-ladybird-august-2026-e7183d3f3eaa522b.md): Ladybird · 2026-08-31 · Hard · 13 min read · Browsers, Performance engineering, Rust, Memory safety, CSS
  Ladybird's August 2026 progress centres on a sustained engine performance push.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
