Feature request: ability to use libeio with multiple event loops

Marc Lehmann schmorp at schmorp.de
Sat Dec 31 12:42:37 CET 2011

On Thu, Dec 22, 2011 at 02:53:52PM +0100, Hongli Lai <hongli at phusion.nl> wrote:
> I know that, but as you can read from my very first email I was planning on
> running I threads, with I=number of cores, where each thread has 1 event
> loop. My question now has got nothing to do with the threads vs events
> debate. Marc is claiming that running I *processes* instead of I threads is
> faster thanks to MMU stuff and I'm asking for clarification.

I thought I explained this earlier, and I a not sure I can make it any

Just try, mentally, to imagine what happens on your cache when you access
a mutex, or mmap/munmap some memory (e.g. as a result of free), in the
presense of concurrently executing threads.

Now imagine you have far-away cpus, where it is beneficial to have per-cpu
memory pools, e.g. in systems with higher number of cores or good old
multi-cpu systems.

Your cache lines bounce around, and memory is slow, or there will be ipmi's.

Maybe the dthreads paper mentioned earlier explains this better, as they
also have real-world data where unsharing memory and joining it later can
have substantial performance benefits.

Maybe it is just too obvious to me: memory isn't shared between cores in the
hardware level, where memory means cache and the main memory is some distant
slow storage device with complex and slow coherency protocols to give you the
illusion of shared memory.

It's a bit like using (physical) disk files to exchange data instead of
using memory. It is going to be slower, and vastly more complex to keep

I think the problem is vice versa - whoever claims that threads are as
fast as processes on *different* cores or cpus has to explain how this
can be possible - for every design using threads I think I cna give a
faster design using process, because processes can also share memory (but
I wished it was easier).

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list