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
extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
bool preserve_lru) {
extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
malloc_mutex_assert_owner(tsdn, &extents->mtx);
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);
}
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;
/*
* 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
extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent,
bool preserve_lru) {
extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
malloc_mutex_assert_owner(tsdn, &extents->mtx);
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,
(size_t)pind);
}
if (!preserve_lru) {
extent_list_remove(&extents->lru, extent);
}
extent_list_remove(&extents->lru, extent);
size_t npages = size >> LG_PAGE;
/*
* 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) {
return true;
}
extents_insert_locked(tsdn, extents, extent, true);
extents_insert_locked(tsdn, extents, extent);
return false;
}
@ -560,7 +554,7 @@ extents_evict(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
extent = NULL;
goto label_return;
}
extents_remove_locked(tsdn, extents, extent, false);
extents_remove_locked(tsdn, extents, extent);
if (!extents->delay_coalesce) {
break;
}
@ -633,29 +627,29 @@ extents_postfork_child(tsdn_t *tsdn, extents_t *extents) {
static void
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_state_get(extent) == extent_state_active);
extent_state_set(extent, extents_state_get(extents));
extents_insert_locked(tsdn, extents, extent, preserve_lru);
extents_insert_locked(tsdn, extents, extent);
}
static void
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);
extent_deactivate_locked(tsdn, arena, extents, extent, preserve_lru);
extent_deactivate_locked(tsdn, arena, extents, extent);
malloc_mutex_unlock(tsdn, &extents->mtx);
}
static void
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_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);
}
@ -905,7 +899,7 @@ extent_recycle_extract(tsdn_t *tsdn, arena_t *arena,
return NULL;
}
extent_activate_locked(tsdn, arena, extents, extent, false);
extent_activate_locked(tsdn, arena, extents, extent);
malloc_mutex_unlock(tsdn, &extents->mtx);
return extent;
@ -1031,10 +1025,10 @@ extent_recycle_split(tsdn_t *tsdn, arena_t *arena,
if (result == extent_split_interior_ok) {
if (lead != NULL) {
extent_deactivate(tsdn, arena, extents, lead, false);
extent_deactivate(tsdn, arena, extents, lead);
}
if (trail != NULL) {
extent_deactivate(tsdn, arena, extents, trail, false);
extent_deactivate(tsdn, arena, extents, trail);
}
return extent;
} else {
@ -1517,34 +1511,15 @@ extent_coalesce(tsdn_t *tsdn, arena_t *arena, extent_hooks_t **r_extent_hooks,
bool growing_retained) {
assert(extent_can_coalesce(arena, extents, inner, outer));
if (extents->delay_coalesce) {
/*
* 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);
extent_activate_locked(tsdn, arena, extents, outer);
malloc_mutex_unlock(tsdn, &extents->mtx);
bool err = extent_merge_impl(tsdn, arena, r_extent_hooks,
forward ? inner : outer, forward ? outer : inner, growing_retained);
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 (extents->delay_coalesce) {
extent_list_prepend(&extents->lru, outer);
}
extent_deactivate_locked(tsdn, arena, extents, outer,
extents->delay_coalesce);
extent_deactivate_locked(tsdn, arena, extents, outer);
}
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,
r_extent_hooks, rtree_ctx, extents, extent,
&coalesced, growing_retained);
if (coalesced) {
extent_list_remove(&extents->lru, extent);
}
} while (coalesced &&
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);
}