Skip to content

Commit af7ef94

Browse files
tanjialiangpradeepvaka
authored andcommitted
Add memory pool debug regex
1 parent b9ef92b commit af7ef94

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

presto-main-base/src/main/java/com/facebook/presto/sessionpropertyproviders/NativeWorkerSessionPropertyProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class NativeWorkerSessionPropertyProvider
5252
public static final String NATIVE_DEBUG_DISABLE_COMMON_SUB_EXPRESSION = "native_debug_disable_common_sub_expressions";
5353
public static final String NATIVE_DEBUG_DISABLE_EXPRESSION_WITH_MEMOIZATION = "native_debug_disable_expression_with_memoization";
5454
public static final String NATIVE_DEBUG_DISABLE_EXPRESSION_WITH_LAZY_INPUTS = "native_debug_disable_expression_with_lazy_inputs";
55+
public static final String NATIVE_DEBUG_MEMORY_POOL_NAME_REGEX = "native_debug_memory_pool_name_regex";
5556
public static final String NATIVE_SELECTIVE_NIMBLE_READER_ENABLED = "native_selective_nimble_reader_enabled";
5657
public static final String NATIVE_MAX_PARTIAL_AGGREGATION_MEMORY = "native_max_partial_aggregation_memory";
5758
public static final String NATIVE_MAX_EXTENDED_PARTIAL_AGGREGATION_MEMORY = "native_max_extended_partial_aggregation_memory";
@@ -200,6 +201,14 @@ public NativeWorkerSessionPropertyProvider(FeaturesConfig featuresConfig)
200201
"of lazy inputs unless required. Should only be used for debugging.",
201202
false,
202203
true),
204+
stringProperty(
205+
NATIVE_DEBUG_MEMORY_POOL_NAME_REGEX,
206+
"Regex for filtering on memory pool name if not empty." +
207+
" This allows us to only track the callsites of memory allocations for" +
208+
" memory pools whose name matches the specified regular expression. Empty" +
209+
" string means no match for all.",
210+
"",
211+
true),
203212
booleanProperty(
204213
NATIVE_SELECTIVE_NIMBLE_READER_ENABLED,
205214
"Temporary flag to control whether selective Nimble reader should be " +

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,17 @@ std::shared_ptr<core::QueryCtx> QueryContextManager::findOrCreateQueryCtx(
163163
// though the query ctx has been evicted out of the cache. The query ctx cache
164164
// is still indexed by the query id.
165165
static std::atomic_uint64_t poolId{0};
166+
std::optional<memory::MemoryPool::DebugOptions> poolDbgOpts;
167+
const auto debugMemoryPoolNameRegex = queryConfig.debugMemoryPoolNameRegex();
168+
if (!debugMemoryPoolNameRegex.empty()) {
169+
poolDbgOpts = memory::MemoryPool::DebugOptions{
170+
.debugPoolNameRegex = debugMemoryPoolNameRegex};
171+
}
166172
auto pool = memory::MemoryManager::getInstance()->addRootPool(
167173
fmt::format("{}_{}", queryId, poolId++),
168-
queryConfig.queryMaxMemoryPerNode());
174+
queryConfig.queryMaxMemoryPerNode(),
175+
nullptr,
176+
poolDbgOpts);
169177

170178
auto queryCtx = core::QueryCtx::create(
171179
driverExecutor_,

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ SessionProperties::SessionProperties() {
263263
QueryConfig::kDebugDisableExpressionWithLazyInputs,
264264
boolToString(c.debugDisableExpressionsWithLazyInputs()));
265265

266+
addSessionProperty(
267+
kDebugMemoryPoolNameRegex,
268+
"Regex for filtering on memory pool name if not empty. This allows us to "
269+
"only track the callsites of memory allocations for memory pools whose "
270+
"name matches the specified regular expression. Empty string means no "
271+
"match for all.",
272+
VARCHAR(),
273+
false,
274+
QueryConfig::kDebugMemoryPoolNameRegex,
275+
c.debugMemoryPoolNameRegex());
276+
266277
addSessionProperty(
267278
kSelectiveNimbleReaderEnabled,
268279
"Temporary flag to control whether selective Nimble reader should be "

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ class SessionProperties {
177177
static constexpr const char* kDebugDisableExpressionWithLazyInputs =
178178
"native_debug_disable_expression_with_lazy_inputs";
179179

180+
/// Regex for filtering on memory pool name if not empty. This allows us to
181+
/// only track the callsites of memory allocations for memory pools whose name
182+
/// matches the specified regular expression. Empty string means no match for
183+
/// all.
184+
static constexpr const char* kDebugMemoryPoolNameRegex =
185+
"native_debug_memory_pool_name_regex";
186+
180187
/// Temporary flag to control whether selective Nimble reader should be used
181188
/// in this query or not. Will be removed after the selective Nimble reader
182189
/// is fully rolled out.

0 commit comments

Comments
 (0)