Lessons

Engine fundamentals, made visible

The things every engine leans on and most tutorials wave past: how memory reaches the CPU a cache line at a time, why data layout decides speed, how to refer to objects that come and go, how a game loop keeps the simulation steady whatever the frame rate does, what it takes to make a simulation replay exactly, how to find what's near what, in 2D and in 3D, how to spread a frame across every core without losing determinism, what a core does while a job waits, and how to find out where the time really goes. Each lesson has something to play with, and some measure real effects in your browser.

Memory

  1. 1Memory, cache lines and data layoutThe CPU never reads one variable from memory: it reads a 64-byte cache line. Why that makes data layout the biggest performance lever you have, measured in your browser, plus false sharing and the access patterns prefetchers love.
  2. 2Handles and allocatorsHow to refer to things that get created and destroyed without dangling pointers (generational handles and slot maps), and how to get memory for them without asking malloc every time (arenas, pools and free lists).

Time

  1. 3Game loops, fixed timesteps and running faster than real timeWhy simulating with the frame's delta time causes jitter, instability and replays that don't replay. How a fixed step with an accumulator fixes it, how interpolation keeps rendering smooth, how to avoid the spiral of death, and how decoupling the simulation from rendering lets it run at any speed.
  2. 4DeterminismSame inputs, same outputs, every time. What breaks it (floats, containers, random numbers, threads, clocks), the levels of determinism you can aim for, and how to use worker threads and frame budgets without letting timing leak into the simulation.

Space

  1. 5Spatial partitioning"What is near this?" and "what overlaps what?" are asked thousands of times a frame. Uniform grids, quadtrees, bounding volume hierarchies and sweep and prune, drawn live over moving objects, with the work each one does and where each one falls over.
  2. 6Octrees and flyingNavmeshes assume a floor. Airships, dragons and spaceships need to path through volume, and most of that volume is empty air. A sparse octree over a small city, A* through its free cells, how it compares with a plain voxel grid, and smoothing the result into a path worth flying.

Threads

  1. 7Jobs and task graphsSpreading a frame across every core. Job systems and how big a job should be, static splits against shared queues against work stealing, turning a frame's systems into a task graph from what they read and write, the critical path, reading results a frame later, and keeping all of it deterministic. With how flecs fits in.
  2. 8Threads, pools and fibersWhat a job system runs on, and what happens to a core when a job has to wait. Named threads like a game thread and a render thread, worker pools, and the four answers to waiting (block, help, fibers, coroutines), with why preemptive threads lose to cooperative scheduling for this kind of work.

Measuring

  1. 9Profiling: finding where the time goesEvery lesson here ends with "measure it". This one is how: frames rather than averages, sampling against instrumentation and what each gets wrong, reading a call tree and a flame graph, doing it in Visual Studio, and which other tools to reach for (Superluminal, Tracy, VTune, PIX, RenderDoc) and when.

Examples are in C++. Benchmarks run as JavaScript or WebAssembly in your browser: absolute numbers vary by machine, the ratios are what carry over.