Skip to content

Commit

Permalink
Add stats report daemon to Velox
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang committed May 6, 2024
1 parent e38079f commit 37549d5
Show file tree
Hide file tree
Showing 5 changed files with 769 additions and 3 deletions.
225 changes: 225 additions & 0 deletions velox/common/base/Counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,231 @@ void registerVeloxMetrics() {
DEFINE_HISTOGRAM_METRIC(
kMetricCacheShrinkTimeMs, 10'000, 0, 100'000, 50, 90, 99, 100);

/// ================== Memory Allocator Counters =================

// Number of bytes currently mapped in MemoryAllocator. These bytes represent
// the bytes that are either currently being allocated or were in the past
// allocated, not yet been returned back to the operating system, in the
// form of 'Allocation' or 'ContiguousAllocation'.
DEFINE_METRIC(kMetricMappedMemoryBytes, facebook::velox::StatType::AVG);

// Number of bytes currently allocated (used) from MemoryAllocator in the form
// of 'Allocation' or 'ContiguousAllocation'.
DEFINE_METRIC(kMetricAllocatedMemoryBytes, facebook::velox::StatType::AVG);

// Number of bytes currently mapped in MmapAllocator, in the form of
// 'ContiguousAllocation'.
//
// NOTE: This applies only to MmapAllocator
DEFINE_METRIC(kMetricMmapExternalMappedBytes, facebook::velox::StatType::AVG);

// Number of bytes currently allocated from MmapAllocator directly from raw
// allocateBytes() interface, and internally allocated by malloc. Only small
// chunks of memory are delegated to malloc
//
// NOTE: This applies only to MmapAllocator
DEFINE_METRIC(kMetricMmapRawAllocBytesSmall, facebook::velox::StatType::AVG);

/// ================== AsyncDataCache Counters =================

// Max possible age of AsyncDataCache and SsdCache entries since the raw file
// was opened to load the cache.
DEFINE_METRIC(kMetricCacheMaxAgeSecs, facebook::velox::StatType::AVG);

// Total number of cache entries.
DEFINE_METRIC(kMetricMemoryCacheNumEntries, facebook::velox::StatType::AVG);

// Total number of cache entries that do not cache anything.
DEFINE_METRIC(
kMetricMemoryCacheNumEmptyEntries, facebook::velox::StatType::AVG);

// Total number of cache entries that are pinned for shared access.
DEFINE_METRIC(
kMetricMemoryCacheNumSharedEntries, facebook::velox::StatType::AVG);

// Total number of cache entries that are pinned for exclusive access.
DEFINE_METRIC(
kMetricMemoryCacheNumExclusiveEntries, facebook::velox::StatType::AVG);

// Total number of cache entries that are being or have been prefetched but
// have not been hit.
DEFINE_METRIC(
kMetricMemoryCacheNumPrefetchedEntries, facebook::velox::StatType::AVG);

// Total number of bytes of the cached data that is much smaller than a
// 'MappedMemory' page (AsyncDataCacheEntry::kTinyDataSize).
DEFINE_METRIC(
kMetricMemoryCacheTotalTinyBytes, facebook::velox::StatType::AVG);

// Total number of bytes of the cached data excluding
// 'kMetricMemoryCacheTotalTinyBytes'.
DEFINE_METRIC(
kMetricMemoryCacheTotalLargeBytes, facebook::velox::StatType::AVG);

// Total unused capacity bytes in 'kMetricMemoryCacheTotalTinyBytes'.
DEFINE_METRIC(
kMetricMemoryCacheTotalTinyPaddingBytes, facebook::velox::StatType::AVG);

// Total unused capacity bytes in 'kMetricMemoryCacheTotalLargeBytes'.
DEFINE_METRIC(
kMetricMemoryCacheTotalLargePaddingBytes, facebook::velox::StatType::AVG);

// Total bytes of cache entries in prefetch state.
DEFINE_METRIC(
kMetricMemoryCacheTotalPrefetchBytes, facebook::velox::StatType::AVG);

// Sum of scores of evicted entries. This serves to infer an average lifetime
// for entries in cache.
DEFINE_METRIC(
kMetricMemoryCacheSumEvictScore, facebook::velox::StatType::AVG);

// Cumulative number of hits (saved IO). The first hit to a prefetched entry
// does not count.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeHit, facebook::velox::StatType::AVG);

// Number of hits (saved IO) since last counter retrieval. The first hit to a
// prefetched entry does not count.
DEFINE_METRIC(kMetricMemoryCacheNumHit, facebook::velox::StatType::AVG);

// Cumulative amount of hit bytes (saved IO). The first hit to a prefetched
// entry does not count.
DEFINE_METRIC(
kMetricMemoryCacheCumulativeHitBytes, facebook::velox::StatType::AVG);

// Amount of hit bytes (saved IO) since last counter retrieval. The first hit
// to a prefetched entry does not count.
DEFINE_METRIC(kMetricMemoryCacheHitBytes, facebook::velox::StatType::AVG);

// Cumulative number of new entries created.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeNew, facebook::velox::StatType::AVG);

// Number of new entries created since last counter retrieval.
DEFINE_METRIC(kMetricMemoryCacheNumNew, facebook::velox::StatType::AVG);

// Cumulative number of times a valid entry was removed in order to make
// space.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeEvict, facebook::velox::StatType::AVG);

// Number of times a valid entry was removed in order to make space, since
// last counter retrieval.
DEFINE_METRIC(kMetricMemoryCacheNumEvict, facebook::velox::StatType::AVG);

// Cumulative number of entries considered for evicting.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeEvictChecks,
facebook::velox::StatType::AVG);

