aboutsummaryrefslogtreecommitdiffstats
path: root/src/mutex.c
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-03-17 12:42:33 -0700
committerQi Wang <interwq@gmail.com>2017-05-23 12:26:20 -0700
commitb693c7868ea965407aca4cb01fdb8fe9af14adce (patch)
tree704dbd12a4ddd24e8336e1547343663b530bbce6 /src/mutex.c
parent3f685e88245c9807d7bdcaffce47b0fe14b974be (diff)
downloadplatform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.gz
platform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.tar.bz2
platform_external_jemalloc_new-b693c7868ea965407aca4cb01fdb8fe9af14adce.zip
Implementing opt.background_thread.
Added opt.background_thread to enable background threads, which handles purging currently. When enabled, decay ticks will not trigger purging (which will be left to the background threads). We limit the max number of threads to NCPUs. When percpu arena is enabled, set CPU affinity for the background threads as well. The sleep interval of background threads is dynamic and determined by computing number of pages to purge in the future (based on backlog).
Diffstat (limited to 'src/mutex.c')
-rw-r--r--src/mutex.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/mutex.c b/src/mutex.c
index b15bbf6e..c92ddd72 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -5,10 +5,6 @@
#include "jemalloc/internal/assert.h"
#include "jemalloc/internal/malloc_io.h"
-#if defined(JEMALLOC_LAZY_LOCK) && !defined(_WIN32)
-#include <dlfcn.h>
-#endif
-
#ifndef _CRT_SPINCOUNT
#define _CRT_SPINCOUNT 4000
#endif
@@ -24,10 +20,6 @@ static bool postpone_init = true;
static malloc_mutex_t *postponed_mutexes = NULL;
#endif
-#if defined(JEMALLOC_LAZY_LOCK) && !defined(_WIN32)
-static void pthread_create_once(void);
-#endif
-
/******************************************************************************/
/*
* We intercept pthread_create() calls in order to toggle isthreaded if the
@@ -35,18 +27,9 @@ static void pthread_create_once(void);
*/
#if defined(JEMALLOC_LAZY_LOCK) && !defined(_WIN32)
-static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *,
- void *(*)(void *), void *__restrict);
-
static void
pthread_create_once(void) {
- pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
- if (pthread_create_fptr == NULL) {
- malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
- "\"pthread_create\")\n");
- abort();
- }
-
+ pthread_create_fptr = load_pthread_create_fptr();
isthreaded = true;
}