Small actors, flat costs.

What an actor costs in memory, how to size a host, and how each operation's cost holds as the population doubles. Every number comes from a program in the repository that you can run.

See the costsSee the scaling

What an actor costs.

One more actor, message or delayed send, measured as resident memory in a process with a million of them.

runtime, datamodelactor, startedactor, after an eventactor, hibernatedmessage waitingdelayed send pending
node, native531 B671 B124 B315 B357 B
bun, native618 B800 B101 B386 B456 B
node, quickjs1041 B1639 B97 B312 B364 B
bun, quickjs1049 B1653 B99 B318 B364 B
Measured 2026-11-20 on an Intel Xeon at 2.10 GHz, 4 CPUs, 16 GiB, Linux; Node.js 22.23.5 and Bun 1.4.1. A counter chart with one variable, messages of {"text": "hello"}, tracing on.

A host's fixed costs spread over its actors, so an actor costs less in a larger population.

10,000100,0001,000,0002,000,0004,000,000
per actor, started1327 B774 B531 B519 B501 B
per actor, after an event1956 B920 B671 B665 B644 B
per actor, hibernated1147 B326 B124 B103 B92 B
per message waiting1146 B444 B315 B296 B286 B
per delayed send pending1296 B544 B357 B341 B332 B
Node.js on the native datamodel.

Size a host.

A host grows on its own, but each growth copies its memory. A host that will hold a known population is better sized for it.

size.mjsjavascript
import { Host } from '@tinyactors/node';

const N = 2_000_000; // actors
const R = 1000;      // resident at most
const room = 64;
const host = new Host([], { system: 'big', config: { system: {
  maxActors: N + room, maxEvents: 4096,
  instanceBytes: 2048 * (R + room), stringBytes: 16384 + 64 * (R + room),
} } });
console.log((await host.hostConfig()).system.maxActors);
host.close();
output
2000064

Read what a host uses at any time:

stats.mjsjavascript
import { compileCharts, Host } from '@tinyactors/node';

const compiled = compileCharts([{ name: 'idle.scxml', text: `
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
       datamodel="ecmascript" name="idle"><state id="waiting"/></scxml>` }]);
const image = compiled.image;
compiled.close();

for (const system of [{}, { maxActors: 1000 }]) {
  const host = new Host(image, { system: 'demo', config: { system } });
  const before = (await host.hostStats()).pools[0].actors;
  for (let i = 0; i < 1000; i++) host.spawn('idle');
  const after = (await host.hostStats()).pools[0].actors;
  console.log(`maxActors ${system.maxActors ?? 'default'}: capacity ${before.capacity}, ` +
    `then ${after.used} used, high water ${after.highWater}, grown: ${after.capacity > before.capacity}`);

  host.addImage(image);
  console.log('segments reported:', (await host.hostStats()).pools.map((pool) => pool.segment).join(', '));
  host.close();
}
output
maxActors default: capacity 64, then 1000 used, high water 1000, grown: true
segments reported: 0, 1
maxActors 1000: capacity 1000, then 1000 used, high water 1000, grown: false
segments reported: 0, 1

Costs stay flat.

Every operation of the API, timed on a host of two million actors and on one of four million. Each cell is the cost at two million, then at four, and their ratio. A test fails when a ratio passes 1.5.

operationunitnode, nativenode, quickjsbun, nativebun, quickjs
populate (spawn and hibernate)µs per actor11.71 → 11.62 (0.99)7.16 → 7.36 (1.03)8.64 → 8.51 (0.99)6.74 → 6.58 (0.98)
spawnµs per call5.47 → 5.43 (0.99)2.45 → 2.54 (1.04)4.82 → 5.59 (1.16)2.92 → 2.70 (0.92)
terminateµs per call0.755 → 0.733 (0.97)0.565 → 0.560 (0.99)0.925 → 0.889 (0.96)0.758 → 0.742 (0.98)
sendµs per call4.44 → 4.41 (0.99)2.06 → 2.15 (1.04)3.71 → 3.61 (0.97)2.28 → 2.33 (1.02)
sendManyµs per event4.84 → 4.79 (0.99)2.38 → 2.29 (0.96)3.50 → 3.40 (0.97)2.38 → 2.13 (0.89)
send (hibernated: woken from the store)µs per call34.97 → 30.14 (0.86)33.20 → 40.71 (1.23)27.13 → 29.38 (1.08)34.26 → 35.97 (1.05)
hibernateµs per call5.94 → 5.78 (0.97)4.50 → 4.55 (1.01)4.22 → 4.20 (0.99)4.37 → 4.32 (0.99)
wakeµs per call7.07 → 7.34 (1.04)3.84 → 4.02 (1.05)7.93 → 7.57 (0.95)4.85 → 4.75 (0.98)
actor (by name; measured as actorByName, its direct call)µs per call0.532 → 0.507 (0.95)0.415 → 0.426 (1.03)0.426 → 0.415 (0.98)0.304 → 0.300 (0.99)
actorStateµs per call4.63 → 4.38 (0.95)4.34 → 4.80 (1.11)4.13 → 4.37 (1.06)3.95 → 4.20 (1.06)
hostStatsµs per call19.28 → 19.47 (1.01)19.32 → 19.76 (1.02)19.45 → 16.84 (0.87)14.51 → 14.14 (0.97)
I/O processor round tripµs per call13.30 → 12.54 (0.94)8.47 → 8.33 (0.98)9.89 → 9.46 (0.96)7.88 → 6.48 (0.82)
transport round tripµs per call34.01 → 34.13 (1.00)25.85 → 28.06 (1.09)27.99 → 31.32 (1.12)22.87 → 22.52 (0.98)
delayed send and its timerµs per call7.19 → 7.48 (1.04)3.39 → 3.44 (1.02)5.93 → 5.97 (1.01)3.87 → 3.79 (0.98)
invoked service round tripµs per call14.28 → 15.49 (1.08)10.86 → 11.78 (1.08)11.54 → 13.32 (1.15)9.84 → 10.34 (1.05)
sweep (every actor)µs per actor0.008 → 0.007 (0.97)0.007 → 0.007 (0.98)0.008 → 0.007 (0.94)0.007 → 0.008 (1.03)
migrate (one session)µs per call32.02 → 28.74 (0.90)20.00 → 16.20 (0.81)24.48 → 24.95 (1.02)17.45 → 20.93 (1.20)
snapshotµs per actor0.110 → 0.105 (0.96)0.075 → 0.077 (1.04)0.090 → 0.080 (0.89)0.084 → 0.082 (0.97)
restore (and its first turn)µs per actor0.313 → 0.297 (0.95)0.200 → 0.200 (1.00)0.236 → 0.234 (0.99)0.193 → 0.199 (1.03)
closeµs per actor0.081 → 0.102 (1.26)0.078 → 0.087 (1.11)0.079 → 0.106 (1.35)0.087 → 0.104 (1.19)
Most actors hibernated in SQLite, at most 1000 resident. Measured 2026-10-17 on an Intel Xeon at 2.10 GHz, 4 CPUs, 16 GiB, Linux; Node.js 22.23.3 and Bun 1.4.1. Microseconds.

Correct by the standard.

The core passes all 191 automatic tests of the W3C's SCXML test suite. Every binding runs the same conformance suite, on each of its datamodels.