micoro
micoro copied to clipboard
a light weight, high performance coroutine implementation
-
Introduction
micoro (for MIcro COROutine & MIke's COROtine) is a light weight, high performance coroutine implementation. The basic idea of micoro come from the paper "Revisiting Coroutines" (http://www.inf.puc-rio.br/~roberto/docs/MCC15-04.pdf). As the paper proved, the "full asymmetric coroutine" model is powerful, easier to use and expressive power equivalent to other similar models. So micoro is actually a "full asymmetric coroutine" implemenation with simple API and clear semantics. The original motivation of micoro is to implement a light-weight cooperative multitasking infrastructure for server environment, so simple, performance and robust (rather than portability) is often the top considerations across disign and implementation.
some features:
- x86 user space fast context switch
- x86 user level light-weight lock
- thread-safe operations
- stack overflow detection
- robust code with careful design and test
- portable for non-x86 using ucontext
- running activity statistics
-
Requirement
Currently only POSIX systems are supported. Some tested platform: Linux-2.6.16 x86_32 Linux-2.6.32 x86_64 Linux-3.2 x86_64 GCC-4.7.1 MacOS-10.7.4 x86_64 LLVM-GCC-4.2.1 FreeBSD-9.0 x86_64 GCC-4.2.1 Cygwin_NT-6.1 i686 GCC-4.5.3
-
Install
3.1 install from tarball
tar -xvf micoro-1.0.tar.gz cd micoro-1.0 ./configure make sudo make install
3.2 install from git source
- require GNU autotools & libtool installed
git clone git://github.com/mikewei/micoro.git cd micoro autoreconf -i ./configure make sudo make install
-
Performance
micoro has much higher performance compared with others (e.g. GNU Pth, PCL, pthread ...)
- my benchmark with a Linux-3.2 CoreDuo 2.1G PC context switch performance for 10000 concurrent routines:
GNU Pth - 5,876 switches per second pthread - 237,318 switches per second PCL - 879,165 switches per second micoro - 4,577,256 switches per second
-
Bug report
please email to [email protected]