MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / arena_decay_impl

Function arena_decay_impl

deps/jemalloc/src/arena.c:947–980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

945}
946
947static bool
948arena_decay_impl(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
949 extents_t *extents, bool is_background_thread, bool all) {
950 if (all) {
951 malloc_mutex_lock(tsdn, &decay->mtx);
952 arena_decay_to_limit(tsdn, arena, decay, extents, all, 0,
953 extents_npages_get(extents), is_background_thread);
954 malloc_mutex_unlock(tsdn, &decay->mtx);
955
956 return false;
957 }
958
959 if (malloc_mutex_trylock(tsdn, &decay->mtx)) {
960 /* No need to wait if another thread is in progress. */
961 return true;
962 }
963
964 bool epoch_advanced = arena_maybe_decay(tsdn, arena, decay, extents,
965 is_background_thread);
966 size_t npages_new;
967 if (epoch_advanced) {
968 /* Backlog is updated on epoch advance. */
969 npages_new = decay->backlog[SMOOTHSTEP_NSTEPS-1];
970 }
971 malloc_mutex_unlock(tsdn, &decay->mtx);
972
973 if (have_background_thread && background_thread_enabled() &&
974 epoch_advanced && !is_background_thread) {
975 background_thread_interval_check(tsdn, arena, decay,
976 npages_new);
977 }
978
979 return false;
980}
981
982static bool
983arena_decay_dirty(tsdn_t *tsdn, arena_t *arena, bool is_background_thread,

Callers 2

arena_decay_dirtyFunction · 0.70
arena_decay_muzzyFunction · 0.70

Calls 8

arena_decay_to_limitFunction · 0.70
extents_npages_getFunction · 0.70
arena_maybe_decayFunction · 0.70
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50
malloc_mutex_trylockFunction · 0.50

Tested by

no test coverage detected