summaryrefslogtreecommitdiffstats
path: root/src/background_thread.c
Commit message (Collapse)AuthorAgeFilesLines
* Make background_thread not dependent on libdl.Qi Wang2019-02-071-1/+8
| | | | When not using libdl, still allows background_thread to be enabled.
* Avoid creating bg thds for huge arena lone.Qi Wang2019-01-161-4/+16
| | | | | | For low arena count settings, the huge threshold feature may trigger an unwanted bg thd creation. Given that the huge arena does eager purging by default, bypass bg thd creation when initializing the huge arena.
* Set the default number of background threads to 4.Qi Wang2018-11-161-4/+3
| | | | | The setting has been tested in production for a while. No negative effect while we were able to reduce number of threads per process.
* Make use of pthread_set_name_np(3) on FreeBSD.Edward Tomasz Napierala2018-10-241-0/+2
|
* Clean compilation -Wextragnzlbg2018-07-101-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit jemalloc produced many warnings when compiled with -Wextra with both Clang and GCC. This commit fixes the issues raised by these warnings or suppresses them if they were spurious at least for the Clang and GCC versions covered by CI. This commit: * adds `JEMALLOC_DIAGNOSTIC` macros: `JEMALLOC_DIAGNOSTIC_{PUSH,POP}` are used to modify the stack of enabled diagnostics. The `JEMALLOC_DIAGNOSTIC_IGNORE_...` macros are used to ignore a concrete diagnostic. * adds `JEMALLOC_FALLTHROUGH` macro to explicitly state that falling through `case` labels in a `switch` statement is intended * Removes all UNUSED annotations on function parameters. The warning -Wunused-parameter is now disabled globally in `jemalloc_internal_macros.h` for all translation units that include that header. It is never re-enabled since that header cannot be included by users. * locally suppresses some -Wextra diagnostics: * `-Wmissing-field-initializer` is buggy in older Clang and GCC versions, where it does not understanding that, in C, `= {0}` is a common C idiom to initialize a struct to zero * `-Wtype-bounds` is suppressed in a particular situation where a generic macro, used in multiple different places, compares an unsigned integer for smaller than zero, which is always true. * `-Walloc-larger-than-size=` diagnostics warn when an allocation function is called with a size that is too large (out-of-range). These are suppressed in the parts of the tests where `jemalloc` explicitly does this to test that the allocation functions fail properly. * adds a new CI build bot that runs the log unit test on CI. Closes #1196 .
* Fall back to the default pthread_create if RTLD_NEXT fails.Qi Wang2018-06-281-7/+9
|
* Remove an incorrect assertion.Qi Wang2018-04-181-1/+4
| | | | | Background threads are created without holding the global background_thread lock, which mean paused state is possible (and fine).
* Invoke dlsym() on demand.Qi Wang2018-04-181-11/+24
| | | | | If no lazy lock or background thread is enabled, avoid dlsym pthread_create on boot.
* background_thread: add max thread count configDave Watson2018-04-101-20/+29
| | | | | Looking at the thread counts in our services, jemalloc's background thread is useful, but mostly idle. Add a config option to tune down the number of threads.
* Fix a background_thread shutdown issue.Qi Wang2018-04-021-21/+26
| | | | | 1) make sure background thread 0 is always created; and 2) fix synchronization between thread 0 and the control thread.
* Background threads: fix an indexing bug.David Goldblatt2018-02-281-1/+2
| | | | | | We have a buffer overrun that manifests in the case where arena indices higher than the number of CPUs are accessed before arena indices lower than the number of CPUs. This fixes the bug and adds a test.
* Set isthreaded manually.HEADdevQi Wang2017-10-061-5/+6
| | | | Avoid relying pthread_once which creates dependency during init.
* Delay background_thread_ctl_init to right before thread creation.Qi Wang2017-10-061-3/+0
| | | | | ctl_init sets isthreaded, which means it should be done without holding any locks.
* Fix pthread_sigmask() usage to block all signals.Qi Wang2017-06-261-1/+1
|
* Check arena in current context in pre_reentrancy.Qi Wang2017-06-231-3/+3
|
* Add thread name for background threads.Qi Wang2017-06-231-1/+3
|
* Mask signals during background thread creation.Jason Evans2017-06-211-3/+35
| | | | | This prevents signals from being inadvertently delivered to background threads.
* Only abort on dlsym when necessary.Qi Wang2017-06-141-3/+11
| | | | | If neither background_thread nor lazy_lock is in use, do not abort on dlsym errors.
* Combine background_thread started / paused into state.Qi Wang2017-06-121-25/+46
|
* Not re-enable background thread after fork.Qi Wang2017-06-121-35/+46
| | | | Avoid calling pthread_create in postfork handlers.
* Move background thread creation to background_thread_0.Qi Wang2017-06-121-140/+241
| | | | | To avoid complications, avoid invoking pthread_create "internally", instead rely on thread0 to launch new threads, and also terminating threads when asked.
* Normalize background thread configuration.Jason Evans2017-06-091-0/+2
| | | | Also fix a compilation error #ifndef JEMALLOC_PTHREAD_CREATE_WRAPPER.
* Add internal tsd for background_thread.Qi Wang2017-06-081-5/+4
|
* Drop high rank locks when creating threads.Qi Wang2017-06-081-1/+4
| | | | | | Avoid holding arenas_lock and background_thread_lock when creating background threads, because pthread_create may take internal locks, and potentially cause deadlock with jemalloc internal locks.
* Set isthreaded when enabling background_thread.Qi Wang2017-06-021-23/+39
|
* Fix background thread creation.Qi Wang2017-06-011-13/+17
| | | | The state initialization should be done before pthread_create.
* Refactor/fix background_thread/percpu_arena bootstrapping.Jason Evans2017-06-011-50/+66
| | | | | Refactor bootstrapping such that dlsym() is called during the bootstrapping phase that can tolerate reentrant allocation.
* Use real pthread_create for creating background threads.Qi Wang2017-05-311-2/+8
|
* Track background thread status separately at fork.Qi Wang2017-05-311-3/+8
| | | | | Use a separate boolean to track the enabled status, instead of leaving the global background thread status inconsistent.
* Check for background thread inactivity on extents_dalloc.Qi Wang2017-05-231-19/+42
| | | | | | To avoid background threads sleeping forever with idle arenas, we eagerly check background threads' sleep time after extents_dalloc, and signal the thread if necessary.
* Add background thread related stats.Qi Wang2017-05-231-20/+79
|
* Implementing opt.background_thread.Qi Wang2017-05-231-0/+572
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).