Skip to content

Commit be96378

Browse files
committed
fix: evict expired cache cells even when the high watermark has not been reached
Signed-off-by: Shawn Wang <[email protected]>
1 parent 2c8ee18 commit be96378

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

src/cachinglayer/Utils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ getSystemMemoryInfo() {
227227

228228
if (container_limit > 0 && container_limit < host_memory) {
229229
info.total_bytes = container_limit;
230-
LOG_DEBUG("[MCL] Using container memory limit: {}", FormatBytes(container_limit));
231230
} else {
232231
info.total_bytes = host_memory;
233232
if (container_limit > host_memory) {

src/cachinglayer/lrucache/DList.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ DList::evictionLoop() {
191191
: 0,
192192
};
193193
const auto min_eviction = ResourceUsage{0, 0};
194-
if (eviction_target.AnyGTZero()) {
194+
const auto evicted =
195195
tryEvict(eviction_target, min_eviction, eviction_config_.cache_cell_unaccessed_survival_time.count() > 0);
196+
if (evicted.AnyGTZero()) {
197+
notifyWaitingRequests();
196198
}
197-
notifyWaitingRequests();
198199
}
199200
}
200201

@@ -326,7 +327,7 @@ DList::tryEvict(const ResourceUsage& expected_eviction, const ResourceUsage& min
326327
}
327328
if (!size_to_evict.AnyGTZero()) {
328329
// Do not spam log during eviction loop.
329-
if (!evict_expired_items) {
330+
if (!evict_expired_items && expected_eviction.AnyGTZero()) {
330331
LOG_DEBUG(
331332
"[MCL] No items can be evicted, expected_eviction {}, "
332333
"min_eviction {}, giving up eviction. Current usage: {}",
@@ -378,21 +379,9 @@ DList::tryEvict(const ResourceUsage& expected_eviction, const ResourceUsage& min
378379
});
379380

380381
LOG_TRACE("[MCL] Logically evicted size: {}", size_to_evict.ToString());
382+
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::MEMORY).Increment(size_to_evict.memory_bytes);
383+
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::DISK).Increment(size_to_evict.file_bytes);
381384

382-
switch (size_to_evict.storage_type()) {
383-
case StorageType::MEMORY:
384-
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::MEMORY).Increment(size_to_evict.memory_bytes);
385-
break;
386-
case StorageType::DISK:
387-
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::DISK).Increment(size_to_evict.file_bytes);
388-
break;
389-
case StorageType::MIXED:
390-
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::MEMORY).Increment(size_to_evict.memory_bytes);
391-
cachinglayer::monitor::cache_evicted_bytes_total(StorageType::DISK).Increment(size_to_evict.file_bytes);
392-
break;
393-
default:
394-
ThrowInfo(ErrorCode::UnexpectedError, "Unknown StorageType");
395-
}
396385
return size_to_evict;
397386
}
398387

0 commit comments

Comments
 (0)