Skip to content

Commit 7143c3d

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-33151: Remove hifi mfu config param
2 bit LRU support was left as a dynamic config option to allow easy testing and for customers to revert the eviction algorithm changes if the hifi MFU changes caused issues. Hifi MFU has been around long enough that we want to remove some complexity and get rid of 2 bit LRU support. Remove the hifi_mfu config parameter entirely and the 2 bit LRU code. The DcpProducer can still talk to older nodes and send 2 bit LRU hotness values instead of hifi MFU hotness values if the DcpConsumer does not hello with supports hifi MFU. Change-Id: Ibdbd39a070205911514d189eb00f2a8190e97373 Reviewed-on: http://review.couchbase.org/105338 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Reviewed-by: Daniel Owen <[email protected]>
1 parent eaf86b3 commit 7143c3d

File tree

12 files changed

+146
-297
lines changed

12 files changed

+146
-297
lines changed

engines/ep/configuration.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -471,18 +471,6 @@
471471
"dynamic": true,
472472
"type": "size_t"
473473
},
474-
"ht_eviction_policy": {
475-
"default": "hifi_mfu",
476-
"descr": "The eviction policy for the hash table",
477-
"dynamic": true,
478-
"type": "std::string",
479-
"validator": {
480-
"enum": [
481-
"2-bit_lru",
482-
"hifi_mfu"
483-
]
484-
}
485-
},
486474
"ht_locks": {
487475
"default": "47",
488476
"dynamic": true,

engines/ep/src/dcp/consumer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ DcpConsumer::DcpConsumer(EventuallyPersistentEngine& engine,
180180
pendingSetPriority = true;
181181
pendingEnableExtMetaData = true;
182182
pendingSupportCursorDropping = true;
183-
pendingSupportHifiMFU =
184-
(config.getHtEvictionPolicy() == "hifi_mfu");
183+
pendingSupportHifiMFU = true;
185184
pendingEnableExpiryOpcode = true;
186185
syncReplNegotiation.state = SyncReplNegotiation::State::PendingRequest;
187186
// If a consumer_name was provided then tell the producer about it.

engines/ep/src/dcp/producer.cc

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ DcpProducer::DcpProducer(EventuallyPersistentEngine& e,
187187
setSupportAck(true);
188188
setReserved(true);
189189
pause(PausedReason::Initializing);
190-
191190
if (notifyOnly) {
192191
setLogHeader("DCP (Notifier) " + getName() + " -");
193192
} else {
@@ -561,20 +560,16 @@ ENGINE_ERROR_CODE DcpProducer::streamRequest(
561560
}
562561

563562
uint8_t DcpProducer::encodeItemHotness(const Item& item) const {
564-
if (engine_.getConfiguration().getHtEvictionPolicy() == "hifi_mfu") {
565-
auto freqCount = item.getFreqCounterValue();
566-
if (consumerSupportsHifiMfu) {
567-
// The consumer supports the hifi_mfu eviction
568-
// policy, therefore use the frequency counter.
569-
return freqCount;
570-
}
571-
// The consumer does not support the hifi_mfu
572-
// eviction policy, therefore map from the 8-bit
573-
// probabilistic counter (256 states) to NRU (4 states).
574-
return ItemEviction::convertFreqCountToNRUValue(freqCount);
575-
}
576-
/* We are using the 2-bit_lru and therefore get the value */
577-
return item.getNRUValue();
563+
auto freqCount = item.getFreqCounterValue();
564+
if (consumerSupportsHifiMfu) {
565+
// The consumer supports the hifi_mfu eviction
566+
// policy, therefore use the frequency counter.
567+
return freqCount;
568+
}
569+
// The consumer does not support the hifi_mfu
570+
// eviction policy, therefore map from the 8-bit
571+
// probabilistic counter (256 states) to NRU (4 states).
572+
return ItemEviction::convertFreqCountToNRUValue(freqCount);
578573
}
579574

580575
ENGINE_ERROR_CODE DcpProducer::step(struct dcp_message_producers* producers) {

engines/ep/src/ep_engine.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,6 @@ cb::mcbp::Status EventuallyPersistentEngine::setFlushParam(
550550
getConfiguration().setPagerActiveVbPcnt(std::stoull(val));
551551
} else if (key == "pager_sleep_time_ms") {
552552
getConfiguration().setPagerSleepTimeMs(std::stoull(val));
553-
} else if (key == "ht_eviction_policy") {
554-
getConfiguration().setHtEvictionPolicy(val);
555553
} else if (key == "item_eviction_age_percentage") {
556554
getConfiguration().setItemEvictionAgePercentage(std::stoull(val));
557555
} else if (key == "item_eviction_freq_counter_age_threshold") {
@@ -4183,10 +4181,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::getStats(
41834181
} else if (statKey == "dcp") {
41844182
rv = doDcpStats(cookie, add_stat);
41854183
} else if (statKey == "eviction") {
4186-
// Only return eviction stats if hifi_mfu eviction policy is used.
4187-
rv = (configuration.getHtEvictionPolicy() == "hifi_mfu")
4188-
? doEvictionStats(cookie, add_stat)
4189-
: ENGINE_EINVAL;
4184+
rv = doEvictionStats(cookie, add_stat);
41904185
} else if (statKey == "hash") {
41914186
rv = doHashStats(cookie, add_stat);
41924187
} else if (statKey == "vbucket") {

engines/ep/src/item_pager.cc

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,18 @@ ItemPager::ItemPager(EventuallyPersistentEngine& e, EPStats& st)
4848
engine(e),
4949
stats(st),
5050
available(new std::atomic<bool>(true)),
51-
phase(PAGING_UNREFERENCED),
51+
phase(REPLICA_ONLY),
5252
doEvict(false),
5353
sleepTime(std::chrono::milliseconds(
5454
e.getConfiguration().getPagerSleepTimeMs())),
5555
notified(false) {
56-
if (engine.getConfiguration().getHtEvictionPolicy() == "hifi_mfu") {
57-
// For the hifi_mfu algorithm if a couchbase/persistent bucket we
58-
// want to start visiting the replica vbucket first. However for
59-
// ephemeral we do not evict from replica vbuckets and therefore
60-
// we start with active and pending vbuckets.
61-
phase = (engine.getConfiguration().getBucketType() == "persistent")
62-
? REPLICA_ONLY
63-
: ACTIVE_AND_PENDING_ONLY;
64-
}
56+
// For the hifi_mfu algorithm if a couchbase/persistent bucket we
57+
// want to start visiting the replica vbucket first. However for
58+
// ephemeral we do not evict from replica vbuckets and therefore
59+
// we start with active and pending vbuckets.
60+
phase = (engine.getConfiguration().getBucketType() == "persistent")
61+
? REPLICA_ONLY
62+
: ACTIVE_AND_PENDING_ONLY;
6563
}
6664

6765
bool ItemPager::run(void) {
@@ -84,21 +82,6 @@ bool ItemPager::run(void) {
8482
double upper = static_cast<double>(stats.mem_high_wat);
8583
double lower = static_cast<double>(stats.mem_low_wat);
8684

87-
// If we dynamically switch from the hifi_mfu policy to the 2-bit_lru
88-
// policy or vice-versa, we will not be in a valid phase. Therefore
89-
// reinitialise to the correct phase for the eviction policy.
90-
if (engine.getConfiguration().getHtEvictionPolicy() == "hifi_mfu") {
91-
if (phase != REPLICA_ONLY && phase != ACTIVE_AND_PENDING_ONLY) {
92-
// Not a valid phase for the hifi_mfu policy, so reinitialise.
93-
phase = (engine.getConfiguration().getBucketType() == "persistent")
94-
? REPLICA_ONLY
95-
: ACTIVE_AND_PENDING_ONLY;
96-
}
97-
} else if (phase != PAGING_UNREFERENCED && phase != PAGING_RANDOM) {
98-
// Not a valid phase for the 2-bit_lru policy, so reinitialise.
99-
phase = PAGING_UNREFERENCED;
100-
}
101-
10285
if (current <= lower) {
10386
doEvict = false;
10487
}
@@ -126,33 +109,27 @@ bool ItemPager::run(void) {
126109
VBucketFilter filter;
127110
// For the hifi_mfu algorithm use the phase to filter which vbuckets
128111
// we want to visit (either replica or active/pending vbuckets).
129-
if (cfg.getHtEvictionPolicy() == "hifi_mfu") {
130-
vbucket_state_t state;
131-
if (phase == REPLICA_ONLY) {
132-
state = vbucket_state_replica;
133-
} else if (phase == ACTIVE_AND_PENDING_ONLY) {
134-
state = vbucket_state_active;
135-
auto acceptableVBs = kvBucket->getVBucketsInState(state);
136-
for (auto vb : acceptableVBs) {
137-
filter.addVBucket(vb);
138-
}
139-
state = vbucket_state_pending;
140-
} else {
141-
throw std::invalid_argument(
142-
"ItemPager::run - "
143-
"phase is invalid for hifi_mfu eviction algorithm");
144-
}
112+
vbucket_state_t state;
113+
if (phase == REPLICA_ONLY) {
114+
state = vbucket_state_replica;
115+
} else if (phase == ACTIVE_AND_PENDING_ONLY) {
116+
state = vbucket_state_active;
145117
auto acceptableVBs = kvBucket->getVBucketsInState(state);
146118
for (auto vb : acceptableVBs) {
147119
filter.addVBucket(vb);
148120
}
121+
state = vbucket_state_pending;
122+
} else {
123+
throw std::invalid_argument(
124+
"ItemPager::run - "
125+
"phase is invalid for hifi_mfu eviction algorithm");
126+
}
127+
auto acceptableVBs = kvBucket->getVBucketsInState(state);
128+
for (auto vb : acceptableVBs) {
129+
filter.addVBucket(vb);
149130
}
150131

151132
bool isEphemeral = (cfg.getBucketType() == "ephemeral");
152-
PagingVisitor::EvictionPolicy evictionPolicy =
153-
(cfg.getHtEvictionPolicy() == "2-bit_lru")
154-
? PagingVisitor::EvictionPolicy::lru2Bit
155-
: PagingVisitor::EvictionPolicy::hifi_mfu;
156133

157134
auto pv = std::make_unique<PagingVisitor>(
158135
*kvBucket,
@@ -166,8 +143,7 @@ bool ItemPager::run(void) {
166143
&phase,
167144
isEphemeral,
168145
cfg.getItemEvictionAgePercentage(),
169-
cfg.getItemEvictionFreqCounterAgeThreshold(),
170-
evictionPolicy);
146+
cfg.getItemEvictionFreqCounterAgeThreshold());
171147

172148
// p99.99 is ~200ms
173149
const auto maxExpectedDurationForVisitorTask =
@@ -244,10 +220,6 @@ bool ExpiredItemPager::run(void) {
244220
Configuration& cfg = engine->getConfiguration();
245221
bool isEphemeral =
246222
(engine->getConfiguration().getBucketType() == "ephemeral");
247-
PagingVisitor::EvictionPolicy evictionPolicy =
248-
(cfg.getHtEvictionPolicy() == "2-bit_lru")
249-
? PagingVisitor::EvictionPolicy::lru2Bit
250-
: PagingVisitor::EvictionPolicy::hifi_mfu;
251223
auto pv = std::make_unique<PagingVisitor>(
252224
*kvBucket,
253225
stats,
@@ -260,8 +232,7 @@ bool ExpiredItemPager::run(void) {
260232
/* pager_phase */ nullptr,
261233
isEphemeral,
262234
cfg.getItemEvictionAgePercentage(),
263-
cfg.getItemEvictionFreqCounterAgeThreshold(),
264-
evictionPolicy);
235+
cfg.getItemEvictionFreqCounterAgeThreshold());
265236

266237
// p99.99 is ~50ms (same as ItemPager).
267238
const auto maxExpectedDurationForVisitorTask =

engines/ep/src/item_pager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class EventuallyPersistentEngine;
3030
* The item pager phase
3131
*/
3232
enum item_pager_phase {
33-
PAGING_UNREFERENCED,
34-
PAGING_RANDOM,
3533
REPLICA_ONLY, // Visit only replica vbuckets
3634
ACTIVE_AND_PENDING_ONLY // Visit only active and pending vbuckets
3735
};

0 commit comments

Comments
 (0)