Skip to content

Commit

Permalink
Add session properties for scaled table scan configs
Browse files Browse the repository at this point in the history
  • Loading branch information
natashasehgal committed Jan 8, 2025
1 parent f9bd6e3 commit b5bb716
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
20 changes: 20 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 @@ -419,3 +419,23 @@ writer scaling if it is detected as overloaded by scale writer exchange.

Minimum amount of data processed by all the logical table partitions to
trigger skewed partition rebalancing by scale writer exchange.

``native_table_scan_scaled_processing_enabled``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

If set to ``true``, enables scaling the table scan concurrency on each worker.

``native_table_scan_scale_up_memory_usage_ratio``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* **Type:** ``double``
* **Minimum value:** ``0``
* **Maximum value:** ``1``
* **Default value:** ``0.7``

Controls the ratio of available memory that can be used for scaling up table scans.
A higher value allows more memory to be allocated for scaling up table scans,
while a lower value limits the amount of memory used.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class NativeWorkerSessionPropertyProvider
public static final String NATIVE_SCALED_WRITER_MAX_PARTITIONS_PER_WRITER = "native_scaled_writer_max_partitions_per_writer";
public static final String NATIVE_SCALED_WRITER_MIN_PARTITION_PROCESSED_BYTES_REBALANCE_THRESHOLD = "native_scaled_writer_min_partition_processed_bytes_rebalance_threshold";
public static final String NATIVE_SCALED_WRITER_MIN_PROCESSED_BYTES_REBALANCE_THRESHOLD = "native_scaled_writer_min_processed_bytes_rebalance_threshold";
public static final String NATIVE_TABLE_SCAN_SCALED_PROCESSING_ENABLED = "native_table_scan_scaled_processing_enabled";
public static final String NATIVE_TABLE_SCAN_SCALE_UP_MEMORY_USAGE_RATIO = "native_table_scan_scale_up_memory_usage_ratio";
private final List<PropertyMetadata<?>> sessionProperties;

@Inject
Expand Down Expand Up @@ -311,6 +313,20 @@ public NativeWorkerSessionPropertyProvider(FeaturesConfig featuresConfig)
"Minimum amount of data processed by all the logical table partitions " +
"to trigger skewed partition rebalancing by scale writer exchange.",
256L << 20,
!nativeExecution),
booleanProperty(
NATIVE_TABLE_SCAN_SCALED_PROCESSING_ENABLED,
"If set to true, enables scaling the table scan concurrency on each worker.",
false,
!nativeExecution),
doubleProperty(
NATIVE_TABLE_SCAN_SCALE_UP_MEMORY_USAGE_RATIO,
"The query memory usage ratio used by scan controller to decide if it can " +
"increase the number of running scan threads. When the query memory usage " +
"is below this ratio, the scan controller keeps increasing the running scan " +
"thread for scale up, and stop once exceeds this ratio. The value is in the " +
"range of [0, 1].",
0.7,
!nativeExecution));
}

Expand Down
17 changes: 17 additions & 0 deletions presto-native-execution/presto_cpp/main/SessionProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,23 @@ SessionProperties::SessionProperties() {
false,
QueryConfig::kScaleWriterMinProcessedBytesRebalanceThreshold,
std::to_string(c.scaleWriterMinProcessedBytesRebalanceThreshold()));

addSessionProperty(
kTableScanScaledProcessingEnabled,
"If set to true, enables scaled processing for table scans.",
BOOLEAN(),
false,
QueryConfig::kTableScanScaledProcessingEnabled,
std::to_string(c.tableScanScaledProcessingEnabled()));

addSessionProperty(
kTableScanScaleUpMemoryUsageRatio,
"Controls the ratio of available memory that can be used for scaling up table scans. "
"The value is in the range of [0, 1].",
DOUBLE(),
false,
QueryConfig::kTableScanScaleUpMemoryUsageRatio,
std::to_string(c.tableScanScaleUpMemoryUsageRatio()));
}

const std::unordered_map<std::string, std::shared_ptr<SessionProperty>>&
Expand Down
9 changes: 9 additions & 0 deletions presto-native-execution/presto_cpp/main/SessionProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ class SessionProperties {
static constexpr const char* kShuffleCompressionEnabled =
"exchange_compression";

/// If set to true, enables scaled processing for table scans.
static constexpr const char* kTableScanScaledProcessingEnabled =
"native_table_scan_scaled_processing_enabled";

/// Controls the ratio of available memory that can be used for scaling up
/// table scans. The value is in the range of [0, 1].
static constexpr const char* kTableScanScaleUpMemoryUsageRatio =
"native_table_scan_scale_up_memory_usage_ratio";

SessionProperties();

const std::unordered_map<std::string, std::shared_ptr<SessionProperty>>&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ TEST_F(SessionPropertiesTest, validateMapping) {
SessionProperties::kScaleWriterMaxPartitionsPerWriter,
SessionProperties::
kScaleWriterMinPartitionProcessedBytesRebalanceThreshold,
SessionProperties::kScaleWriterMinProcessedBytesRebalanceThreshold};
SessionProperties::kScaleWriterMinProcessedBytesRebalanceThreshold,
SessionProperties::kTableScanScaledProcessingEnabled,
SessionProperties::kTableScanScaleUpMemoryUsageRatio};
const std::vector<std::string> veloxConfigNames = {
core::QueryConfig::kAdjustTimestampToTimezone,
core::QueryConfig::kDriverCpuTimeSliceLimitMs,
Expand All @@ -40,7 +42,9 @@ TEST_F(SessionPropertiesTest, validateMapping) {
core::QueryConfig::kScaleWriterMaxPartitionsPerWriter,
core::QueryConfig::
kScaleWriterMinPartitionProcessedBytesRebalanceThreshold,
core::QueryConfig::kScaleWriterMinProcessedBytesRebalanceThreshold};
core::QueryConfig::kScaleWriterMinProcessedBytesRebalanceThreshold,
core::QueryConfig::kTableScanScaledProcessingEnabled,
core::QueryConfig::kTableScanScaleUpMemoryUsageRatio};
auto sessionProperties = SessionProperties().getSessionProperties();
const auto len = names.size();
for (auto i = 0; i < len; i++) {
Expand Down

0 comments on commit b5bb716

Please sign in to comment.