Overview
dtact is a non-preemptive, stackful coroutine runtime. Instead of compiling async code into state machines, it gives every task its own stack and switches between them with hand-written assembly. That one decision makes the rest possible: a suspended task keeps its C stack, so foreign code can suspend and resume it.
Scheduling is a peer-to-peer mesh rather than a global work-stealing queue. Workers exchange work through bounded lock-free mailboxes, so a saturated core deflects its backlog into a neighbouring cache domain instead of contending on one shared structure.
Contexts are carved out of a pre-allocated arena, which turns spawning into an index allocation, and futures small enough to fit are placed on the fiber's own stack. The project is explicit about the trade-off: a yield is a full register switch, heavier than a stackless runtime, and worth it when the work between yields is substantial or when C has to participate.
Capabilities
what it doesLock-free context arena
Fiber contexts come from a pre-allocated arena, so spawning is an index allocation rather than a heap allocation — even at high spawn rates.
P2P mesh scheduling
Workers exchange work through bounded, lock-free mailboxes instead of one global work-stealing queue, which keeps contention local to a cache domain.
Topology-aware affinity
SameCore, SameCCX, SameNUMA or Any: deflection is confined to the neighbourhood you choose, per runtime or per fiber.
Assembly context switchers
Hand-written switchers per architecture, with floating-point and cross-thread variants, so the cost of a switch matches the workload.
Zero-copy futures
Small and medium futures are placed directly on the fiber's own stack, removing a heap allocation from the spawn path.
C and C++ FFI
Fibers have their own stacks, so C code can launch and await them. dtact-util exposes io, fs, process, signal, stream and timer through the same ABI.
How it works
design notesThe spawn path
A spawn takes a slot from the context arena, writes the future into the slot's zero-copy buffer and publishes the handle. There is no allocator call and no queue insertion on the critical path.
Deflection instead of stealing
A full mailbox hands work to a neighbour rather than waiting: each worker pushes to peers and pulls only from its own mailbox, so contention stays inside a cache domain.
Affinity that is enforced
SameCore pins, SameCCX and SameNUMA confine deflection, Any lets work travel. P2PMesh, Global and Pinned set the runtime default; topology_mode overrides it per fiber.
Priorities with consequences
Low and High bias the deflection threshold. Critical is never deflected, enters at the front of its worker's queue, and parks rather than migrating when the queue is full.
Per-architecture switchers
Assembly context switches for x86_64, AArch64 and RISC-V, with variants that skip floating-point state or switch across threads — you pay for the state you need.
Stack safety levels
Safety0 performs no overflow check, Safety1 checks a canary at termination, Safety2 checks at every suspension. Trips are counted, and named fibers appear in diagnostics.
Measured performance
project benchmarks| Workload | dtact | Note |
|---|---|---|
| Spawn + join, N = 1,000 | ≈195 ns per task | ≈5.3× cheaper than Tokio |
| Spawn + join, N = 100,000 | ≈450 ns per task | advantage narrows with batch size |
| Hot-core deflection | ahead at both extremes | dips near N ≈ 4,000–16,000 |
| Yield cost | full register switch | stackful by design — amortise the work |

Install
cargo# the runtime
cargo add dtact
# async I/O on the same scheduler
cargo add dtact-utilThe C API ships as dtact.h; dtact-util exposes io, fs, process, signal, stream and timer through the same ABI, with io_uring, IOCP and kqueue backends.