diff --git a/cachelib/allocator/BackgroundEvictor-inl.h b/cachelib/allocator/BackgroundEvictor-inl.h index b4e07d1dde..4b99d04bc7 100644 --- a/cachelib/allocator/BackgroundEvictor-inl.h +++ b/cachelib/allocator/BackgroundEvictor-inl.h @@ -81,12 +81,12 @@ void BackgroundEvictor::checkAndRun() { tid,pid,cid,batch); evictions += evicted; - const size_t cid_id = (size_t)mpStats.acStats.at(cid).allocSize; - auto it = evictions_per_class_.find(cid_id); + //const size_t cid_id = (size_t)mpStats.acStats.at(cid).allocSize; + auto it = evictions_per_class_.find(cid); if (it != evictions_per_class_.end()) { it->second += evicted; - } else { - evictions_per_class_[cid_id] = 0; + } else if (evicted > 0) { + evictions_per_class_[cid] = evicted; } } diff --git a/cachelib/allocator/BackgroundPromoter-inl.h b/cachelib/allocator/BackgroundPromoter-inl.h index fbb06b168e..8bd3e93e63 100644 --- a/cachelib/allocator/BackgroundPromoter-inl.h +++ b/cachelib/allocator/BackgroundPromoter-inl.h @@ -80,12 +80,12 @@ void BackgroundPromoter::checkAndRun() { tid,pid,cid,batch); promotions += promoted; - const size_t cid_id = (size_t)mpStats.acStats.at(cid).allocSize; - auto it = promotions_per_class_.find(cid_id); + //const size_t cid_id = (size_t)mpStats.acStats.at(cid).allocSize; + auto it = promotions_per_class_.find(cid); if (it != promotions_per_class_.end()) { it->second += promoted; - } else { - promotions_per_class_[cid_id] = 0; + } else if (promoted > 0) { + promotions_per_class_[cid] = promoted; } } diff --git a/cachelib/allocator/CacheAllocator.h b/cachelib/allocator/CacheAllocator.h index e1d63d256f..37b828585e 100644 --- a/cachelib/allocator/CacheAllocator.h +++ b/cachelib/allocator/CacheAllocator.h @@ -1899,7 +1899,7 @@ class CacheAllocator : public CacheBase { size_t traverseAndPromoteItems(unsigned int tid, unsigned int pid, unsigned int cid, size_t batch) { auto& mmContainer = getMMContainer(tid, pid, cid); - size_t promotions; + size_t promotions = 0; std::vector candidates; candidates.reserve(batch);