accept: Implement fast soaccept predication
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 24 Nov 2011 05:53:54 +0000 (13:53 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 24 Nov 2011 06:32:15 +0000 (14:32 +0800)
commit5e4b399478dd637a5a3939ddd2ebb4c5cffd3138
tree48530fc579d1ee3a262808e96b2f5f5b8a24b5e6
parent6ac773636aba04de4b4229b2de91ade80e4cc4ca
accept: Implement fast soaccept predication

Fast soaccept predication tries to run soaccept_predicate before
domsg to the proto-thread, i.e. put the current thread into sleep.

We could do this because listen socket's completion list is always
protected by the listen socket's pool-token.  Domsg to proto-thread
to extract socket from completion list for non-block listen socket
does not make any sense.  Even for blocking listen socket if there
are sockets on the completion list, domsg to the proto-thread to
extract socket from completion list also wastes time.

The result:

192.168.249.42 (Xeon E3-1230 HT enabled, 16G) runs httperf
192.168.249.29 (i7-2600 HT enabled, 16G) runs nginx (web server)

The server runs nginx-1.0.4 (from pkgsrc-2011Q2), using the default
configure w/ following changes:
events {
    worker_connections  10240;
    use kqueue;
}

The client runs httperf-0.9.0 manually compiled w/ FD_SETSIZE to 16424
The client machine runs following commands before starting benching:
net.inet.ip.portrange.last=60000
route change -net 192.168.249.0/24 -msl 500

16 parallel httperf --server=192.168.249.29 --wsess=5000,1,1 --max-conn=4
4 runs (Request rate, unit: req/s)

old  23554.0  23542.0  23557.0  23526.2
new  24793.7  24809.9  24792.7  24794.4

This gives 5.3% performance improvement
sys/kern/uipc_socket.c
sys/kern/uipc_syscalls.c