Connections on the varnishbox

Poul-Henning Kamp phk at
Fri Oct 26 15:58:24 CEST 2007

In message <ujrabq66r5l.fsf at>, =?iso-8859-1?Q?Dag-Erling_Sm=F8rg
rav?= writes:
>"Poul-Henning Kamp" <phk at> writes:
>> In retrospect, I am not convinced that idea/implementation of
>> multiple thread pools is sufficiently sound.  Its one area that
>> we will have to impove somehow.
>> Under no circumstances should more than a few pools (< 5) be created.
>I wonder...
>Why do we have a complex setup with pools, workers within pools etc.?

The idea was to reduce lock contention on the pool mutex.

>If we just used the socket descriptor as a direct index into an array
>of workers, no locking would be necessary since the descriptor itself
>would act as a semaphore.

The majority of time the descriptor is idle, and your proposal essentially
parks one thread per descriptor, so if we did that, a lot of code could
be simplified, but at a massive expansion in the number of threads and
a drastic reduction in CPU cache efficiency.

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the varnish-misc mailing list