Momo: High-Performance, Atomic-Free Async Runtime
Momo is a general-purpose, high-performance async runtime for Rust, meticulously optimized for thread-local affinity, cache locality, and zero atomic contention.
๐ Why Momo?
In traditional async runtimes like Tokio or smol, tasks are designed to be moved between threads (Work-Stealing). While powerful, this comes at a cost: atomic synchronization overhead and L1/L2 cache bouncing.
Momo takes a different approach: Shared-Nothing Architecture.
- Task Pinning: Tasks stay on the thread that created them.
- Atomic-Free Internal: Most internal scheduling logic uses
RcandRefCellinstead ofArcandMutex, eliminating lock contention. - Predictable Performance: $O(1)$ timer management and generational I/O tokens ensure stable performance regardless of scale.
๐ฆ Getting Started
Installation
Add momo-rs to your Cargo.toml:
[]
= "0.1"
Basic Example
The simplest way to use Momo is via the #[momo::main] macro:
async
๐ ๏ธ API Overview
Task Management
| Function | Description |
|---|---|
momo::spawn |
Spawns a future onto the current thread's executor. |
momo::yield_now |
Voluntarily yields execution back to the scheduler. |
momo::stop |
Signals the local runtime to shut down. |
Networking (TCP)
Momo provides a high-performance networking stack based on mio.
use TcpListener;
async
Timer Services
Momo uses a 4-level Hierarchical Timer Wheel for $O(1)$ efficiency.
use Duration;
async
๐๏ธ Architecture
๐ก๏ธ Generational I/O Tokens
To prevent the "ABA problem" (where a file descriptor is reused by the OS), Momo assigns a 64-bit ID to every socket. This ID combines a 32-bit index with a 32-bit generation counter. Stale events from old connections are automatically ignored.
๐ก O(1) Hierarchical Timer Wheel
Unlike runtimes that use binary heaps ($O(\log N)$), Momo uses a wheel structure. This ensures that inserting or expiring a timer takes the same amount of time whether you have 10 or 10,000,000 active timers.
๐ Shared-Nothing Scheduler
Every thread in a Momo application runs its own independent executor. There is no global lock and no task migration, making Momo ideal for "Thread-per-Core" designs.
๐ Performance Comparison
Measured on single-threaded configurations (2026-04-21).
| Metric | Momo | Tokio (LocalSet) | Speedup |
|---|---|---|---|
| Spawn Latency | 169.74 ns | 678.97 ns | 4.0x faster |
| MPSC Throughput | ~7 ns / msg | ~88 ns / msg | 12.5x faster |
| Yield Overhead | 17.70 ยตs | 77.54 ยตs | 4.4x faster |
๐ก๏ธ License
Momo is licensed under the MIT License.
๐ Documentation
Full documentation is available at docs.rs/momo-rs.