// Number of entries considered for evicting, since last counter retrieval.
DEFINE_METRIC(
kMetricMemoryCacheNumEvictChecks, facebook::velox::StatType::AVG);

// Cumulative number of times a user waited for an entry to transit from
// exclusive to shared mode.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeWaitExclusive,
facebook::velox::StatType::AVG);

// Number of times a user waited for an entry to transit from exclusive to
// shared mode, since last counter retrieval.
DEFINE_METRIC(
kMetricMemoryCacheNumWaitExclusive, facebook::velox::StatType::AVG);

// Cumulative clocks spent in allocating or freeing memory for backing cache
// entries.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeAllocClocks,
facebook::velox::StatType::AVG);

// Clocks spent in allocating or freeing memory for backing cache entries,
// since last counter retrieval
DEFINE_METRIC(
kMetricMemoryCacheNumAllocClocks, facebook::velox::StatType::AVG);

// Cumulative number of AsyncDataCache entries that are aged out and evicted
// given configured TTL.
DEFINE_METRIC(
kMetricMemoryCacheNumCumulativeAgedOutEntries,
facebook::velox::StatType::AVG);

// Number of AsyncDataCache entries that are aged out and evicted
// given configured TTL.
DEFINE_METRIC(
kMetricMemoryCacheNumAgedOutEntries, facebook::velox::StatType::AVG);

/// ================== SsdCache Counters ==================

// Number of regions currently cached by SSD.
DEFINE_METRIC(kMetricSsdCacheCachedRegions, facebook::velox::StatType::AVG);

// Number of entries currently cached by SSD.
DEFINE_METRIC(kMetricSsdCacheCachedEntries, facebook::velox::StatType::AVG);

// Total bytes currently cached by SSD.
DEFINE_METRIC(kMetricSsdCacheCachedBytes, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeReadEntries, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeReadBytes, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeWrittenEntries, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeWrittenBytes, facebook::velox::StatType::AVG);

// Cumulative number of SsdCache entries that are aged out and evicted given
// configured TTL.
DEFINE_METRIC(
kMetricSsdCacheCumulativeAgedOutEntries, facebook::velox::StatType::AVG);

// Cumulative number of SsdCache regions that are aged out and evicted given
// configured TTL.
DEFINE_METRIC(
kMetricSsdCacheCumulativeAgedOutRegions, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeOpenSsdErrors, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeOpenCheckpointErrors,
facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeOpenLogErrors, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeDeleteCheckpointErrors,
facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeGrowFileErrors, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeWriteSsdErrors, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeWriteCheckpointErrors,
facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeReadSsdErrors, facebook::velox::StatType::AVG);

DEFINE_METRIC(
kMetricSsdCacheCumulativeReadCheckpointErrors,
facebook::velox::StatType::AVG);

DEFINE_METRIC(kMetricSsdCacheCheckpointsRead, facebook::velox::StatType::SUM);

DEFINE_METRIC(
kMetricSsdCacheCheckpointsWritten, facebook::velox::StatType::SUM);

DEFINE_METRIC(kMetricSsdCacheRegionsEvicted, facebook::velox::StatType::SUM);

/// ================== Memory Arbitration Counters =================

