extents: Remove preserve_lru feature.

preserve_lru feature adds lots of complication, for little value.
Removing it means merged extents are re-added to the lru list, and may
take longer to madvise away than they otherwise would.

Canaries after removal seem flat for several services (no change).
This commit is contained in:
Dave Watson 2018-02-22 09:40:27 -08:00
parent 21eb0d15a6
commit 6d02421730

View File

@ -306,8 +306,7 @@ extents_npages_get(extents_t *extents) {
} }
static void static void
extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent, extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
bool preserve_lru) {
malloc_mutex_assert_owner(tsdn, &extents->mtx); malloc_mutex_assert_owner(tsdn, &extents->mtx);
assert(extent_state_get(extent) == extents->state); assert(extent_state_get(extent) == extents->state);
@ -319,9 +318,7 @@ extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
(size_t)pind); (size_t)pind);
} }
extent_heap_insert(&extents->heaps[pind], extent); extent_heap_insert(&extents->heaps[pind], extent);
if (!preserve_lru) {
extent_list_append(&extents->lru, extent); extent_list_append(&extents->lru, extent);
}
size_t npages = size >> LG_PAGE; size_t npages = size >> LG_PAGE;
/* /*
* All modifications to npages hold the mutex (as asserted above), so we * All modifications to npages hold the mutex (as asserted above), so we
@ -335,8 +332,7 @@ extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
} }
static void static void
extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent, extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
bool preserve_lru) {
malloc_mutex_assert_owner(tsdn, &extents->mtx); malloc_mutex_assert_owner(tsdn, &extents->mtx);
assert(extent_state_get(extent) == extents->state); assert(extent_state_get(extent) == extents->state);
@ -348,9 +344,7 @@ extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
bitmap_set(extents->bitmap, &extents_bitmap_info, bitmap_set(extents->bitmap, &extents_bitmap_info,
(size_t)pind); (size_t)pind);
} }
if (!preserve_lru) {
extent_list_remove(&extents->lru, extent); extent_list_remove(&extents->lru, extent);
}
size_t npages = size >> LG_PAGE; size_t npages = size >> LG_PAGE;
/* /*
* As in extents_insert_locked, we hold extents->mtx and so don't need * As in extents_insert_locked, we hold extents->mtx and so don't need
@ -500,7 +494,7 @@ extent_try_delayed_coalesce(tsdn_t *tsdn, arena_t *arena,
if (!coalesced) { if (!coalesced) {
return true; return true;
} }
extents_insert_locked(tsdn, extents, extent, true); extents_insert_locked(tsdn, extents, extent);
return false; return false;
} }
@ -560,7 +554,7 @@ extents_evict(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
extent = NULL; extent = NULL;
goto label_return; goto label_return;
} }
extents_remove_locked(tsdn, extents, extent, false); extents_remove_locked(tsdn, extents, extent);
if (!extents->delay_coalesce) { if (!extents->delay_coalesce) {
break; break;
} }
@ -633,29 +627,29 @@ extents_postfork_child(tsdn_t *tsdn, extents_t *extents) {
static void static void
extent_deactivate_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, extent_deactivate_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents,
extent_t *extent, bool preserve_lru) { extent_t *extent) {
assert(extent_arena_get(extent) == arena); assert(extent_arena_get(extent) == arena);
assert(extent_state_get(extent) == extent_state_active); assert(extent_state_get(extent) == extent_state_active);
extent_state_set(extent, extents_state_get(extents)); extent_state_set(extent, extents_state_get(extents));
extents_insert_locked(tsdn, extents, extent, preserve_lru); extents_insert_locked(tsdn, extents, extent);
} }
static void static void
extent_deactivate(tsdn_t *tsdn, arena_t *arena, extents_t *extents, extent_deactivate(tsdn_t *tsdn, arena_t *arena, extents_t *extents,
extent_t *extent, bool preserve_lru) { extent_t *extent) {
malloc_mutex_lock(tsdn, &extents->mtx); malloc_mutex_lock(tsdn, &extents->mtx);
extent_deactivate_locked(tsdn, arena, extents, extent, preserve_lru); extent_deactivate_locked(tsdn, arena, extents, extent);
malloc_mutex_unlock(tsdn, &extents->mtx); malloc_mutex_unlock(tsdn, &extents->mtx);
} }
static void static void
extent_activate_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, extent_activate_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents,
extent_t *extent, bool preserve_lru) { extent_t *extent) {
assert(extent_arena_get(extent) == arena); assert(extent_arena_get(extent) == arena);
assert(extent_state_get(extent) == extents_state_get(extents)); assert(extent_state_get(extent) == extents_state_get(extents));
extents_remove_locked(tsdn, extents, extent, preserve_lru); extents_remove_locked(tsdn, extents, extent);
extent_state_set(extent, extent_state_active); extent_state_set(extent, extent_state_active);
} }
@ -905,7 +899,7 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena,
return NULL; return NULL;
} }
extent_activate_locked(tsdn, arena, extents, extent, false); extent_activate_locked(tsdn, arena, extents, extent);
malloc_mutex_unlock(tsdn, &extents->mtx); malloc_mutex_unlock(tsdn, &extents->mtx);
return extent; return extent;
@ -1031,10 +1025,10 @@ extent_recycle_split(tsdn_t *tsdn, arena_t *arena,
if (result == extent_split_interior_ok) { if (result == extent_split_interior_ok) {
if (lead != NULL) { if (lead != NULL) {
extent_deactivate(tsdn, arena, extents, lead, false); extent_deactivate(tsdn, arena, extents, lead);
} }
if (trail != NULL) { if (trail != NULL) {
extent_deactivate(tsdn, arena, extents, trail, false); extent_deactivate(tsdn, arena, extents, trail);
} }
return extent; return extent;
} else { } else {
@ -1517,34 +1511,15 @@ extent_coalesce(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
bool growing_retained) { bool growing_retained) {
assert(extent_can_coalesce(arena, extents, inner, outer)); assert(extent_can_coalesce(arena, extents, inner, outer));
if (extents->delay_coalesce) { extent_activate_locked(tsdn, arena, extents, outer);
/*
* Remove outer from the LRU list so that it won't be show up in
* decay through extents_evict.
*/
extent_list_remove(&extents->lru, outer);
}
extent_activate_locked(tsdn, arena, extents, outer,
extents->delay_coalesce);
malloc_mutex_unlock(tsdn, &extents->mtx); malloc_mutex_unlock(tsdn, &extents->mtx);
bool err = extent_merge_impl(tsdn, arena, r_extent_hooks, bool err = extent_merge_impl(tsdn, arena, r_extent_hooks,
forward ? inner : outer, forward ? outer : inner, growing_retained); forward ? inner : outer, forward ? outer : inner, growing_retained);
malloc_mutex_lock(tsdn, &extents->mtx); malloc_mutex_lock(tsdn, &extents->mtx);
if (!err && extents->delay_coalesce) {
if (forward) {
extent_list_prepend(&extents->lru, inner);
} else {
extent_list_prepend(&extents->lru, outer);
}
}
if (err) { if (err) {
if (extents->delay_coalesce) { extent_deactivate_locked(tsdn, arena, extents, outer);
extent_list_prepend(&extents->lru, outer);
}
extent_deactivate_locked(tsdn, arena, extents, outer,
extents->delay_coalesce);
} }
return err; return err;
@ -1655,13 +1630,10 @@ extent_record(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
extent = extent_try_coalesce(tsdn, arena, extent = extent_try_coalesce(tsdn, arena,
r_extent_hooks, rtree_ctx, extents, extent, r_extent_hooks, rtree_ctx, extents, extent,
&coalesced, growing_retained); &coalesced, growing_retained);
if (coalesced) {
extent_list_remove(&extents->lru, extent);
}
} while (coalesced && } while (coalesced &&
extent_size_get(extent) >= prev_size + LARGE_MINCLASS); extent_size_get(extent) >= prev_size + LARGE_MINCLASS);
} }
extent_deactivate_locked(tsdn, arena, extents, extent, false); extent_deactivate_locked(tsdn, arena, extents, extent);
malloc_mutex_unlock(tsdn, &extents->mtx); malloc_mutex_unlock(tsdn, &extents->mtx);
} }