A host owns one system per image
The host header says a host owns segments, one ta_system per image.
Segment k creates sessions k·2³²+1 to k·2³²+2³²−1, so a session id names one actor in the host.
tinyactors is an embeddable C library that runs SCXML statechart actors inside your process from Node.js, Bun, Python, WebAssembly, and C. After reading, you can judge whether to depend on tinyactors and inspect its memory layout and compiled C core yourself.
An application handling order workflows needs explicit state machines without running a separate actor cluster or letting workflow logic open network sockets directly. A library that parsed XML or opened its own sockets behind the application's back would take that I/O out of the team's hands.
Each actor runs one SCXML statechart, which defines discrete states, transitions between those states, and a datamodel of variables. Instead of parsing XML at runtime, a compiler turns those charts into a binary image of .tai bytes. Your application embeds a host, which is the runtime instance that lives in your process and runs those compiled charts.
The engine inside that host never opens sockets, writes files, or sleeps on its own. Whenever an actor sends a message, writes a log, or invokes an external service, the host emits that request as an effect. Your application receives those effects, executes the I/O in Node.js, Bun, Python, WebAssembly, or C, and feeds events back. Because teams update statecharts over time, the next question is how one host loads compiled images and handles deploys.
A deploy during business hours must update an order statechart while existing orders are still waiting for payment. Stopping the process drops active workflows, and overwriting running definitions risks corrupting orders mid-transition.
Adding a compiled image to a host creates a segment, which is one running instance of that image inside the host. Inside each segment sits a system, the C engine that manages that segment's actors, mailboxes, and timers inside one memory block. Each segment assigns its actors unique session ids starting at k·2³²+1, where k is the segment index.
Adding an image that contains a chart of the same name performs a deploy. New actors start in the newest segment, while running actors stay on their existing segment until they end or migrate. To migrate an actor, the host moves it to the newer segment at a stable point while keeping its session id. The host also carries a system id, which identifies the whole host in addresses seen from other processes. Notice that the word system now names two distinct scopes, which the next section separates.
| Word | What it is | In C |
|---|---|---|
| Image | Compiled charts, a .tai file | ta_compile_charts |
| Segment | One image running inside a host; segment k numbers its sessions from k·2³²+1 | ta_host_add_image |
| System | A segment's engine: its actors, mailboxes and timers in one region | ta_system |
| Host | Every segment as one actor system, with one clock and routing | ta_host |
| System id | The host's name in addresses, seen from other systems | systemID |
An order actor in one process sends a payment request to a billing actor, while another actor talks to an external service in another process. Routing both messages through the same path either wastes network transport on local actors or traps external sends inside the host.
In the C library, a system is a ta_system struct, meaning one segment's engine inside a host. In actor addresses, a system is an entire host, named in addresses by its system id.
This distinction decides where messages go when one actor sends an event to another. When the destination address has the same system id, the host routes the event directly between its own segments. When the address names another system id, the send leaves the host as an effect for your application's transport. To keep that boundary strict across languages, tinyactors divides its C implementation into explicit layers.
The host header says a host owns segments, one ta_system per image.
Segment k creates sessions k·2³²+1 to k·2³²+2³²−1, so a session id names one actor in the host.
A send to an address whose system id is not this host's leaves as an effect for your transport.
Sends between segments of one host stay inside the host.
A team needs the same statechart engine inside Node.js, Python, and WebAssembly without rewriting core rules per runtime. Tying the engine to libc, file handles or one host language would block embedding it in the others.
The modules base, image, trace, core, and system form the freestanding core, which never calls the C standard library. Core never allocates memory after its initial creation and never performs I/O. Instead, core reports side effects upward and calls back only into a datamodel evaluator and an allocator.
Above core sits the host layer, which coordinates multiple segments and allocates memory only through the allocator it is given. Above the host sit the SCXML compiler, datamodel engines such as quickjs for ECMAScript or a binding's own language, and bindings. Those bindings expose the host to Node.js, Bun, Python, WebAssembly, or C, while your application controls storage and policy. With core isolated from I/O, the next question is how your application drives the host during execution.
| Layer | What it does | Where |
|---|---|---|
| Core | Runs statecharts over a compiled image, in one region sized at creation | src/base, image, trace, core, system |
| Host | Runs many systems as one, allocating only through the allocator it is given | src/host |
| Compiler | Turns SCXML documents into an image | src/compile |
| Datamodels | Evaluate expressions: ECMAScript on quickjs, or a binding's own language | src/datamodel_ecmascript |
| Binding | Turns values into its language's objects and runs the loop | tinyactors-napi, tinyactors-cpython |
| Application | Stores blobs and snapshots, and decides policy | your code |
Core hands effects to the host and calls back only into the datamodel and the allocator.
An order actor emits a payment charge and schedules a timeout before waiting for the payment gateway response in Node.js or Python. If the actor engine advances again before the host reads or handles those outputs, state diverges from real I/O.
Your binding or application drives the host in a loop: take a batch of effects, handle them, acknowledge, and run. A batch holds the outgoing sends, logs, and service invocations produced by the previous run.
Everything the host hands out with a batch, every field and every output, remains valid until your code acknowledges that batch. A run refuses while a batch is still open, so every effect of a batch is handled before any actor moves again. Once the application acknowledges the batch, the next run processes queued events and updates actors inside memory. The next section explains where that actor state lives inside memory.
The loop is take, handle, acknowledge and run, and a run refuses while a batch is open.
Each binding runs this loop in C on its own event loop.
A host running thousands of active actors and timers cannot afford per-actor heap allocations or raw pointers that break across process restarts. Unbounded allocations stall the event loop and prevent saving or moving actor memory as bytes.
Each segment stores all of its runtime state inside one contiguous block of memory called a region. At creation, the system partitions that region once into fixed pools for actors, events, timers, and requests. The same partitioning also sets aside slab pages for chart state and strings, an outbox, and a trace journal.
Records inside a region reference one another with relative offsets instead of raw memory pointers. Because offsets stay valid regardless of base address, the bytes of a region can be relocated or written straight to disk. When a pool fills up, the host grows the segment by allocating a larger block and copying the region into it. Knowing how a region is partitioned leads directly to the memory cost of each actor, message, and timer.
The system carves its header, actor slots, event slots, timers, slab pages, the outbox and the trace journal from one block.
When a pool runs out, the host copies the segment into a bigger block with more of that pool.
The capacity doubles until the block is a quarter larger, up to sixteen times the pool.
A team sizing a host for thousands of idle sessions needs exact per-actor memory costs before committing to production capacity. Guessing object overhead from runtime wrappers leaves teams blind to how quickly queued messages and timers fill RAM.
In the region pools, one actor uses 81 bytes, which includes the 48-byte ta_actor record, indices, links, and a generation byte. One queued message uses 106 bytes with tracing enabled, or 57 bytes when tracing is off. One delayed send uses 151 bytes with tracing enabled, or 102 bytes untraced, because it stores timer state alongside its message.
An actor's chart state and datamodel variables sit in slab pages or the datamodel engine on top of that 81-byte record. These byte counts come directly from C struct definitions and are verified by mise run layout against ta_system_layout. Because all active state lives in memory pools, you also need to know what a crash loses and how state persists.
| One more | Bytes, tracing on | Bytes, tracing off | Parts |
|---|---|---|---|
| Actor | 81 | 81 | record 48, links 16, session index 8, name index 8, generation 1 |
| Message | 106 | 57 | event 56, trace context 48, generations 2 |
| Delayed send | 151 | 102 | timer 24, heap entry 20, generation 1, its message |
mise run layout in tinyactors-core on 2026-11-25, at commit 2dc827ac, checked against ta_system_layout.The layout task reads the region's structs from the debug information and checks each cost against ta_system_layout.
The whole actor, with its chart's state and variables, is measured in the capacity guide.
Source:tinyactors, tinyactors-core/mise/tasks/layoutCapacity and memory
A process crashes during peak traffic while actors hold in-progress orders in memory and thousands of idle sessions sit waiting for events. Without a way to persist individual actors or dump a whole host safely, a restart loses live state or risks restoring incompatible memory bytes.
A crash loses everything held only in memory, so only data written to your application's store survives. To persist idle actors individually, hibernation serializes an actor's state into a blob stored by your application. That actor's 81-byte record remains in the region so events and timers still locate it, and the next event wakes it.
To capture the entire host at once, a snapshot writes every segment's region, the compiled images, system id, and host time. A snapshot also stores datamodel state and a description of its memory layout with a hashed layout id. When restoring, the host checks that layout id and refuses a snapshot from a different layout instead of misreading bytes. Because the layout description travels with the bytes, the Inspector page and CLI can read snapshots without running the engine. For inspecting the C core itself rather than a saved snapshot, the page closes with Atlas.
Snapshots are region bytes plus the datamodel's own state, and restore only on a build with the same layout.
Hibernation blobs stay with your store and are not part of a snapshot.
Each snapshot describes every type, member, offset and size in its regions, with a layout id hashed from that description.
A restore compares that id with its own build's and refuses a different layout instead of misreading the bytes.
tinyactors actors lists every actor in a snapshot with its state, mailbox and pending delayed sends, running nothing.
Source:tinyactors, tinyactors-core/docs/cli.md, "Snapshots and blobs"
Hand-drawn architecture diagrams of a C library cannot be trusted when compiler padding and inlining alter the real binary. Without inspecting the optimized build itself, struct sizes and hidden call paths remain guesswork.
Compiler optimizations change the binary by inserting struct padding and inlining functions across translation units. To reflect the actual compiled code, the mise run atlas task extracts DWARF debug information from an optimized build of core.
Atlas renders every core struct across 64-byte cache lines, starting with the 48-byte ta_actor record, with padding bytes shown. Selecting any function displays its callers, its callees, and the calls inlined by the compiler, grouped by C layer. Each dataset names the commit its data came from, letting you inspect core directly below.
Atlas draws each struct of tinyactors' C core to scale on 64-byte cache lines, padding included, starting with the 48-byte actor record. Each function lists its callers, its callees and the calls the compiler inlined, grouped by layer.
The mise run atlas task reads each function, call site and struct from the DWARF of core's optimized build.
Atlas names the commit its data was built from.