Skip to content

arsenz/zero-hot-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hyper-tick ⏱️

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.

⚡ Design Philosophy

This executor is built around a Thread-Per-Core architecture. Cross-thread synchronization is completely eliminated to guarantee microsecond-level latency profiles.

  1. Zero-Allocation Hot Path: Heap allocations (Box, Vec resizing) are strictly forbidden once the execution loop begins. Memory is requested from the OS exactly once during system initialization.
  2. Lock-Free Scheduling: Relies on internal mutability (Rc<RefCell<...>>) rather than atomic primitives (Arc, Mutex) to avoid expensive cache-coherency protocols across CPU cores.
  3. Manual VTable Implementation: Implements a custom RawWakerVTable to safely pack and unpack reference-counted state into raw C-pointers (*const ()), satisfying the Rust async ABI without the overhead of the standard library's Waker utilities.

🧠 Architecture Overview

1. Initialization Phase

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).

2. The Hot Path (executor.run())

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.

🚀 Quick Start

To see the zero-allocation hot path in action, run the mocked market data feed example:

cargo run --example market_tick

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages