kqueue based thread pool

Igor Sysoev is at rambler-co.ru
Fri Oct 26 00:09:07 PDT 2007

The modern threads implementation works fine with program that requires
fair threads scheduling, like Apache and MySQL.

However, there are programs (like varnish) that use FSM and thread pool.
The threads allow to run on SMP and reduce blocking on disk I/O.
These programs use an acceptor/listener thread and worker pool threads.
In this model it's preferable to have one RUNnable worker thread per CPU and
to start next one only when the current thread blocks. Also, when scheduler
chooses next thread to run it should get the more recently run (cache hot)
thread instead of fair scheduling. It's good to have some idle threads
in pool, those run very seldom when active threads are blocked on I/O, etc.

Just wonder whether current scheduler is easy extendable to create thread
pool controlled by kqueue: that is the kernel acts as acceptor/listener
thread that wakes up worker threads waiting in kevent() ?

Igor Sysoev

More information about the freebsd-threads mailing list