mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-28 22:02:12 +03:00
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).
This commit is contained in:
parent
3f685e8824
commit
b693c7868e
23 changed files with 1245 additions and 348 deletions
25
include/jemalloc/internal/background_thread_structs.h
Normal file
25
include/jemalloc/internal/background_thread_structs.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H
|
||||
#define JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H
|
||||
|
||||
struct background_thread_info_s {
|
||||
malloc_mutex_t mtx;
|
||||
#ifdef JEMALLOC_BACKGROUND_THREAD
|
||||
/* Background thread is pthread specific. */
|
||||
pthread_cond_t cond;
|
||||
pthread_t thread;
|
||||
/* Whether the thread has been created. */
|
||||
bool started;
|
||||
/* Next scheduled wakeup time (absolute time). */
|
||||
nstime_t next_wakeup;
|
||||
/*
|
||||
* Since the last background thread run, newly added number of pages
|
||||
* that need to be purged by the next wakeup. This is adjusted on
|
||||
* epoch advance, and is used to determine whether we should signal the
|
||||
* background thread to wake up earlier.
|
||||
*/
|
||||
size_t npages_to_purge_new;
|
||||
#endif /* ifdef JEMALLOC_BACKGROUND_THREAD */
|
||||
};
|
||||
typedef struct background_thread_info_s background_thread_info_t;
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_BACKGROUND_THREAD_STRUCTS_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue