diff --git a/cachelib/allocator/CacheAllocator-inl.h b/cachelib/allocator/CacheAllocator-inl.h index 3d279046a3..51188bede8 100644 --- a/cachelib/allocator/CacheAllocator-inl.h +++ b/cachelib/allocator/CacheAllocator-inl.h @@ -2904,7 +2904,7 @@ PoolStats CacheAllocator::getPoolStats(PoolId poolId) const { for (const ClassId cid : classIds) { uint64_t allocAttempts, evictionAttempts, allocFailures, fragmentationSize, classHits, chainedItemEvictions, - regularItemEvictions, numWritebacks = 0; + dsaEvictionSubmits, regularItemEvictions, numWritebacks = 0; MMContainerStat mmContainerStats; for (TierId tid = 0; tid < getNumTiers(); tid++) { allocAttempts += (*stats_.allocAttempts)[tid][poolId][cid].get(); @@ -2913,6 +2913,7 @@ PoolStats CacheAllocator::getPoolStats(PoolId poolId) const { fragmentationSize += (*stats_.fragmentationSize)[tid][poolId][cid].get(); classHits += (*stats_.cacheHits)[tid][poolId][cid].get(); chainedItemEvictions += (*stats_.chainedItemEvictions)[tid][poolId][cid].get(); + dsaEvictionSubmits += (*stats_.dsaEvictionSubmits)[tid][poolId][cid].get(); regularItemEvictions += (*stats_.regularItemEvictions)[tid][poolId][cid].get(); numWritebacks += (*stats_.numWritebacks)[tid][poolId][cid].get(); mmContainerStats += getMMContainerStat(tid, poolId, cid); @@ -2928,6 +2929,7 @@ PoolStats CacheAllocator::getPoolStats(PoolId poolId) const { fragmentationSize, classHits, chainedItemEvictions, + dsaEvictionSubmits, regularItemEvictions, numWritebacks, mmContainerStats}}); @@ -2982,6 +2984,7 @@ PoolStats CacheAllocator::getPoolStats(TierId tid, PoolId poolId) co (*stats_.fragmentationSize)[tid][poolId][cid].get(), classHits, (*stats_.chainedItemEvictions)[tid][poolId][cid].get(), + (*stats_.dsaEvictionSubmits)[tid][poolId][cid].get(), (*stats_.regularItemEvictions)[tid][poolId][cid].get(), (*stats_.numWritebacks)[tid][poolId][cid].get(), getMMContainerStat(tid, poolId, cid)}}); diff --git a/cachelib/allocator/CacheAllocator.h b/cachelib/allocator/CacheAllocator.h index 914fd03ede..253667fe77 100644 --- a/cachelib/allocator/CacheAllocator.h +++ b/cachelib/allocator/CacheAllocator.h @@ -2238,6 +2238,7 @@ auto& mmContainer = getMMContainer(tid, pid, cid); dml::data_view dstView = dml::make_view( reinterpret_cast(newItemHandles[index]->getMemory()), newItemHandles[index]->getSize()); + (*stats_.dsaEvictionSubmits)[tid][pid][cid].inc(); if (config_.dsaAsync) { dmlHandles.emplace_back( dml::submit(dml::mem_copy, srcView, dstView)); diff --git a/cachelib/allocator/CacheStats.cpp b/cachelib/allocator/CacheStats.cpp index 24fc8c6c1a..8df78f39df 100644 --- a/cachelib/allocator/CacheStats.cpp +++ b/cachelib/allocator/CacheStats.cpp @@ -29,6 +29,7 @@ void Stats::init() { fragmentationSize = std::make_unique(); allocFailures = std::make_unique(); chainedItemEvictions = std::make_unique(); + dsaEvictionSubmits = std::make_unique(); regularItemEvictions = std::make_unique(); numWritebacks = std::make_unique(); auto initToZero = [](auto& a) { @@ -46,6 +47,7 @@ void Stats::init() { initToZero(*allocFailures); initToZero(*fragmentationSize); initToZero(*chainedItemEvictions); + initToZero(*dsaEvictionSubmits); initToZero(*regularItemEvictions); initToZero(*numWritebacks); @@ -57,7 +59,7 @@ struct SizeVerify {}; void Stats::populateGlobalCacheStats(GlobalCacheStats& ret) const { #ifndef SKIP_SIZE_VERIFY - SizeVerify a = SizeVerify<16192>{}; + SizeVerify a = SizeVerify<16208>{}; std::ignore = a; #endif ret.numCacheGets = numCacheGets.get(); @@ -151,6 +153,7 @@ void Stats::populateGlobalCacheStats(GlobalCacheStats& ret) const { ret.evictionAttempts = accum(*evictionAttempts); ret.allocFailures = accum(*allocFailures); auto chainedEvictions = accum(*chainedItemEvictions); + ret.dsaEvictionSubmits = accum(*dsaEvictionSubmits); auto regularEvictions = accum(*regularItemEvictions); for (TierId tid = 0; tid < chainedEvictions.size(); tid++) { ret.numEvictions.push_back(chainedEvictions[tid] + regularEvictions[tid]); @@ -223,6 +226,7 @@ PoolStats& PoolStats::operator+=(const PoolStats& other) { d.numHits += s.numHits; d.numWritebacks += s.numWritebacks; d.chainedItemEvictions += s.chainedItemEvictions; + d.dsaEvictionSubmits += s.dsaEvictionSubmits; d.regularItemEvictions += s.regularItemEvictions; } diff --git a/cachelib/allocator/CacheStats.h b/cachelib/allocator/CacheStats.h index 91daf6f80b..ec6aec5eed 100644 --- a/cachelib/allocator/CacheStats.h +++ b/cachelib/allocator/CacheStats.h @@ -122,6 +122,9 @@ struct CacheStat { // number of evictions from this class id that was of a chained item uint64_t chainedItemEvictions{0}; + // number of items submitted via DSA for eviction + uint64_t dsaEvictionSubmits{0}; + // number of regular items that were evicted from this classId uint64_t regularItemEvictions{0}; @@ -462,6 +465,9 @@ struct GlobalCacheStats { // number of failures to allocate an item due to internal error std::vector allocFailures; + // number of dsa evictions submits across all the pools in the cache. + std::vector dsaEvictionSubmits; + // number of evictions across all the pools in the cache. std::vector numEvictions; diff --git a/cachelib/allocator/CacheStatsInternal.h b/cachelib/allocator/CacheStatsInternal.h index ef41ea7bbc..ba05efbad0 100644 --- a/cachelib/allocator/CacheStatsInternal.h +++ b/cachelib/allocator/CacheStatsInternal.h @@ -230,6 +230,7 @@ struct Stats { std::unique_ptr allocFailures{}; std::unique_ptr fragmentationSize{}; std::unique_ptr chainedItemEvictions{}; + std::unique_ptr dsaEvictionSubmits{}; std::unique_ptr regularItemEvictions{}; std::unique_ptr numWritebacks{}; diff --git a/cachelib/cachebench/cache/Cache-inl.h b/cachelib/cachebench/cache/Cache-inl.h index a008036454..be3230862f 100644 --- a/cachelib/cachebench/cache/Cache-inl.h +++ b/cachelib/cachebench/cache/Cache-inl.h @@ -677,6 +677,7 @@ Stats Cache::getStats() const { cacheStats.promotionStats.runCount; ret.evictAttempts = cacheStats.evictionAttempts; + ret.dsaEvictionSubmits = cacheStats.dsaEvictionSubmits; ret.allocAttempts = cacheStats.allocAttempts; ret.allocFailures = cacheStats.allocFailures; diff --git a/cachelib/cachebench/cache/CacheStats.h b/cachelib/cachebench/cache/CacheStats.h index 4034e1249b..ced0acec9f 100644 --- a/cachelib/cachebench/cache/CacheStats.h +++ b/cachelib/cachebench/cache/CacheStats.h @@ -54,6 +54,7 @@ struct Stats { BackgroundPromotionStats backgndPromoStats; ReaperStats reaperStats; + std::vector dsaEvictionSubmits; std::vector numEvictions; std::vector numWritebacks; std::vector numCacheHits; @@ -167,8 +168,8 @@ struct Stats { << std::endl; } for (TierId tid = 0; tid < nTiers; tid++) { - out << folly::sformat("Tier {} Evictions : {:,} Writebacks: {:,} Success: {:.2f}%", - tid, numEvictions[tid], numWritebacks[tid], + out << folly::sformat("Tier {} Evictions : {:,} DSA submits: {:,} Writebacks: {:,} Success: {:.2f}%", + tid, numEvictions[tid], dsaEvictionSubmits[tid], numWritebacks[tid], invertPctFn(numEvictions[tid] - numWritebacks[tid], numEvictions[tid])) << std::endl; } auto foreachAC = [&](auto &map, auto cb) {