Skip to content

Commit 1dfec49

Browse files
committed
MB-40531: [BP] Make replica eviction ignore age threshold
Backport of http://review.couchbase.org/c/kv_engine/+/134805 Normally items above a configured MFU value item_eviction_freq_counter_age_threshold and below a configured age item_eviction_age_percentage are not evicted. This avoids evicting "young" items; their MFU counter might not reflect how hot they are yet as they were only recently stored. However, when evicting from replica vbuckets, this may not be as beneficial. As active resident ratio has a direct impact on cache miss rate and average latency, it may be better to evict even young replica items to reclaim memory where possible, before considering active vbs. Change-Id: Ic066f2231fad551ef2d04ee93126ac47181e6a15 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/142503 Well-Formed: Build Bot <[email protected]> Tested-by: Paolo Cocchi <[email protected]> Reviewed-by: Trond Norbye <[email protected]>
1 parent 36fe786 commit 1dfec49

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

engines/ep/src/item_pager.cc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,25 @@ PagingVisitor::PagingVisitor(KVBucket& s,
141141
uint64_t age = (maxCas > v.getCas()) ? (maxCas - v.getCas()) : 0;
142142
age = age >> ItemEviction::casBitsNotTime;
143143

144-
if ((storedValueFreqCounter <= freqCounterThreshold) &&
145-
((storedValueFreqCounter < freqCounterAgeThreshold)
146-
|| (age >= ageThreshold))) {
144+
const bool belowMFUThreshold =
145+
storedValueFreqCounter <= freqCounterThreshold;
146+
// age exceeds threshold (from age histogram, set by config param
147+
// item_eviction_age_percentage
148+
// OR
149+
// MFU is below threshold set by config param
150+
// item_eviction_freq_counter_age_threshold
151+
// Below this threshold the item is considered "cold" enough
152+
// to be evicted even if it is "young".
153+
const bool meetsAgeRequirements =
154+
age >= ageThreshold ||
155+
storedValueFreqCounter < freqCounterAgeThreshold;
156+
157+
// For replica vbuckets, young items are not protected from
158+
// eviction.
159+
const bool isReplica =
160+
currentBucket->getState() == vbucket_state_replica;
161+
162+
if (belowMFUThreshold && (meetsAgeRequirements || isReplica)) {
147163
/*
148164
* If the storedValue is eligible for eviction then add its
149165
* frequency counter value to the histogram, otherwise add the

0 commit comments

Comments
 (0)