hnes/libaco logo

hnes/libaco

Free

A blazing fast and lightweight C asymmetric coroutine library 💎 ⛅🚀⛅🌞

FreeFree tier
Type
Open Source

About hnes/libaco

libaco (Arkenstone) is a production-ready, blazing fast, and lightweight asymmetric coroutine library for C, implementing the Sys V ABI for Intel386 and x86-64. With fewer than 700 lines of code, it achieves context switch times of about 10 ns on AWS c5d.large machines and can run 10,000,000 coroutines simultaneously using only 2.8 GB of physical memory. It supports both standalone and shared stack configurations, and includes detailed documentation with a strict mathematical proof of correctness.

Key Features

Less than 700 LOC with full coroutine functionality
Ultra-fast context switching (~10 ns on modern hardware)
Extremely memory efficient: 10 million coroutines use only 2.8 GB
Supports both standalone and shared stack configurations
Production-ready with mathematical proof of correctness
Detailed documentation and tutorials provided

Pros & Cons

Pros
  • Blazing fast context switch (~10 ns)
  • Very lightweight: under 700 lines of code
  • Memory efficient: supports millions of coroutines
  • Flexible stack options (standalone or shared)
  • Well-documented with mathematical proof of correctness
  • Production ready with stable API
Cons
  • Limited to Sys V ABI on Intel386 and x86-64 architectures
  • Requires C programming environment, not a high-level API
  • No built-in scheduler; user must manage coroutine scheduling
  • Documentation may lag behind master branch (use releases)

Best For

High-performance concurrent systems in CGame engines requiring lightweight multitaskingNetwork servers handling many concurrent connectionsEmbedded systems with limited memoryAny application needing efficient asymmetrical coroutines

FAQ

What is the performance of context switching?
Context switch between coroutines takes about 10 ns on an AWS c5d.large machine (standalone stack).
How many coroutines can run simultaneously?
10,000,000 coroutines can run simultaneously, costing only 2.8 GB of physical memory (with tcmalloc and 120B copy-stack size).
What architectures are supported?
Supports Sys V ABI of Intel386 and x86-64.
Is the project production ready?
Yes, the project is marked as production ready.