From 15780e09157be4f1764e8a7c0bdeca7b4c63337b Mon Sep 17 00:00:00 2001 From: Zac Wen Date: Wed, 1 May 2024 16:24:57 -0700 Subject: [PATCH] Record number of regions evicted in SsdCacheStats (#9686) Summary: Pull Request resolved: https://github.com/facebookincubator/velox/pull/9686 Reviewed By: xiaoxmeng Differential Revision: D56837945 Pulled By: zacw7 fbshipit-source-id: 7ad13d46e34b9b9ae70f90b4243f155c75c7aa80 --- velox/common/caching/SsdFile.cpp | 2 ++ velox/common/caching/SsdFile.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/velox/common/caching/SsdFile.cpp b/velox/common/caching/SsdFile.cpp index b4b7c37fa431..e977f610ebe3 100644 --- a/velox/common/caching/SsdFile.cpp +++ b/velox/common/caching/SsdFile.cpp @@ -347,6 +347,7 @@ bool SsdFile::growOrEvictLocked() { logEviction(candidates); clearRegionEntriesLocked(candidates); + stats_.regionsEvicted += candidates.size(); writableRegions_ = std::move(candidates); suspended_ = false; return true; @@ -532,6 +533,7 @@ void SsdFile::updateStats(SsdCacheStats& stats) const { } stats.entriesAgedOut += stats_.entriesAgedOut; stats.regionsAgedOut += stats_.regionsAgedOut; + stats.regionsEvicted += stats_.regionsEvicted; for (auto pins : regionPins_) { stats.numPins += pins; } diff --git a/velox/common/caching/SsdFile.h b/velox/common/caching/SsdFile.h index 8502a9d649a7..9b027cf9cb60 100644 --- a/velox/common/caching/SsdFile.h +++ b/velox/common/caching/SsdFile.h @@ -138,6 +138,7 @@ struct SsdCacheStats { bytesCached = tsanAtomicValue(other.bytesCached); entriesAgedOut = tsanAtomicValue(other.entriesAgedOut); regionsAgedOut = tsanAtomicValue(other.regionsAgedOut); + regionsEvicted = tsanAtomicValue(other.regionsEvicted); numPins = tsanAtomicValue(other.numPins); openFileErrors = tsanAtomicValue(other.openFileErrors); @@ -162,6 +163,7 @@ struct SsdCacheStats { tsan_atomic bytesCached{0}; tsan_atomic entriesAgedOut{0}; tsan_atomic regionsAgedOut{0}; + tsan_atomic regionsEvicted{0}; tsan_atomic numPins{0}; tsan_atomic openFileErrors{0};