Skip to content

Commit c67df92

Browse files
committed
no online eviction
1 parent e329395 commit c67df92

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

cachelib/allocator/CacheAllocator-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ CacheAllocator<CacheTrait>::allocateInternalTier(TierId tid,
478478
backgroundEvictor_[backgroundWorkerId(tid, pid, cid, backgroundEvictor_.size())]->wakeUp();
479479
}
480480

481-
if (memory == nullptr && !evict) {
481+
if ((memory == nullptr && !evict) || (memory == nullptr && config_.noOnlineEviction)) {
482482
return {};
483483
} else if (memory == nullptr) {
484484
memory = findEviction(tid, pid, cid);
@@ -2033,7 +2033,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
20332033
Item* syncItem = nullptr;
20342034
bool chainedItem = false;
20352035
auto& mmContainer = getMMContainer(tid, pid, cid);
2036-
bool lastTier = tid+1 >= getNumTiers();
2036+
bool lastTier = tid+1 >= getNumTiers() || config_.noOnlineEviction;
20372037

20382038
mmContainer.withEvictionIterator([this, tid, pid, cid, &candidate,
20392039
&toRecycle, &toRecycleParent, &syncItem,

cachelib/allocator/CacheAllocatorConfig.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ class CacheAllocatorConfig {
313313

314314
// Insert items to first free memory tier
315315
CacheAllocatorConfig& enableInsertToFirstFreeTier();
316+
317+
CacheAllocatorConfig& enableNoOnlineEviction();
316318

317319
// Passes in a callback to initialize an event tracker when the allocator
318320
// starts
@@ -535,6 +537,8 @@ class CacheAllocatorConfig {
535537
// from the bottom one if memory cache is full
536538
bool insertToFirstFreeTier = false;
537539

540+
bool noOnlineEviction = false;
541+
538542
// the number of tries to search for an item to evict
539543
// 0 means it's infinite
540544
unsigned int evictionSearchTries{50};
@@ -676,6 +680,12 @@ CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::enableInsertToFirstFreeTier()
676680
return *this;
677681
}
678682

683+
template <typename T>
684+
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::enableNoOnlineEviction() {
685+
noOnlineEviction = true;
686+
return *this;
687+
}
688+
679689
template <typename T>
680690
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::setCacheName(
681691
const std::string& _cacheName) {
@@ -1256,6 +1266,7 @@ std::map<std::string, std::string> CacheAllocatorConfig<T>::serialize() const {
12561266
configMap["delayCacheWorkersStart"] =
12571267
delayCacheWorkersStart ? "true" : "false";
12581268
configMap["insertToFirstFreeTier"] = std::to_string(insertToFirstFreeTier);
1269+
configMap["noOnlineEviction"] = std::to_string(noOnlineEviction);
12591270
mergeWithPrefix(configMap, throttleConfig.serialize(), "throttleConfig");
12601271
mergeWithPrefix(configMap,
12611272
chainedItemAccessConfig.serialize(),

cachelib/cachebench/cache/Cache-inl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Cache<Allocator>::Cache(const CacheConfig& config,
105105
}
106106

107107
allocatorConfig_.insertToFirstFreeTier = config_.insertToFirstFreeTier;
108+
allocatorConfig_.noOnlineEviction = config_.noOnlineEviction;
108109

109110
auto cleanupGuard = folly::makeGuard([&] {
110111
if (!nvmCacheFilePath_.empty()) {

cachelib/cachebench/util/CacheConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ CacheConfig::CacheConfig(const folly::dynamic& configJson) {
5151
JSONSetVal(configJson, useCombinedLockForIterators);
5252

5353
JSONSetVal(configJson, insertToFirstFreeTier);
54+
JSONSetVal(configJson, noOnlineEviction);
5455

5556
JSONSetVal(configJson, lru2qHotPct);
5657
JSONSetVal(configJson, lru2qColdPct);

cachelib/cachebench/util/CacheConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct CacheConfig : public JSONConfig {
9999
bool useCombinedLockForIterators{true};
100100

101101
bool insertToFirstFreeTier{false};
102+
bool noOnlineEviction{false};
102103

103104
// LRU param
104105
uint64_t lruIpSpec{0};

0 commit comments

Comments
 (0)