Set the default number of background threads to 4.
The setting has been tested in production for a while. No negative effect while we were able to reduce number of threads per process.
This commit is contained in:
parent
43f3b1ad0c
commit
c4063ce439
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#define BACKGROUND_THREAD_INDEFINITE_SLEEP UINT64_MAX
|
#define BACKGROUND_THREAD_INDEFINITE_SLEEP UINT64_MAX
|
||||||
#define MAX_BACKGROUND_THREAD_LIMIT MALLOCX_ARENA_LIMIT
|
#define MAX_BACKGROUND_THREAD_LIMIT MALLOCX_ARENA_LIMIT
|
||||||
|
#define DEFAULT_NUM_BACKGROUND_THREAD 4
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
background_thread_stopped,
|
background_thread_stopped,
|
||||||
|
@ -13,7 +13,7 @@ JEMALLOC_DIAGNOSTIC_DISABLE_SPURIOUS
|
|||||||
#define BACKGROUND_THREAD_DEFAULT false
|
#define BACKGROUND_THREAD_DEFAULT false
|
||||||
/* Read-only after initialization. */
|
/* Read-only after initialization. */
|
||||||
bool opt_background_thread = BACKGROUND_THREAD_DEFAULT;
|
bool opt_background_thread = BACKGROUND_THREAD_DEFAULT;
|
||||||
size_t opt_max_background_threads = MAX_BACKGROUND_THREAD_LIMIT;
|
size_t opt_max_background_threads = MAX_BACKGROUND_THREAD_LIMIT + 1;
|
||||||
|
|
||||||
/* Used for thread creation, termination and stats. */
|
/* Used for thread creation, termination and stats. */
|
||||||
malloc_mutex_t background_thread_lock;
|
malloc_mutex_t background_thread_lock;
|
||||||
@ -872,9 +872,8 @@ background_thread_boot1(tsdn_t *tsdn) {
|
|||||||
assert(have_background_thread);
|
assert(have_background_thread);
|
||||||
assert(narenas_total_get() > 0);
|
assert(narenas_total_get() > 0);
|
||||||
|
|
||||||
if (opt_max_background_threads == MAX_BACKGROUND_THREAD_LIMIT &&
|
if (opt_max_background_threads > MAX_BACKGROUND_THREAD_LIMIT) {
|
||||||
ncpus < MAX_BACKGROUND_THREAD_LIMIT) {
|
opt_max_background_threads = DEFAULT_NUM_BACKGROUND_THREAD;
|
||||||
opt_max_background_threads = ncpus;
|
|
||||||
}
|
}
|
||||||
max_background_threads = opt_max_background_threads;
|
max_background_threads = opt_max_background_threads;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user