Skip to content

Commit 2b8dafc

Browse files
[velox][memory] Adding threshold for logging memory pool allocations"
Summary: I added threshold for logging memory pool allocations": facebookincubator/velox#14437 In this adding I'm adding corresponding session property to configure the threshold. Differential Revision: D80066283
1 parent 0e7e4e0 commit 2b8dafc

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

presto-native-execution/presto_cpp/main/QueryContextManager.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
182182
// is still indexed by the query id.
183183
static std::atomic_uint64_t poolId{0};
184184
std::optional<memory::MemoryPool::DebugOptions> poolDbgOpts;
185-
const auto debugMemoryPoolNameRegex = queryConfig.debugMemoryPoolNameRegex();
186-
if (!debugMemoryPoolNameRegex.empty()) {
185+
if (auto debugMemoryPoolNameRegex = queryConfig.debugMemoryPoolNameRegex();
186+
!debugMemoryPoolNameRegex.empty()) {
187187
poolDbgOpts = memory::MemoryPool::DebugOptions{
188-
.debugPoolNameRegex = debugMemoryPoolNameRegex};
188+
.debugPoolWarnThresholdBytes =
189+
queryConfig.debugMemoryPoolWarnThresholdBytes(),
190+
.debugPoolNameRegex = std::move(debugMemoryPoolNameRegex)};
189191
}
190192
auto pool = memory::MemoryManager::getInstance()->addRootPool(
191193
fmt::format("{}_{}", queryId, poolId++),

presto-native-execution/presto_cpp/main/SessionProperties.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,18 @@ SessionProperties::SessionProperties() {
274274
QueryConfig::kDebugMemoryPoolNameRegex,
275275
c.debugMemoryPoolNameRegex());
276276

277+
addSessionProperty(
278+
kDebugMemoryPoolWarnThresholdBytes,
279+
"Warning threshold in bytes for debug memory pools. When set to a "
280+
"non-zero value, a warning will be logged once per memory pool when "
281+
"allocations cause the pool to exceed this threshold. This is useful for "
282+
"identifying memory usage patterns during debugging. A value of "
283+
"0 means no warning threshold is enforced.",
284+
BIGINT(),
285+
false,
286+
QueryConfig::kDebugMemoryPoolWarnThresholdBytes,
287+
std::to_string(c.debugMemoryPoolWarnThresholdBytes()));
288+
277289
addSessionProperty(
278290
kSelectiveNimbleReaderEnabled,
279291
"Temporary flag to control whether selective Nimble reader should be "

presto-native-execution/presto_cpp/main/SessionProperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ class SessionProperties {
184184
static constexpr const char* kDebugMemoryPoolNameRegex =
185185
"native_debug_memory_pool_name_regex";
186186

187+
static constexpr const char* kDebugMemoryPoolWarnThresholdBytes =
188+
"native_debug_memory_pool_warn_threshold_bytes";
189+
187190
/// Temporary flag to control whether selective Nimble reader should be used
188191
/// in this query or not. Will be removed after the selective Nimble reader
189192
/// is fully rolled out.

0 commit comments

Comments
 (0)