Skip to content

Commit bd69c27

Browse files
committed
no online eviction
1 parent f9e8274 commit bd69c27

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

cachelib/allocator/CacheAllocator-inl.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,10 @@ CacheAllocator<CacheTrait>::allocateInternalTier(TierId tid,
472472
tid, pid, cid, backgroundEvictor_.size())]
473473
->wakeUp();
474474
}
475-
476-
if (memory == nullptr) {
477-
if (!evict) {
478-
return {};
479-
}
475+
476+
if ((memory == nullptr && !evict) || (memory == nullptr && config_.noOnlineEviction)) {
477+
return {};
478+
} else if (memory == nullptr) {
480479
memory = findEviction(tid, pid, cid);
481480
}
482481

@@ -1959,7 +1958,7 @@ CacheAllocator<CacheTrait>::getNextCandidate(TierId tid,
19591958
bool isExpired = false;
19601959
bool chainedItem = false;
19611960
auto& mmContainer = getMMContainer(tid, pid, cid);
1962-
bool lastTier = tid+1 >= getNumTiers();
1961+
bool lastTier = tid+1 >= getNumTiers() || config_.noOnlineEviction;
19631962

19641963
mmContainer.withEvictionIterator([this, tid, pid, cid, &candidate,
19651964
&toRecycle, &toRecycleParent,

cachelib/allocator/CacheAllocatorConfig.h

+11
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ class CacheAllocatorConfig {
315315

316316
// Insert items to first free memory tier
317317
CacheAllocatorConfig& enableInsertToFirstFreeTier();
318+
319+
CacheAllocatorConfig& enableNoOnlineEviction();
318320

319321
// Passes in a callback to initialize an event tracker when the allocator
320322
// starts
@@ -547,6 +549,8 @@ class CacheAllocatorConfig {
547549
// from the bottom one if memory cache is full
548550
bool insertToFirstFreeTier = false;
549551

552+
bool noOnlineEviction = false;
553+
550554
// the number of tries to search for an item to evict
551555
// 0 means it's infinite
552556
unsigned int evictionSearchTries{50};
@@ -687,6 +691,12 @@ CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::enableInsertToFirstFreeTier()
687691
return *this;
688692
}
689693

694+
template <typename T>
695+
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::enableNoOnlineEviction() {
696+
noOnlineEviction = true;
697+
return *this;
698+
}
699+
690700
template <typename T>
691701
CacheAllocatorConfig<T>& CacheAllocatorConfig<T>::setCacheName(
692702
const std::string& _cacheName) {
@@ -1269,6 +1279,7 @@ std::map<std::string, std::string> CacheAllocatorConfig<T>::serialize() const {
12691279
configMap["delayCacheWorkersStart"] =
12701280
delayCacheWorkersStart ? "true" : "false";
12711281
configMap["insertToFirstFreeTier"] = std::to_string(insertToFirstFreeTier);
1282+
configMap["noOnlineEviction"] = std::to_string(noOnlineEviction);
12721283
mergeWithPrefix(configMap, throttleConfig.serialize(), "throttleConfig");
12731284
mergeWithPrefix(configMap,
12741285
chainedItemAccessConfig.serialize(),

cachelib/cachebench/cache/Cache-inl.h

+1
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

+1
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

+1
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)