boost::asio concurrency
An interesting question has been asked on stackoverflow: C++ Socket Server - Unable to saturate CPU - essentially saying that a multithreaded server using boost::asio isn't able to saturate 4 CPUs.
Looking at the boost::asio source code soon revealed that while boost::asio allows the event-loop to be run by multiple threads, only one thread will be allowed to call into the kernel's epoll syscall on Linux which vastly reduces concurrency. Note that this is not a limitation of the Linux kernel, but purely a limitation of how it is used by boost::asio (Linux would allow multiple threads calling epoll concurrently, but using it that way can be quite tricky without using excessive locking).
I think the main lesson to learn here is that while an interface might look perfectly fine when it comes to multithreading, there might be unexpected implementation limitations that could still limit concurrency.
For some more information on multithreaded edge-triggered epoll event loops on Linux, also check out my nginetd project.
-- cmeerw.org

