Skip to main content
dtact is a non-preemptive, stackful coroutine (fiber) runtime built for hardware-level control, heterogeneous orchestration, and zero-copy C/C++ interoperability.
This page is an architectural overview. For full Rust API documentation, live crate versions, and C header details, visit docs.rs/dtact and apich.org/projects/dtact.

Full API Reference

Generated rustdoc for dtact, dtact-macros, and dtact-util on docs.rs.

Project Homepage

Release metadata, benchmarks, and Open Collective budget on apich.org.

GitHub Repository

Source code, C/C++ headers (dtact.h, dtact.hpp), and Criterion benchmarks.

Zenodo DOI

Persistent academic citation (10.5281/zenodo.20002105) and Software Heritage archive.

Architecture & Core Design

Instead of compiling async functions into stackless state machines, dtact assigns each task its own stack from a pre-allocated, lock-free ContextPool arena and switches execution with hand-written assembly switchers for x86_64, AArch64, and RISC-V.

Key Architectural Trade-offs

  • Stackful vs. stackless: A yield in dtact performs a full CPU register context switch, which is heavier than polling a stackless state machine. In return, suspended fibers preserve their C stack, allowing C and C++ code (dtact.h / dtact.hpp) to launch, yield, and await fibers natively.
  • P2P mesh deflection: Instead of contending on a single global work-stealing queue, workers pull only from their own bounded lock-free mailbox and deflect overflow to neighbouring cores within the configured cache or NUMA domain.
  • Best-fit workloads: Ideal for Bag-of-Tasks (BoT) workloads at moderate-to-high load, parallel batch computation, and mixed Rust/C++ orchestration.

Repository Structure

Spawn-Time Knobs & dtact-util Backends

Every fiber spawned via #[task(...)], ClosureSpawnOptions, or dtact_spawn_options_t applies seven runtime knobs: dtact-util decouples I/O from the scheduler behind three Cargo feature modes: native (default, io_uring / IOCP / kqueue), tokio (wrapper for workloads dominated by short-lived connection churn), and sync (backend-agnostic utility primitives), plus a blocking C ABI (dtact_util.h).

Benchmarks

dtact spawn and join benchmark comparison against Tokio

Criterion spawn + join median per-task cost (nanoseconds) and Tokio-to-dtact ratio on 4-core x86_64.

dtact hot-core deflection benchmark chart

Hot-core work-deflection behaviour across task batch sizes.

Quick Example

Last modified on November 29, 2026