Execute asynchronous tasks with a configurable scheduler.
A Zig port of commonware's
commonware-runtime.
Upstream stability varies by primitive. BETA (wire and storage formats are stable, and
breaking changes come with a migration path): the core traits (spawner, clock, network,
storage), the tokio runtime, iobuf, utils (including buffer and signal), telemetry,
the blob header, and the metered storage, network, and process modules. Everything else is
ALPHA (breaking changes expected), including deterministic, mocks, conformance,
io_uring, and the audited, faulty, and memory storage. See commonware's
stability levels.
Every backlog item in docs/lanes/runtime.md is checked off.
telemetry/ and production/ are tracked in
docs/lanes/runtime-telemetry.md, and buffer/ in
docs/lanes/storage-journal.md. Every backlog item in
both is checked off.
context(context.zig):Context(Network), what a task is given to spawn, sleep, store, connect, and register metrics.deterministic(deterministic.zig): a runtime that runs tasks as fibers on one thread, in an order chosen by a seed.production(production/mod.zig): real time, files on disk, and TCP, onstd.Io.Threaded, with optional io_uring.fiber(fiber.zig): stackful fibers and their context switch.supervision,signal(supervision.zig, signal.zig): the tree of tasks an ending task takes down with it, and one-time shutdown broadcasts.storage(storage.zig): partitions of named blobs, as vtable interfaces.network,mocks(network.zig, mocks.zig): the network interface, and the in-memory sink and stream pair under the deterministic network.resolver(resolver.zig): DNS resolution of a host name.iobuf(iobuf.zig):IoBufMut,IoBuf, and chunk sequences for I/O.buffer(buffer/mod.zig): read and write buffers over a blob.telemetry(telemetry/mod.zig): metrics and traces.conformance(conformance.zig): commits a workload's storage audit as a conformance hash.process.metered(process/metered.zig): resident and virtual memory size of the process, on Linux only.
zig build test-runtime # unit tests and seeded fuzz
zig build bench -Dbench-filter=runtime:: # I/O backend benchmarks (ReleaseFast)Other bench prefixes: buffer_paged:: and iobuf::. zig build test also runs each
benchmark once on its smoke inputs. For long fuzz runs, use
zig build test --fuzz -Doptimize=ReleaseSafe. The production network stress tests run only
with -Dslow-tests.
- Tasks are stackful fibers, not polled futures. The deterministic runner implements
std.Io, sostd.Io.Mutex,Condition,Queue, andSelectare deterministic. See the runtime lane decisions. - Fibers block at different points than polled futures, so auditor digests compare only between zigware runs. Storage audits match commonware. See the runtime lane decisions.
- Abort is a
std.Iocancelation, and a panic aborts the process. AHandlemust be joined, aborted, or detached exactly once. See the runtime lane decisions. - A
Runnercanstartseveral roots in sequence, which replacesCheckpointandrecover. See the runtime lane decisions. - Blobs must be closed, and closing does not sync.
read_manyis not ported.start_syncreturns aCompletion, and backends without their own sync inline. See the runtime lane decisions. - The production runtime runs on
std.Io.Threaded, becausestd.Io.Uringdoes not compile in Zig 0.17.1. io_uring is our own backend and stays off by default. See the runtime-telemetry lane decisions. - Traces have no global subscriber. Components take a
Tracerfrom the context. See the runtime-telemetry lane decisions.