@@ -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
6765bool 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 =
0 commit comments