// The number of arbitration requests.
Expand Down
160 changes: 160 additions & 0 deletions velox/common/base/Counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,164 @@ constexpr folly::StringPiece kMetricArbitratorAbortedCount{

constexpr folly::StringPiece kMetricArbitratorFailuresCount{
"velox.arbitrator_failures_count"};

constexpr folly::StringPiece kMetricMappedMemoryBytes{
"velox.mapped_memory_bytes"};

constexpr folly::StringPiece kMetricAllocatedMemoryBytes{
"velox.allocated_memory_bytes"};

constexpr folly::StringPiece kMetricMmapExternalMappedBytes{
"velox.mmap_external_mapped_bytes"};

constexpr folly::StringPiece kMetricMmapRawAllocBytesSmall{
"velox.mmap_raw_alloc_bytes_small"};

constexpr folly::StringPiece kMetricCacheMaxAgeSecs{"velox.cache_max_age_secs"};

constexpr folly::StringPiece kMetricMemoryCacheNumEntries{
"velox.memory_cache_num_entries"};

constexpr folly::StringPiece kMetricMemoryCacheNumEmptyEntries{
"velox.memory_cache_num_empty_entries"};

constexpr folly::StringPiece kMetricMemoryCacheNumSharedEntries{
"velox.memory_cache_num_shared_entries"};

constexpr folly::StringPiece kMetricMemoryCacheNumExclusiveEntries{
"velox.memory_cache_num_exclusive_entries"};

constexpr folly::StringPiece kMetricMemoryCacheNumPrefetchedEntries{
"velox.memory_cache_num_prefetched_entries"};

constexpr folly::StringPiece kMetricMemoryCacheTotalTinyBytes{
"velox.memory_cache_total_tiny_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheTotalLargeBytes{
"velox.memory_cache_total_large_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheTotalTinyPaddingBytes{
"velox.memory_cache_total_tiny_padding_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheTotalLargePaddingBytes{
"velox.memory_cache_total_large_padding_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheTotalPrefetchBytes{
"velox.memory_cache_total_prefetched_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheSumEvictScore{
"velox.memory_cache_sum_evict_score"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeHit{
"velox.memory_cache_num_cumulative_hit"};

constexpr folly::StringPiece kMetricMemoryCacheNumHit{
"velox.memory_cache_num_hit"};

constexpr folly::StringPiece kMetricMemoryCacheCumulativeHitBytes{
"velox.memory_cache_cumulative_hit_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheHitBytes{
"velox.memory_cache_hit_bytes"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeNew{
"velox.memory_cache_num_cumulative_new"};

constexpr folly::StringPiece kMetricMemoryCacheNumNew{
"velox.memory_cache_num_new"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeEvict{
"velox.memory_cache_num_cumulative_evict"};

constexpr folly::StringPiece kMetricMemoryCacheNumEvict{
"velox.memory_cache_num_evict"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeEvictChecks{
"velox.memory_cache_num_cumulative_evict_checks"};

constexpr folly::StringPiece kMetricMemoryCacheNumEvictChecks{
"velox.memory_cache_num_evict_checks"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeWaitExclusive{
"velox.memory_cache_num_cumulative_wait_exclusive"};

constexpr folly::StringPiece kMetricMemoryCacheNumWaitExclusive{
"velox.memory_cache_num_wait_exclusive"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeAllocClocks{
"velox.memory_cache_num_cumulative_alloc_clocks"};

constexpr folly::StringPiece kMetricMemoryCacheNumAllocClocks{
"velox.memory_cache_num_alloc_clocks"};

constexpr folly::StringPiece kMetricMemoryCacheNumCumulativeAgedOutEntries{
"velox.memory_cache_num_cumulative_aged_out_entries"};

constexpr folly::StringPiece kMetricMemoryCacheNumAgedOutEntries{
"velox.memory_cache_num_aged_out_entries"};

/// ================== SsdCache Counters ==================

constexpr folly::StringPiece kMetricSsdCacheCachedRegions{
"velox.ssd_cache_cached_regions"};

constexpr folly::StringPiece kMetricSsdCacheCachedEntries{
"velox.ssd_cache_cached_entries"};

constexpr folly::StringPiece kMetricSsdCacheCachedBytes{
"velox.ssd_cache_cached_bytes"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeReadEntries{
"velox.ssd_cache_cumulative_read_entries"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeReadBytes{
"velox.ssd_cache_cumulative_read_bytes"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeWrittenEntries{
"velox.ssd_cache_cumulative_written_entries"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeWrittenBytes{
"velox.ssd_cache_cumulative_written_bytes"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeAgedOutEntries{
"velox.ssd_cache_cumulative_aged_out_entries"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeAgedOutRegions{
"velox.ssd_cache_cumulative_aged_out_regions"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeOpenSsdErrors{
"velox.ssd_cache_cumulative_open_ssd_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeOpenCheckpointErrors{
"velox.ssd_cache_cumulative_open_checkpoint_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeOpenLogErrors{
"velox.ssd_cache_cumulative_open_log_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeDeleteCheckpointErrors{
"velox.ssd_cache_cumulative_delete_checkpoint_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeGrowFileErrors{
"velox.ssd_cache_cumulative_grow_file_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeWriteSsdErrors{
"velox.ssd_cache_cumulative_write_ssd_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeWriteCheckpointErrors{
"velox.ssd_cache_cumulative_write_checkpoint_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeReadSsdErrors{
"velox.ssd_cache_cumulative_read_ssd_errors"};

constexpr folly::StringPiece kMetricSsdCacheCumulativeReadCheckpointErrors{
"velox.ssd_cache_cumulative_read_checkpoint_errors"};

constexpr folly::StringPiece kMetricSsdCacheCheckpointsRead{
"velox.ssd_cache_checkpoints_read"};

constexpr folly::StringPiece kMetricSsdCacheCheckpointsWritten{
"velox.ssd_cache_checkpoints_written"};

constexpr folly::StringPiece kMetricSsdCacheRegionsEvicted{
"velox.ssd_cache_regions_evicted"};
} // namespace facebook::velox
Loading

0 comments on commit 37549d5

Please sign in to comment.