On Fri, May 20, 2011 at 1:09 PM, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 05/20/2011 12:59 PM, Stefan Hajnoczi wrote: >> >> This coroutines implementation is based on the gtk-vnc implementation >> written by Anthony Liguori<anth...@codemonkey.ws> but it has been >> significantly rewritten by Kevin Wolf<kw...@redhat.com> to use >> setjmp()/longjmp() instead of the more expensive swapcontext() and by >> Paolo Bonzini<pbonz...@redhat.com> for Windows Fibers support. >> > > Not a blocker at all, but why did you move the pooling to the ucontext > implementation? It's less expensive to create the fiber in Windows because > there are no system calls (unlike swapcontext), but a future pthread-based > implementation will also need the pooling. > > It can be left to whoever writes the pthread stuff, though.
There are two options for pooling: 1. Thread-local pools 2. One global pool with a lock One of these choices must be selected because otherwise the pool could be accessed simultaneously from multiple threads. I tried #2 first because it was less code but it caused a noticable slow-down with ./check-coroutine --benchmark-lifecycle. Option #1 had less impact but requires using thread-local storage, which I've used pthread APIs for. Hence I moved it into coroutine-ucontext.c hoping that win32 would either be fast enough as-as or that we could find a better solution if someone needs it. Stefan