Skip to content

Commit c2265cd

Browse files
No ghost, Cheap Evict
1 parent 0566f6a commit c2265cd

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

cachelib/allocator/MMS3FIFO.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,19 @@ class MMS3FIFO {
210210
return *this;
211211
}
212212
++it;
213-
// Skip accessed items
214-
skipAccessed(it);
213+
// // Skip accessed items
214+
// skipAccessed(it);
215215
return *this;
216216
}
217217

218-
ListIterator& skipAccessed(ListIterator& it) noexcept {
218+
void skipAccessed(ListIterator& it) noexcept {
219219
while (it) {
220220
T& node = *it;
221221
if (!Container<T, HookPtr>::isAccessed(node)) {
222222
break; // found a valid eviction victim
223223
}
224224
++it; // skip this accessed item
225225
}
226-
return it;
227226
}
228227

229228
LockedIterator& operator--() {
@@ -469,7 +468,7 @@ void MMS3FIFO::Container<T, HookPtr>::maybeResizeGhostLocked() noexcept {
469468

470469
size_t expectedGhostSize =
471470
static_cast<size_t>(lruSize * config_.ghostSizePercent / 100);
472-
ghostQueue_.resize(expectedGhostSize);
471+
// ghostQueue_.resize(expectedGhostSize);
473472
capacity_ = lruSize;
474473
}
475474

@@ -540,7 +539,8 @@ bool MMS3FIFO::Container<T, HookPtr>::add(T& node) noexcept {
540539
const auto currTime = static_cast<Time>(util::getCurrentTimeSec());
541540

542541
const auto nodeHash = hashNode(node);
543-
const auto ghostContains = ghostQueue_.contains(nodeHash);
542+
// auto ghostContains = ghostQueue_.contains(nodeHash);
543+
auto ghostContains = false;
544544
return lruMutex_->lock_combine([this, &node, currTime, ghostContains]() {
545545
if (node.isInMMContainer()) {
546546
return false;
@@ -579,9 +579,16 @@ void MMS3FIFO::Container<T, HookPtr>::rebalanceForEviction() {
579579
auto expectedTinySize =
580580
static_cast<size_t>(config_.tinySizePercent * totalSize / 100);
581581

582+
auto rebalanceLimit = 5;
583+
auto rebalanceCount = 0;
584+
582585
// Promote until we find a victim, so iterator won't have to mutate the lists
583586
while (true) {
584587
bool tryTiny = tinyLru.size() >= expectedTinySize;
588+
rebalanceCount++;
589+
if (rebalanceCount > rebalanceLimit) {
590+
break;
591+
}
585592

586593
if (tryTiny) {
587594
// Tail of T
@@ -672,8 +679,8 @@ bool MMS3FIFO::Container<T, HookPtr>::remove(T& node) noexcept {
672679
return true;
673680
});
674681
if (result && isTiny_) {
675-
// Insert to ghost queue
676-
ghostQueue_.insert(hashNode(node));
682+
// // Insert to ghost queue
683+
// ghostQueue_.insert(hashNode(node));
677684
}
678685
return result;
679686
}
@@ -705,7 +712,7 @@ void MMS3FIFO::Container<T, HookPtr>::remove(LockedIterator& it) noexcept {
705712
if (it.l_.owns_lock()) {
706713
it.l_.unlock();
707714
}
708-
ghostQueue_.insert(hashNode(node));
715+
// ghostQueue_.insert(hashNode(node));
709716
}
710717
return;
711718
}

0 commit comments

Comments
 (0)