summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_aio_pthread.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-01-05 15:48:24 -0800
committerJeremy Allison <jra@samba.org>2012-01-06 02:42:25 +0100
commite8a7d9c822ae4be4533f9e34885816a5b7831154 (patch)
tree50352a0092e47131f3858f664740a5cbee8fdd44 /source3/modules/vfs_aio_pthread.c
parent200c22b9940f8e222f20f95691bc61dcb883b609 (diff)
downloadsamba-e8a7d9c822ae4be4533f9e34885816a5b7831154.tar.gz
samba-e8a7d9c822ae4be4533f9e34885816a5b7831154.tar.bz2
samba-e8a7d9c822ae4be4533f9e34885816a5b7831154.zip
Add a sys_get_number_of_cores() function that calls sysconf or sysctl
and tunes the aio threads.
Diffstat (limited to 'source3/modules/vfs_aio_pthread.c')
-rw-r--r--source3/modules/vfs_aio_pthread.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c
index cccaa332e0..9217b69e80 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -55,7 +55,17 @@ static void aio_pthread_handle_completion(struct event_context *event_ctx,
static int aio_get_num_threads(void)
{
- return 10;
+ int num_cores = sys_get_number_of_cores();
+ DEBUG(10,("aio_get_num_threads: sys_get_number_of_cores "
+ "returned %d\n",
+ num_cores));
+ num_cores *= 2;
+ if (num_cores < 1) {
+ num_cores = 1;
+ }
+ /* Even on a single processor box give a little
+ concurrency. */
+ return MIN(4,num_cores);
}
#if 0
@@ -102,7 +112,7 @@ static bool init_aio_threadpool(void)
{
struct fd_event *sock_event = NULL;
int ret = 0;
- int num_threads = aio_get_num_threads();
+ int num_threads;
#if 0
struct timeval ne;
#endif
@@ -111,6 +121,7 @@ static bool init_aio_threadpool(void)
return true;
}
+ num_threads = aio_get_num_threads();
ret = pthreadpool_init(num_threads, &pool);
if (ret) {
errno = ret;