Skip to content

Commit

Permalink
[native] Add query init memory metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjialiang committed Apr 3, 2024
1 parent 190dceb commit 83798a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "presto_cpp/main/QueryContextManager.h"
#include <folly/executors/IOThreadPoolExecutor.h>
#include "presto_cpp/main/common/Configs.h"
#include "presto_cpp/main/common/Counters.h"
#include "velox/common/base/StatsReporter.h"
#include "velox/core/QueryConfig.h"
#include "velox/type/tz/TimeZoneMap.h"

Expand Down Expand Up @@ -191,6 +193,8 @@ std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
!SystemConfig::instance()->memoryArbitratorKind().empty()
? memory::MemoryReclaimer::create()
: nullptr);
RECORD_HISTOGRAM_METRIC_VALUE(
kCounterQueryMemoryPoolInitCapacity, pool->capacity());

auto queryCtx = std::make_shared<core::QueryCtx>(
driverExecutor_,
Expand Down
10 changes: 10 additions & 0 deletions presto-native-execution/presto_cpp/main/common/Counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ void registerPrestoMetrics() {
0,
62l * 1024 * 1024 * 1024, // max bucket value: 62GB
100);
DEFINE_HISTOGRAM_METRIC(
kCounterQueryMemoryPoolInitCapacity,
4l * 1024 * 1024, // 4MB bucket size
0,
1024l * 1024 * 1024, // 1GB max size
5,
50,
90,
95,
100);

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

Expand Down
4 changes: 3 additions & 1 deletion presto-native-execution/presto_cpp/main/common/Counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ constexpr folly::StringPiece kCounterMmapExternalMappedBytes{
/// NOTE: This applies only to MmapAllocator
constexpr folly::StringPiece kCounterMmapRawAllocBytesSmall{
"presto_cpp.mmap_raw_alloc_bytes_small"};

/// Peak number of bytes queued in PrestoExchangeSource waiting for consume.
constexpr folly::StringPiece kCounterExchangeSourcePeakQueuedBytes{
"presto_cpp.exchange_source_peak_queued_bytes"};
/// Initial capacity of the root memory pool of queries
constexpr folly::StringPiece kCounterQueryMemoryPoolInitCapacity{
"presto_cpp.query_memory_pool_init_capacity"};

/// ================== Memory Arbitrator Counters =================

Expand Down

0 comments on commit 83798a2

Please sign in to comment.