You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/31 09:03:17 UTC
[GitHub] [spark] singhpk234 commented on a change in pull request #35806: [SPARK-38505][SQL] Make partial aggregation adaptive
singhpk234 commented on a change in pull request #35806:
URL: https://github.com/apache/spark/pull/35806#discussion_r839345569
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala
##########
@@ -847,18 +904,60 @@ case class HashAggregateExec(
s"UnsafeRow $unsafeRowBuffer = null;"
}
+ val adaptivePartialAggregation = if (isAdaptivePartialAggregationEnabled) {
+ val numberOfConsumedKeysTerm =
+ ctx.addMutableState(CodeGenerator.JAVA_LONG, "numberOfConsumedKeys")
+ val numAggSkippedRows = metricTerm(ctx, "numSkippedParAggRows")
+ val initExpr = declFunctions.flatMap(f => f.initialValues)
+ val emptyBufferKeyCode = GenerateUnsafeProjection.createCode(ctx, initExpr)
+
+ val numberOfKeys = if (fastHashMapTerm != null) {
+ s"$numberOfConsumedKeysTerm = $fastHashMapTerm.getNumKeys();"
+ } else if (hashMapTerm != null) {
+ s"$numberOfConsumedKeysTerm = $hashMapTerm.getNumKeys();"
+ } else {
+ s"$numberOfConsumedKeysTerm = 0;"
+ }
+ s"""
+ |if (!$skipPartialAggregateTerm) {
+ | if ($numberOfConsumedTerm == ${conf.adaptivePartialAggregationThreshold}) {
Review comment:
should we make this :
```suggestion
| if ($numberOfConsumedTerm >= ${conf.adaptivePartialAggregationThreshold}) {
```
As let's say we made conf.adaptivePartialAggregationThreshold as 10K, at that point % was 0.84 but on processing more let's say 2K rows this increases to 0.85, we will never disable our partial Agg.
As per my understanding : this will be in-sync with trino impl as well.
https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/operator/aggregation/partial/PartialAggregationController.java#L63-L67
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala
##########
@@ -847,18 +904,60 @@ case class HashAggregateExec(
s"UnsafeRow $unsafeRowBuffer = null;"
}
+ val adaptivePartialAggregation = if (isAdaptivePartialAggregationEnabled) {
+ val numberOfConsumedKeysTerm =
+ ctx.addMutableState(CodeGenerator.JAVA_LONG, "numberOfConsumedKeys")
+ val numAggSkippedRows = metricTerm(ctx, "numSkippedParAggRows")
+ val initExpr = declFunctions.flatMap(f => f.initialValues)
+ val emptyBufferKeyCode = GenerateUnsafeProjection.createCode(ctx, initExpr)
+
+ val numberOfKeys = if (fastHashMapTerm != null) {
+ s"$numberOfConsumedKeysTerm = $fastHashMapTerm.getNumKeys();"
+ } else if (hashMapTerm != null) {
+ s"$numberOfConsumedKeysTerm = $hashMapTerm.getNumKeys();"
+ } else {
+ s"$numberOfConsumedKeysTerm = 0;"
+ }
+ s"""
+ |if (!$skipPartialAggregateTerm) {
+ | if ($numberOfConsumedTerm == ${conf.adaptivePartialAggregationThreshold}) {
+ | $numberOfKeys
+ | if ((double) $numberOfConsumedKeysTerm / (double) $numberOfConsumedTerm > 0.85) {
Review comment:
should we make this 0.85 as configurable via conf, like it's done in trino
https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/SystemSessionProperties.java#L790-L795
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org