Skip to content

Commit b35c183

Browse files
byahn0996facebook-github-bot
authored andcommitted
Adding excessive read bytes stat
Summary: Adding a stat for excessive read bytes when we read more than the actual size Reviewed By: haowu14 Differential Revision: D73965289 fbshipit-source-id: cad27ad5692c6cf066216f537582e4db50c0ad82
1 parent 32fd6c1 commit b35c183

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

cachelib/allocator/nvmcache/tests/NvmCacheTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,7 @@ TEST_F(NvmCacheTest, NavyStats) {
16381638
EXPECT_TRUE(cs("navy_bc_reinsertions"));
16391639
EXPECT_TRUE(cs("navy_bc_reinsertion_bytes"));
16401640
EXPECT_TRUE(cs("navy_bc_reinsertion_errors"));
1641+
EXPECT_TRUE(cs("navy_bc_excessive_read_bytes"));
16411642
EXPECT_TRUE(cs("navy_bc_lookup_for_item_destructor_errors"));
16421643
EXPECT_TRUE(cs("navy_bc_reclaim_entry_header_checksum_errors"));
16431644
EXPECT_TRUE(cs("navy_bc_reclaim_value_checksum_errors"));

cachelib/navy/block_cache/BlockCache.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ Status BlockCache::readEntry(const RegionDescriptor& readDesc,
764764
uint32_t size = serializedSize(desc.keySize, desc.valueSize);
765765
if (buffer.size() > size) {
766766
// Read more than actual size. Trim the invalid data in the beginning
767+
excessiveReadBytes_.add(buffer.size() - size);
767768
buffer.trimStart(buffer.size() - size);
768769
} else if (buffer.size() < size) {
769770
// Read less than actual size. Read again with proper buffer.
@@ -876,6 +877,8 @@ void BlockCache::getCounters(const CounterVisitor& visitor) const {
876877
CounterVisitor::CounterType::RATE);
877878
visitor("navy_bc_reinsertion_errors", reinsertionErrorCount_.get(),
878879
CounterVisitor::CounterType::RATE);
880+
visitor("navy_bc_excessive_read_bytes", excessiveReadBytes_.get(),
881+
CounterVisitor::CounterType::RATE);
879882
visitor("navy_bc_lookup_for_item_destructor_errors",
880883
lookupForItemDestructorErrorCount_.get(),
881884
CounterVisitor::CounterType::RATE);

cachelib/navy/block_cache/BlockCache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ class BlockCache final : public Engine {
414414
mutable AtomicCounter cleanupEntryHeaderChecksumErrorCount_;
415415
mutable AtomicCounter cleanupValueChecksumErrorCount_;
416416
mutable AtomicCounter lookupForItemDestructorErrorCount_;
417+
mutable AtomicCounter excessiveReadBytes_;
417418
};
418419
} // namespace navy
419420
} // namespace cachelib

0 commit comments

Comments
 (0)