Dtact: An Experimental Stackful Coroutine Runtime for Heterogeneous Orchestration and Hardware-Level Control

Read full text
Authors: Xinyu Yang
Cited by: 11

Abstract

Overview Dtact is a non-preemptive, stackful coroutine (fiber) runtime implemented in Rust. It is designed to explore alternative approaches to asynchronous execution, focusing on hardware-level control and low-contention scheduling in heterogeneous environments. Unlike standard stackless state-machine runtimes, Dtact leverages independent stacks to facilitate seamless cross-language FFI and architecture-specific optimization. Key Architectural Features This project explores several specialized design patterns for high-performance systems: Lock-Free Context Arena: Utilizes a pre-allocated ContextPool to manage fiber execution contexts, aimed at reducing heap allocation overhead during high-frequency task spawning. Decentralized P2P Mesh Scheduling: Implements a peer-to-peer mesh architecture for worker communication via bounded, lock-free mailboxes, providing an alternative to global work-stealing queues to mitigate synchronization contention. Zero-Copy Future Migration: Explores the direct placement of Future payloads onto pre-allocated fiber stacks to minimize memory movement. Assembly-Level Context Switching: Provides a suite of customizable switchers (including floating-point preservation variants) allowing for fine-grained control over the context-switch cost relative to specific workloads. Interoperability: Features a native C-FFI layer, enabling C/C++ applications to integrate with the coroutine runtime. Research and Performance Characteristics The design of Dtact represents a deliberate trade-off. While stackful coroutines incur a higher yield overhead compared to stackless state machines (due to register context switching), they offer superior ergonomics for FFI-heavy workloads and complex execution flows. This repository provides the complete implementation, including Rust macros and C integration examples, to demonstrate the viability of this architectural pattern. Usage and Contributions This codebase is intended for researchers and systems engineers interested in runtime design and concurrency models. We welcome academic discussion, feedback, and contributions via the linked repository. License This project is dual-licensed under the MIT License and Apache License (Version 2.0).

Publication details

Publication date
20 May 2026
Language
EN