[OPTIM] stream_sock: reduce the default number of accepted connections at once
By default on a single process, we accept 100 connections at once. This is too
much on recent CPUs where the cache is constantly thrashing, because we visit
all those connections several times. We should batch the processing slightly
less so that all the accepted session may remain in cache during their initial
processing.
Lowering the batch size from 100 to 32 has changed the connection rate for
concurrencies between 5-10k from 67 kcps to 94 kcps on a Core i5 660 (4M L3),
and forward rates from 30k to 39.5k.
Tests on this hardware show that values between 10 and 30 seem to do the job fine.
diff --git a/src/haproxy.c b/src/haproxy.c
index 712485c..4c20331 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -593,10 +593,15 @@
global.tune.maxpollevents = MAX_POLL_EVENTS;
if (global.tune.maxaccept == 0) {
+ /* Note: we should not try to accept too many connections at once,
+ * because past one point we're significantly reducing the cache
+ * efficiency and the highest session rate significantly drops.
+ * Values between 15 and 35 seem fine on a Core i5 with 4M L3 cache.
+ */
if (global.nbproc > 1)
global.tune.maxaccept = 8; /* leave some conns to other processes */
else
- global.tune.maxaccept = 100; /* accept many incoming conns at once */
+ global.tune.maxaccept = 32; /* accept more incoming conns at once */
}
if (global.tune.recv_enough == 0)