Feature request: ability to use libeio with multiple event loops

Hongli Lai hongli at phusion.nl
Tue Dec 20 15:26:22 CET 2011

On Tue, Dec 20, 2011 at 3:04 PM, Paddy Byers <paddy.byers at gmail.com> wrote:
> This has been asked for before and rejected.
> This is what I'm doing, which works well:
> http://lists.schmorp.de/pipermail/libev/2011q4/001584.html

(Replying to libev mailing list so that Marc can see my reasons)

I see. My case is a little different though: you're thinking about
multiple event loops in a single thread while I'm thinking about one
event loop per thread. I'm thinking about multiple eio contexts with
each context having its own thread pool. This would be similar to how
EV_MULTIPLICTY works in libev.

The reasons why I have multiple threads are:
1. I want to make full use of all CPU cores.
2. All threads are mostly independent, but share one data structure.
It's faster to query and to manipulate this data structure with locks
and shared memory than to use message passing and multiple processes.
3. I want to minimize context switching overhead. Context switching
between processes involves flushing the TLB while context switching
between threads does not (at least on Linux). Manipulating a shared
data structure through message passing *always* involves a context
switch, even in the uncontended case, while mutexes do not impose such
overhead in the uncontended case.

- Hongli
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: info at phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

More information about the libev mailing list