pthreadpool: Avoid a malloc/free per job
commit84aa2ddd861549d6ec8d1ef15f4fd518e03f449b
authorVolker Lendecke <vl@samba.org>
Fri, 21 Mar 2014 16:53:26 +0000 (21 17:53 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 27 Mar 2014 05:06:11 +0000 (27 06:06 +0100)
treedc1137ef85e9d3c09416c30d38aafbb79b0a1d84
parent17a60b98db92026ae0b7136a9c8b802bf936423a
pthreadpool: Avoid a malloc/free per job

pthreadpool_add_job is in our hottest code path for r/w intensive workloads, so
we should avoid anything CPU-intensive. pthreadpool used to malloc each job and
free it in the worker thread. This patch adds a FIFO queue for jobs that helper
threads copy from, avoiding constant malloc/free. This cuts user space
CPU in the local-bench-pthreadpool benchmark by roughly 10% on my system.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/pthreadpool/pthreadpool.c