[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Multi-Threaded Libevent Server Example



On 03/25/2012 02:05 PM, Ron Cemer wrote:
I've developed a multi-threaded, libevent-based socket server example which
uses a threaded work queue and a separate event queues (event_base in libevent
terminology) for each client connection.  This should provide better CPU
utilization on hyperthreading, multi-core or multi-CPU architectures.
The single-threaded nature of libevent is problematic on multi-core
> architectures, because all but one core goes unused.

Yes, libevent is threadsafe but you have to do all the thread management yourself, and there is no built-in support for thread pooling or workqueues. This is the main reason why I lost interest in libevent and started working on libdispatch instead [1].

The project also includes a simple, theaded work queue implementation.

I took a quick look, and you are correct; it is a simple implementation :)

You might be interested in trying libpthread_workqueue, which is a more sophisticated workqueue implementation. It is self-regulating based on the system load, so it tries to keep all of the processors/cores/threads busy without overloading the system. I posted an experimental patch [1] to this list awhile back showing how to combine libevent with libpthread_workqueue.

Regards,

 - Mark


[1] http://mark.heily.com/project/libdispatch/
[2] http://archives.seul.org/libevent/users/Jan-2012/msg00013.html
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.