Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions presto-docs/src/main/sphinx/presto_cpp/properties-session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,17 @@ Native Execution only. Ratio of unused (evicted) bytes to total bytes that trigg
compaction. The value is in the range of [0, 1). Currently only applies to
approx_most_frequent aggregate with StringView type during global aggregation.

``native_aggregation_memory_compaction_reclaim_enabled``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* **Type:** ``boolean``
* **Default value:** ``false``

Native Execution only. If true, enables lightweight memory compaction before
spilling during memory reclaim in aggregation. When enabled, the aggregation
operator will try to compact aggregate function state (for example, free dead strings)
before resorting to spilling.

``optimizer.optimize_top_n_rank``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class NativeWorkerSessionPropertyProvider
public static final String NATIVE_USE_VELOX_GEOSPATIAL_JOIN = "native_use_velox_geospatial_join";
public static final String NATIVE_AGGREGATION_COMPACTION_BYTES_THRESHOLD = "native_aggregation_compaction_bytes_threshold";
public static final String NATIVE_AGGREGATION_COMPACTION_UNUSED_MEMORY_RATIO = "native_aggregation_compaction_unused_memory_ratio";
public static final String NATIVE_AGGREGATION_MEMORY_COMPACTION_RECLAIM_ENABLED = "native_aggregation_memory_compaction_reclaim_enabled";
public static final String NATIVE_MERGE_JOIN_OUTPUT_BATCH_START_SIZE = "native_merge_join_output_batch_start_size";

private final List<PropertyMetadata<?>> sessionProperties;
Expand Down Expand Up @@ -458,6 +459,13 @@ public NativeWorkerSessionPropertyProvider(FeaturesConfig featuresConfig)
"aggregate with StringView type during global aggregation.",
0.25,
!nativeExecution),
booleanProperty(
NATIVE_AGGREGATION_MEMORY_COMPACTION_RECLAIM_ENABLED,
"If true, enables lightweight memory compaction before spilling during " +
"memory reclaim in aggregation. When enabled, the aggregation operator " +
"will try to compact aggregate function state before resorting to spilling.",
false,
!nativeExecution),
integerProperty(
NATIVE_MERGE_JOIN_OUTPUT_BATCH_START_SIZE,
"Initial output batch size in rows for MergeJoin operator. When non-zero, " +
Expand Down
11 changes: 11 additions & 0 deletions presto-native-execution/presto_cpp/main/SessionProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,17 @@ SessionProperties::SessionProperties() {
false,
QueryConfig::kAggregationCompactionUnusedMemoryRatio,
std::to_string(c.aggregationCompactionUnusedMemoryRatio()));

addSessionProperty(
kAggregationMemoryCompactionReclaimEnabled,
"If true, enables lightweight memory compaction before spilling during "
"memory reclaim in aggregation. When enabled, the aggregation operator "
"will try to compact aggregate function state (for example, free dead strings) "
"before resorting to spilling. Disabled by default.",
BOOLEAN(),
false,
QueryConfig::kAggregationMemoryCompactionReclaimEnabled,
boolToString(c.aggregationMemoryCompactionReclaimEnabled()));
}

const std::string SessionProperties::toVeloxConfig(
Expand Down
7 changes: 7 additions & 0 deletions presto-native-execution/presto_cpp/main/SessionProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@ class SessionProperties {
static constexpr const char* kAggregationCompactionUnusedMemoryRatio =
"native_aggregation_compaction_unused_memory_ratio";

/// If true, enables lightweight memory compaction before spilling during
/// memory reclaim in aggregation. When enabled, the aggregation operator
/// will try to compact aggregate function state (e.g., free dead strings)
/// before resorting to spilling. Disabled by default.
static constexpr const char* kAggregationMemoryCompactionReclaimEnabled =
"native_aggregation_memory_compaction_reclaim_enabled";

inline bool hasVeloxConfig(const std::string& key) {
auto sessionProperty = sessionProperties_.find(key);
if (sessionProperty == sessionProperties_.end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ TEST_F(SessionPropertiesTest, validateMapping) {
core::QueryConfig::kAggregationCompactionBytesThreshold},
{SessionProperties::kAggregationCompactionUnusedMemoryRatio,
core::QueryConfig::kAggregationCompactionUnusedMemoryRatio},
{SessionProperties::kAggregationMemoryCompactionReclaimEnabled,
core::QueryConfig::kAggregationMemoryCompactionReclaimEnabled},
{SessionProperties::kMergeJoinOutputBatchStartSize,
core::QueryConfig::kMergeJoinOutputBatchStartSize}};

Expand Down
Loading