MCPcopy Create free account
hub / github.com/facebook/CacheLib / getStats

Method getStats

cachelib/interface/components/RAMCacheComponent.cpp:484–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482}
483
484CacheComponentStats RAMCacheComponent::getStats() const noexcept {
485 CacheComponentStats stats(*stats_);
486
487 // Populate numItems from pool stats
488 stats.numItems = cache_->getPoolStats(defaultPool_).numItems();
489
490 // Populate removeByKey throughput from CacheAllocator's counters
491 auto& allocatorStats = cache_->stats();
492 stats.removeByKey_.throughput_.calls_ = allocatorStats.numCacheRemoves.get();
493 stats.removeByKey_.throughput_.hits_ =
494 allocatorStats.numCacheRemoveRamHits.get();
495 stats.removeByKey_.throughput_.misses_ =
496 stats.removeByKey_.throughput_.calls_ -
497 stats.removeByKey_.throughput_.hits_;
498
499 // Populate allocate latency from CacheAllocator's counter
500 stats.allocate_.latency_ = allocatorStats.allocateLatency_.estimate();
501
502 auto now = std::chrono::steady_clock::now();
503 auto prev = std::exchange(lastStatsCollectionTime_, now);
504 cache_->exportStats(
505 /* statPrefix */ "",
506 std::chrono::duration_cast<std::chrono::seconds>(now - prev),
507 [&stats](folly::StringPiece name, uint64_t value) {
508 stats.extraStats_.insertCount(name.toString(), value);
509 });
510
511 return stats;
512}
513
514} // namespace facebook::cachelib::interface

Callers 1

CO_TYPED_TESTFunction · 0.45

Calls 7

estimateMethod · 0.80
insertCountMethod · 0.80
numItemsMethod · 0.45
getPoolStatsMethod · 0.45
getMethod · 0.45
exportStatsMethod · 0.45
toStringMethod · 0.45

Tested by 1

CO_TYPED_TESTFunction · 0.36