cartae.app

Twinz notebook · Article 2

Simulating 12.25 million inhabitants 233 times faster than real time

Twinz (twinzcities.com) continuously simulates the 12.25 million inhabitants of Île-de-France, each with a home, a budget, a schedule and daily trips, on the first twin, paris.twinzcities.com. To test an idea over several weeks without waiting a real month, the engine now computes 24 full hours of the region in 6 minutes and 10 seconds on 8 CPU cores, without a graphics card.

By François · 25 November 2026 · 7-minute read

Why speed decides whether a simulator is any use

If you want to know how a neighbourhood reacts to a station closing, a change in timetables or a rumour about a restaurant, a simulator running at real-time speed (×1) quickly becomes unusable. You would have to wait a whole month to observe thirty days of urban life. Worse still: in my first attempt in JavaScript, told in the founding article, the engine dropped under load to 0.36× real time, measured for 3.29 million inhabitants, while consuming 30 to 40 GB of RAM.

When I laid the foundations of Twinz again in November 2026, I set myself two constraints that seem to pull against each other. First, nobody sleeps when the camera looks elsewhere: the 12,255,926 inhabitants of the 1,266 municipalities of Île-de-France live continuously, with their purchases, their wages, their benefits and their trips. Second, the engine must be able to speed up hard on an ordinary server, without a cluster of graphics cards (GPUs).

I am not publishing the engine's source code here, nor the internal layout of its memory structures. The measured figures, however, can be checked, as can the limits met on the test bench, and the three public principles behind this speed deserve a clear explanation.

The figures measured over a full day

On 24 November 2026, the native engine ran exactly 24 simulated hours (86,400 s) for the whole of Île-de-France on a server allocated 8 CPU cores, without a graphics card and with no viewer connected, to isolate the pure cost of computation. The whole day took a measured 370.25 s, that is 6 min 10 s (6.17 min in decimal), which gives a calculated average speed of ×233.36. At this pace, simulating a whole year of the region takes about 37.5 h (calculated).

The load naturally varies over the urban day. Around 3 am, when most residents are asleep, the engine reaches the cap set for the test, at a measured ×603.02. At 10 am, at the peak of morning trips and activities, it drops to its measured floor of ×109.00. Over the 24 h, average use is 5.49 cores, the midnight rollover completes in a measured 1.23 s and peak RAM reaches 28.32 GiB with no visible leak.

SPEED MEASURED HOUR BY HOUR OVER 24 H (12.25 M INHABITANTS, 8 CORES, NO GPU) 0× 200× 400× 600× 24 h average: ×233.36 3 am: ×603 10 am: ×109 1 pm 6 pm midnight 3 am 7 am 10 am noon Continuous record of 86,400 simulated s (cap ×600): 370.25 s (6 min 10 s), RAM peak 28.32 GiB, 0 errors.
Figure 1. Speed profile measured hour by hour over 24 simulated hours of Île-de-France (24 November 2026). The 10 am dip reflects the morning peak in activity; the night reaches the cap set at ×600.

For fast research experiments, we don't need to run the whole region for every trial. An extraction tool cuts out a self-contained neighbourhood from the real state of the city. On 25 November, an 800 m circle around Place de la Contrescarpe (5th arrondissement of Paris), gathering 16,030 inhabitants with their complete economy and daily life, simulated 24 h in a measured 1.90 s on 4 cores, that is ×45,415, and 7 days in 12.57 s (×48,110) under 0.7 GiB of RAM.

Measured benchmarks of the Twinz engine (24 and 25 November 2026)

Indicator All of Île-de-France Self-contained neighbourhood extract
Scope 12,255,926 inhabitants, 1,266 municipalities (measured) 16,030 inhabitants, 800 m radius in Paris 5th (measured)
Speed over 24 h ×233.36 in 6 min 10 s on 8 cores without GPU (measured) ×45,415 in 1.90 s on 4 cores without GPU (measured)
Peak RAM 28.32 GiB over 24 h, long-term target 1 KB/inhabitant (measured / target) Under 0.7 GiB over 7 simulated days (measured)
Accounting integrity 0-cent gap across the 5 economic balances (measured) 0-cent gap on the same economic core (measured)
Determinism Identical bytes on 1, 2, 4 or 8 partitions, ARM64 and x86-64 (measured) Same log with 0, 1 or 2 cameras open (measured)

Measurements taken on an x86-64 Linux server (8 cores allocated, 5.49 cores used on average), with binary parity checks cross-run on an ARM64 machine.

Three public architecture choices that explain the result

This speed does not come from a trick hidden in the hardware. It rests on three design rules set on the very first day of the rewrite, which remove unnecessary work before even trying to speed it up.

THREE PUBLIC PRINCIPLES OF THE TWINZ ENGINE 1. FIXED COLUMNS No more heavy objects scattered in memory. States live in contiguous arrays read in one block by the CPU. Target: 1 KB / inhabitant 2. TIMED PLANS The engine computes a whole trip at departure, traffic lights included. The browser computes the position on its clock. Zero fixed 0.1 s steps 3. DETERMINISTIC RUST Hot loop compiled to native code, with no garbage collector. Same inputs, same bytes on any server. ARM64 = x86-64 parity
Figure 2. Overview of the three public principles behind Twinz's throughput, without exposing the internal data layout or the detailed algorithms.

The first choice is to store the population's state in fixed-size columns of numbers. In the first version, each inhabitant was a JavaScript object holding hundreds of fields and text strings. At every step, the processor jumped from one memory address to another, and the garbage collector ended up freezing the machine. By storing each quantity in a contiguous numeric array and strictly confining text outside the hot loop, the processor reads memory as a continuous stream and allocates nothing while the simulation advances.

The second choice is about movement. In a naive simulator, the server updates the position of millions of walkers ten times a second, even when nobody is watching them. In Twinz, the engine never stores a permanently updated list of positions. When an inhabitant decides to leave, the engine computes the full trip once, including the wait at traffic lights, whose cycle is fixed, and only replans that inhabitant when they arrive at the door of the place they are heading for. When a visitor opens a street in their browser, the page receives these timed plans, evaluates the exact position at the current instant on the shared clock and handles avoidance between pedestrians locally. The clock doesn't drift and the simulation stays identical, whether zero, one or two visitors are online.

The third choice is porting the whole hot loop to native Rust, under a strict discipline of determinism. The engine never calls the system clock and uses no native mathematical function whose rounding varies from one processor to another. Every source of randomness depends on an explicit seed. This rigour makes it possible to split the computation across several cores while checking that 1, 2, 4 and 8 partitions return exactly the same bytes, and to ensure full parity between an Apple Silicon computer (ARM64) and an x86-64 Linux server. It also allows another rule I care about: the living world is never reset when the code changes, because every format change goes through a conversion that is checked on restart.

What plateaued on the bench

Not everything improved in a straight line. When we went from 6 to 8 cores allocated on the service connected to the web front end (a short window of 360 s simulated under a ×600 setpoint), the measured speed did not increase: it even went from ×246.58 (5.59 effective cores) to ×236.22 (5.94 effective cores), that is -4.2% (calculated).

The measurement revealed a concrete limit: on this workload, useful parallelism plateaus between 5.5 and 6.3 cores because of synchronisation between partitions and exchanges with the streaming server. Opening two extra cores at reduced priority therefore didn't speed up the peak, but it did stop the engine from starving the machine's other services. Keeping this finding in mind avoids chasing useless cores before those synchronisation points have been reduced.

What remains to be proven on this engine