From 64e458f5cdd64f9b67cb495f177ef96bf3ce4e0e Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Wed, 8 Mar 2017 22:42:57 -0800 Subject: Implement two-phase decay-based purging. Split decay-based purging into two phases, the first of which uses lazy purging to convert dirty pages to "muzzy", and the second of which uses forced purging, decommit, or unmapping to convert pages to clean or destroy them altogether. Not all operating systems support lazy purging, yet the application may provide extent hooks that implement lazy purging, so care must be taken to dynamically omit the first phase when necessary. The mallctl interfaces change as follows: - opt.decay_time --> opt.{dirty,muzzy}_decay_time - arena..decay_time --> arena..{dirty,muzzy}_decay_time - arenas.decay_time --> arenas.{dirty,muzzy}_decay_time - stats.arenas..pdirty --> stats.arenas..p{dirty,muzzy} - stats.arenas..{npurge,nmadvise,purged} --> stats.arenas..{dirty,muzzy}_{npurge,nmadvise,purged} This resolves #521. --- src/large.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/large.c') diff --git a/src/large.c b/src/large.c index 5145f418..c578995c 100644 --- a/src/large.c +++ b/src/large.c @@ -125,7 +125,7 @@ large_ralloc_no_move_shrink(tsdn_t *tsdn, extent_t *extent, size_t usize) { extent_usize_get(trail)); } - arena_extent_cache_dalloc(tsdn, arena, &extent_hooks, trail); + arena_extents_dirty_dalloc(tsdn, arena, &extent_hooks, trail); } arena_extent_ralloc_large_shrink(tsdn, arena, extent, oldusize); @@ -158,9 +158,16 @@ large_ralloc_no_move_expand(tsdn_t *tsdn, extent_t *extent, size_t usize, bool commit = true; extent_t *trail; bool new_mapping; - if ((trail = extent_alloc_cache(tsdn, arena, &extent_hooks, - extent_past_get(extent), trailsize, 0, CACHELINE, &is_zeroed_trail, - &commit, false)) == NULL) { + if ((trail = extents_alloc(tsdn, arena, &extent_hooks, + &arena->extents_dirty, extent_past_get(extent), trailsize, 0, + CACHELINE, &is_zeroed_trail, &commit, false)) != NULL + || (trail = extents_alloc(tsdn, arena, &extent_hooks, + &arena->extents_muzzy, extent_past_get(extent), trailsize, 0, + CACHELINE, &is_zeroed_trail, &commit, false)) != NULL) { + if (config_stats) { + new_mapping = false; + } + } else { if ((trail = extent_alloc_wrapper(tsdn, arena, &extent_hooks, extent_past_get(extent), trailsize, 0, CACHELINE, &is_zeroed_trail, &commit, false)) == NULL) { @@ -169,10 +176,6 @@ large_ralloc_no_move_expand(tsdn_t *tsdn, extent_t *extent, size_t usize, if (config_stats) { new_mapping = true; } - } else { - if (config_stats) { - new_mapping = false; - } } if (extent_merge_wrapper(tsdn, arena, &extent_hooks, extent, trail)) { @@ -327,7 +330,7 @@ large_dalloc_prep_impl(tsdn_t *tsdn, arena_t *arena, extent_t *extent, static void large_dalloc_finish_impl(tsdn_t *tsdn, arena_t *arena, extent_t *extent) { extent_hooks_t *extent_hooks = EXTENT_HOOKS_INITIALIZER; - arena_extent_cache_dalloc(tsdn, arena, &extent_hooks, extent); + arena_extents_dirty_dalloc(tsdn, arena, &extent_hooks, extent); } void -- cgit v1.2.3