Skip to main content

Architecture

See CONTRIBUTING.md for how to build and test.

Processes​

An app is one process per node, plus the launcher: the process that called run. The coordinator runs inside the launcher. Each has an id: the coordinator is 0, and the nodes are numbered from 1 in the order in which the program gives them to the app.

A node talks to the coordinator to start up, to report that it is alive, and to shut down. Port values do not pass through the coordinator: nodes send them straight to each other over TCP.

note

Each node listens on 127.0.0.1, so the nodes of an app currently run on one machine.

Crates​

The repository is one Cargo workspace with three crates. raio-rs, in core, is the runtime and the Rust API. raio-macros, in core/macros, holds the Ports derive macro and the #[node] attribute, which Rust requires to be in a crate of their own. raio-py, in python, is the Python binding.

Modules of the Core​

The core is divided into these modules:

ModuleWhat it does
appWhat a node program is written with: App, ports, actions, reactions, connections.
nodeThe scheduler that orders the events of one node by timestamp.
coordinatorThe graph of an app; wires its nodes at startup and shuts them down.
transportCarries bytes between processes.
serializerConverts port values to and from bytes: bincode and MessagePack.
messagesEverything that crosses a process boundary.
runtimeThe single-threaded executor under each node.
driverThe executor's I/O and timers.
diagramDraws an app.

One Thread per Node​

A node runs all of its tasks on a single-threaded executor of its own, so the tasks of a node never run in parallel and need no locks.

The executor and the scheduler work together. Each waker says whether its task resumes at the node's current timestamp or at a new physical timestamp, and the scheduler applies that when it decides which timestamp the node handles next.