Skip to content

Commit 477f273

Browse files
committed
Multi-tier allocator patch
Part 2. ---------------------------- This patch introduces tryEvictToNextMemoryTier (the actual data movement), multi-tier stats and some additional multi-tier tests. - Includes MM2Q support for promotion
1 parent 763d364 commit 477f273

29 files changed

+1473
-185
lines changed

cachelib/allocator/Cache.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ void CacheBase::updateGlobalCacheStats(const std::string& statPrefix) const {
244244
statPrefix + "cache.size.configured",
245245
memStats.configuredRamCacheSize + memStats.nvmCacheSize);
246246

247+
//TODO: add specific per-tier counters
247248
const auto stats = getGlobalCacheStats();
248249

249250
// Eviction Stats
@@ -253,7 +254,8 @@ void CacheBase::updateGlobalCacheStats(const std::string& statPrefix) const {
253254
// from both ram and nvm, this is counted as a single eviction from cache.
254255
// Ram Evictions: item evicted from ram but it can be inserted into nvm
255256
const std::string ramEvictionKey = statPrefix + "ram.evictions";
256-
counters_.updateDelta(ramEvictionKey, stats.numEvictions);
257+
counters_.updateDelta(ramEvictionKey,
258+
std::accumulate(stats.numEvictions.begin(), stats.numEvictions.end(), 0));
257259
// Nvm Evictions: item evicted from nvm but it can be still in ram
258260
const std::string nvmEvictionKey = statPrefix + "nvm.evictions";
259261
counters_.updateDelta(nvmEvictionKey, stats.numNvmEvictions);
@@ -295,11 +297,11 @@ void CacheBase::updateGlobalCacheStats(const std::string& statPrefix) const {
295297
}
296298

297299
counters_.updateDelta(statPrefix + "cache.alloc_attempts",
298-
stats.allocAttempts);
300+
std::accumulate(stats.allocAttempts.begin(), stats.allocAttempts.end(),0));
299301
counters_.updateDelta(statPrefix + "cache.eviction_attempts",
300-
stats.evictionAttempts);
302+
std::accumulate(stats.evictionAttempts.begin(),stats.evictionAttempts.end(),0));
301303
counters_.updateDelta(statPrefix + "cache.alloc_failures",
302-
stats.allocFailures);
304+
std::accumulate(stats.allocFailures.begin(),stats.allocFailures.end(),0));
303305
counters_.updateDelta(statPrefix + "cache.invalid_allocs",
304306
stats.invalidAllocs);
305307

cachelib/allocator/Cache.h

+3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class CacheBase {
244244
// <Stat -> Count/Delta> maps
245245
mutable RateMap counters_;
246246

247+
// max number of tiers
248+
static const size_t kMaxTiers = 2;
249+
247250
protected:
248251
// move bytes from one pool to another. The source pool should be at least
249252
// _bytes_ in size.

0 commit comments

Comments
 (0)