Skip to content

Commit b7d5bd3

Browse files
committed
MB-40531: [BP] Prefer paging from replicas if possible
Backport of http://review.couchbase.org/c/kv_engine/+/134806 Prior to this change, the pager would try to page out X% of items in replica vbuckets, but if this did not bring memory usage below the low water mark, it would flip phase to ACTIVE_AND_PENDING_ONLY - meaning the next run of the pager would page immediately try to page from active and pending vbuckets. Now, active/pending vbuckets will only be considered if paging _every_ possible item from replicas would not free enough memory to drop below the low water mark. Note: On branch 'alice' HIFI MRU is the default eviction policy, but 2Bit LRU is still present. This change applis to HIFI MRU only. Change-Id: I47347fe1680a6c2316154e4d9c511a1b54489d82 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/142512 Well-Formed: Build Bot <[email protected]> Reviewed-by: Daniel Owen <[email protected]> Tested-by: Paolo Cocchi <[email protected]>
1 parent b8aa082 commit b7d5bd3

File tree

14 files changed

+613
-141
lines changed

14 files changed

+613
-141
lines changed

engines/ep/src/ep_bucket.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ class EPBucket : public KVBucket {
147147
return true;
148148
}
149149

150+
bool canEvictFromReplicas() override {
151+
return true;
152+
}
153+
150154
protected:
151155
class ValueChangedListener;
152156

engines/ep/src/ephemeral_bucket.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ class EphemeralBucket : public KVBucket {
133133
*/
134134
static void reconfigureForEphemeral(Configuration& config);
135135

136+
bool canEvictFromReplicas() override {
137+
return false;
138+
}
139+
136140
protected:
137141
std::unique_ptr<VBucketCountVisitor> makeVBCountVisitor(
138142
vbucket_state_t state) override;

engines/ep/src/hash_table.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,15 @@ class HashTable {
854854
*/
855855
void dump() const;
856856

857+
/**
858+
* Generates a new value that is either the same or higher than the input
859+
* value. It is intended to be used to increment the frequency counter of a
860+
* storedValue.
861+
* @param value The value counter to try to generate an increment for.
862+
* @returns The new value that is the same or higher than value.
863+
*/
864+
uint8_t generateFreqValue(uint8_t value);
865+
857866
private:
858867
// The container for actually holding the StoredValues.
859868
using table_type = std::vector<StoredValue::UniquePtr>;
@@ -951,15 +960,6 @@ class HashTable {
951960

952961
void clear_UNLOCKED(bool deactivate);
953962

954-
/**
955-
* Generates a new value that is either the same or higher than the input
956-
* value. It is intended to be used to increment the frequency counter of a
957-
* storedValue.
958-
* @param value The value counter to try to generate an increment for.
959-
* @returns The new value that is the same or higher than value.
960-
*/
961-
uint8_t generateFreqValue(uint8_t value);
962-
963963
DISALLOW_COPY_AND_ASSIGN(HashTable);
964964
};
965965

0 commit comments

Comments
 (0)