summaryrefslogtreecommitdiffstats
path: root/source3/lib/pthreadpool/pthreadpool.c
Commit message (Collapse)AuthorAgeFilesLines
* pthreadpool: Slightly serialize jobsVolker Lendecke2014-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | Using the new msg_source program with 1.500 instances against a single msg_sink I found the msg_source process to spawn two worker threads for synchronously sending the data towards the receiving socket. This should not happen: Per destination node we only create one queue. We strictly only add pthreadpool jobs one after the other, so a single helper thread should be perfectly sufficient. It turned out that under heavy overload the main sending thread was scheduled before the thread that just had finished its send() job. So the helper thread was not able to increment the pool->num_idle variable indicating that we don't have to create a new thread when the new job is added. This patch moves the signalling write under the mutex. This means that indicating readiness via the pipe and the pool->num_idle variable happen both under the same mutex lock and thus are atomic. No superfluous threads anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* pthreadpool: Allow multiple jobs to be receivedVolker Lendecke2014-03-271-9/+10
| | | | | | | This can avoid syscalls when multiple jobs are finished simultaneously Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* pthreadpool: Avoid a malloc/free per jobVolker Lendecke2014-03-271-54/+91
| | | | | | | | | | | 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>
* pthreadpool: Fix pthreadpools with forkVolker Lendecke2014-03-031-15/+6
| | | | | | | | | | | | The current could would crash if a pthreadpool was created, deleted and the process then fork()s. "pthreadpools" is NULL in this case, but the pthread_atfork handlers are in place. This fixes walking the pthreadpools list in reverse. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Simo Sorce <simo@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* pthreadpool: Fix a comment, "quit"->"shutdown"Volker Lendecke2014-01-281-2/+2
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Tue Jan 28 19:06:40 CET 2014 on sn-devel-104
* pthreadpool: Fix CID 710828 Sizeof not portableVolker Lendecke2013-05-121-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org>
* s3: Fix the pthreadpool build on OS/XVolker Lendecke2012-04-091-0/+1
| | | | | OS/X does not have clock_gettime, and without replace.h we do not get the replacement macro
* Change the signature of pthreadpool_finished_job() to return 0Jeremy Allison2011-12-221-4/+5
| | | | | | | | | on success, errno on fail and return the jobid in a separate variable. I need this fix for my vfs_aio_pthread.c module. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Thu Dec 22 12:12:33 CET 2011 on sn-devel-104
* replace: Add don't include unistd.h directly and add uid_wrapper.Andreas Schneider2011-10-271-1/+1
|
* build: Fix waf build on MacOS XAndrew Bartlett2011-09-231-1/+2
| | | | | | | | | | | The -framework CoreFoundation is required by the charset_macosxfs module The system/time.h header is required to access the replacement clock_gettime() Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Fri Sep 23 10:58:02 CEST 2011 on sn-devel-104
* s3/pthreadpool: replace bad portable gettimeofday by clock_gettimeBjörn Jacke2011-06-061-4/+2
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3: Properly clean up in pthreadpool_init in case of failureVolker Lendecke2011-04-271-0/+6
| | | | | Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Wed Apr 27 23:57:19 CEST 2011 on sn-devel-104
* s3: Allow unlimited parallelism in pthreadpoolVolker Lendecke2011-04-261-9/+28
|
* s3: pthreadpool_sig_fd->pthreadpool_signal_fdVolker Lendecke2011-04-251-1/+1
|
* s3: Many pthreadpool fixesVolker Lendecke2011-04-251-0/+592
In particular, this makes it fork-safe