A deterministic, zero-allocation-hot-path async executor for
#![no_std]environments.
hyper-tick is a bare-metal, strictly single-threaded asynchronous task scheduler. It was originally extracted from the core of a proprietary ultra-low-latency networking engine designed for High-Frequency Trading (HFT) and deterministic embedded systems.
Standard async runtimes (like tokio or async-std) prioritize ergonomics and massive concurrency via work-stealing, which introduces unpredictable heap allocations, lock contention, and CPU cache invalidation. hyper-tick discards all of that in favor of absolute predictability.
This executor is built around a Thread-Per-Core architecture. Cross-thread synchronization is completely eliminated to guarantee microsecond-level latency profiles.
- Zero-Allocation Hot Path: Heap allocations (
Box,Vecresizing) are strictly forbidden once the execution loop begins. Memory is requested from the OS exactly once during system initialization. - Lock-Free Scheduling: Relies on internal mutability (
Rc<RefCell<...>>) rather than atomic primitives (Arc,Mutex) to avoid expensive cache-coherency protocols across CPU cores. - Manual VTable Implementation: Implements a custom
RawWakerVTableto safely pack and unpack reference-counted state into raw C-pointers (*const ()), satisfying the Rust async ABI without the overhead of the standard library'sWakerutilities.
During startup, the alloc crate is utilized to construct a fixed-capacity slab of dynamically dispatched, pinned futures (Pin<Box<dyn Future>>). This allows for heterogeneous task execution (e.g., mixing network listeners with timers).
Once .run() is invoked, the executor enters a tightly optimized loop. It pulls tasks from a pre-allocated ring buffer. When a future returns Poll::Pending, its Waker is registered. Our custom Waker implementation safely manipulates raw pointer reference counts, ensuring that waking a task involves nothing more than pushing an integer task_id back into the run queue.
There are exactly 0 calls to malloc or free during the execution loop.
To see the zero-allocation hot path in action, run the mocked market data feed example:
cargo run --example market_tick