You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "wForget (via GitHub)" <gi...@apache.org> on 2025/10/31 05:32:54 UTC

[PR] [GLUTEN-10988][VL] Make resizeBatches.shuffleOutput work only for hash shuffle [incubator-gluten]

wForget opened a new pull request, #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991

   <!--
   Thank you for submitting a pull request! Here are some tips:
   
   1. For first-time contributors, please read our contributing guide:
      https://github.com/apache/incubator-gluten/blob/main/CONTRIBUTING.md
   2. If necessary, create a GitHub issue for discussion beforehand to avoid duplicate work.
   3. If the PR is specific to a single backend, include [VL] or [CH] in the PR title to indicate the
      Velox or ClickHouse backend, respectively.
   4. If the PR is not ready for review, please mark it as a draft.
   -->
   
   ## What changes are proposed in this pull request?
   
   Make resizeBatches.shuffleOutput work only for hash shuffle
   
   closes #10988
   
   ## How was this patch tested?
   
   <!--
   Describe how the changes were tested, if applicable.
   Include new tests to validate the functionality, if necessary.
   For UI-related changes, attach screenshots to demonstrate the updates.
   -->
   


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "marin-ma (via GitHub)" <gi...@apache.org>.
marin-ma commented on code in PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#discussion_r2493593126


##########
gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala:
##########
@@ -31,6 +31,8 @@ import scala.collection.JavaConverters._
 
 trait ShuffleWriterType {
   val name: String
+  val requiresResizingShuffleInput: Boolean = true
+  val requiresResizingShuffleOutput: Boolean = true

Review Comment:
   Please move these into `HashShuffleWriterType`



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#issuecomment-3479141712

   > Could you only remove this for the specific shuffle writer type `SortShuffleWriterType` and `RssSortShuffleWriterType`? There's going to be more shuffle writer type such as gpu shuffle writer in the future.
   
   @marin-ma Thank you. I have only removed support for `SortShuffleWriterType/RssSortShuffleWriterType`. Could you please take another look?


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#issuecomment-3483494700

   Run Gluten Clickhouse CI on x86


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Make resizeBatches.shuffleOutput work only for hash shuffle [incubator-gluten]

Posted by "marin-ma (via GitHub)" <gi...@apache.org>.
marin-ma commented on PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#issuecomment-3473218775

   I think we should only remove for the row-based sort shuffle `SortShuffleWriterType`. Currently we also have `RssSortShuffleWriterType` for celeborn, and there's going to be more shuffle writer type such as gpu shuffle writer in the future. 


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#discussion_r2493801304


##########
gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala:
##########
@@ -31,6 +31,8 @@ import scala.collection.JavaConverters._
 
 trait ShuffleWriterType {
   val name: String
+  val requiresResizingShuffleInput: Boolean = true
+  val requiresResizingShuffleOutput: Boolean = true

Review Comment:
   Thanks, updated



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#issuecomment-3483562795

   Run Gluten Clickhouse CI on x86


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "marin-ma (via GitHub)" <gi...@apache.org>.
marin-ma commented on code in PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#discussion_r2486018463


##########
backends-velox/src/main/scala/org/apache/gluten/extension/AppendBatchResizeForShuffleInputAndOutput.scala:
##########
@@ -30,30 +31,50 @@ import org.apache.spark.sql.execution.adaptive.{AQEShuffleReadExec, ShuffleQuery
  */
 case class AppendBatchResizeForShuffleInputAndOutput() extends Rule[SparkPlan] {
   override def apply(plan: SparkPlan): SparkPlan = {
+    val resizeBatchesShuffleInputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleInput
+    val resizeBatchesShuffleOutputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleOutput
+    if (!resizeBatchesShuffleInputEnabled && !resizeBatchesShuffleOutputEnabled) {
+      return plan
+    }
+
     val range = VeloxConfig.get.veloxResizeBatchesShuffleInputOutputRange
     plan.transformUp {
-      case shuffle: ColumnarShuffleExchangeExec
-          if shuffle.shuffleWriterType == HashShuffleWriterType &&
-            VeloxConfig.get.veloxResizeBatchesShuffleInput =>
+      case ColumnarResizeableShuffleExchangeExec(shuffle) if resizeBatchesShuffleInputEnabled =>

Review Comment:
   It seems this change assumes a specific shuffle writer type requires both shuffle input and output require resizing at the same time, but I don't think that's necessarily true. We may assume for a shuffle type it may need input resizing but not output resizing, and vice versa. (Although for the existing types they are the same).
   
   Maybe we can generalize this by adding these flags to the ShuffleWriterType trait:
   ```
   trait ShuffleWriterType {
     val name: String
     val requiresResizingShuffleInput: Boolean
     val requiresResizingShuffleOutput: Boolean
   }
   ```
   
   What do you think?



##########
backends-velox/src/main/scala/org/apache/gluten/extension/AppendBatchResizeForShuffleInputAndOutput.scala:
##########
@@ -30,30 +31,50 @@ import org.apache.spark.sql.execution.adaptive.{AQEShuffleReadExec, ShuffleQuery
  */
 case class AppendBatchResizeForShuffleInputAndOutput() extends Rule[SparkPlan] {
   override def apply(plan: SparkPlan): SparkPlan = {
+    val resizeBatchesShuffleInputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleInput
+    val resizeBatchesShuffleOutputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleOutput
+    if (!resizeBatchesShuffleInputEnabled && !resizeBatchesShuffleOutputEnabled) {
+      return plan
+    }
+
     val range = VeloxConfig.get.veloxResizeBatchesShuffleInputOutputRange
     plan.transformUp {
-      case shuffle: ColumnarShuffleExchangeExec
-          if shuffle.shuffleWriterType == HashShuffleWriterType &&
-            VeloxConfig.get.veloxResizeBatchesShuffleInput =>
+      case ColumnarResizeableShuffleExchangeExec(shuffle) if resizeBatchesShuffleInputEnabled =>
         val appendBatches =
           VeloxResizeBatchesExec(shuffle.child, range.min, range.max)
         shuffle.withNewChildren(Seq(appendBatches))
-      case a @ AQEShuffleReadExec(ShuffleQueryStageExec(_, _: ColumnarShuffleExchangeExec, _), _)
-          if VeloxConfig.get.veloxResizeBatchesShuffleOutput =>
+      case a @ AQEShuffleReadExec(
+            ShuffleQueryStageExec(_, ColumnarResizeableShuffleExchangeExec(_), _),
+            _) if resizeBatchesShuffleOutputEnabled =>
         VeloxResizeBatchesExec(a, range.min, range.max)
       // Since it's transformed in a bottom to up order, so we may first encountered
       // ShuffeQueryStageExec, which is transformed to VeloxResizeBatchesExec(ShuffeQueryStageExec),
       // then we see AQEShuffleReadExec
       case a @ AQEShuffleReadExec(
             VeloxResizeBatchesExec(
-              s @ ShuffleQueryStageExec(_, _: ColumnarShuffleExchangeExec, _),
+              s @ ShuffleQueryStageExec(_, ColumnarResizeableShuffleExchangeExec(_), _),
               _,
               _),
-            _) if VeloxConfig.get.veloxResizeBatchesShuffleOutput =>
+            _) if resizeBatchesShuffleOutputEnabled =>
         VeloxResizeBatchesExec(a.copy(child = s), range.min, range.max)
-      case s @ ShuffleQueryStageExec(_, _: ColumnarShuffleExchangeExec, _)
-          if VeloxConfig.get.veloxResizeBatchesShuffleOutput =>
+      case s @ ShuffleQueryStageExec(_, ColumnarResizeableShuffleExchangeExec(_), _)
+          if resizeBatchesShuffleOutputEnabled =>
         VeloxResizeBatchesExec(s, range.min, range.max)
     }
   }
+
+  private object ColumnarResizeableShuffleExchangeExec {
+    def unapply(plan: SparkPlan): Option[ColumnarShuffleExchangeExec] = {
+      plan match {
+        // sort-based/rss-sort shuffle has already resized the batch size in shuffle read,
+        // so no need to resize again
+        case shuffle: ColumnarShuffleExchangeExec

Review Comment:
   nit: Perhaps a more readable way for this logic
   
   ```
   case shuffle: ColumnarShuffleExchangeExec
               if shuffle.shuffleWriterType != SortShuffleWriterType
                 && shuffle.shuffleWriterType != RssSortShuffleWriterType => Some(shuffle)
   case _ => None
   ```



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#discussion_r2488459497


##########
backends-velox/src/main/scala/org/apache/gluten/extension/AppendBatchResizeForShuffleInputAndOutput.scala:
##########
@@ -30,30 +31,50 @@ import org.apache.spark.sql.execution.adaptive.{AQEShuffleReadExec, ShuffleQuery
  */
 case class AppendBatchResizeForShuffleInputAndOutput() extends Rule[SparkPlan] {
   override def apply(plan: SparkPlan): SparkPlan = {
+    val resizeBatchesShuffleInputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleInput
+    val resizeBatchesShuffleOutputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleOutput
+    if (!resizeBatchesShuffleInputEnabled && !resizeBatchesShuffleOutputEnabled) {
+      return plan
+    }
+
     val range = VeloxConfig.get.veloxResizeBatchesShuffleInputOutputRange
     plan.transformUp {
-      case shuffle: ColumnarShuffleExchangeExec
-          if shuffle.shuffleWriterType == HashShuffleWriterType &&
-            VeloxConfig.get.veloxResizeBatchesShuffleInput =>
+      case ColumnarResizeableShuffleExchangeExec(shuffle) if resizeBatchesShuffleInputEnabled =>

Review Comment:
   @marin-ma Thank you for your suggestion, I have updated it. Also, do we need to change the default value of `COLUMNAR_VELOX_RESIZE_BATCHES_SHUFFLE_OUTPUT` to true?
   https://github.com/apache/incubator-gluten/blob/95f271d7f683deb9d61fb019806d6d221d0fc6c9/backends-velox/src/main/scala/org/apache/gluten/config/VeloxConfig.scala#L279-L286



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "marin-ma (via GitHub)" <gi...@apache.org>.
marin-ma merged PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#issuecomment-3490308593

   Run Gluten Clickhouse CI on x86


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10988][VL] Do not resize batches for sort-based/rss-sort shuffle [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #10991:
URL: https://github.com/apache/incubator-gluten/pull/10991#discussion_r2486235099


##########
backends-velox/src/main/scala/org/apache/gluten/extension/AppendBatchResizeForShuffleInputAndOutput.scala:
##########
@@ -30,30 +31,50 @@ import org.apache.spark.sql.execution.adaptive.{AQEShuffleReadExec, ShuffleQuery
  */
 case class AppendBatchResizeForShuffleInputAndOutput() extends Rule[SparkPlan] {
   override def apply(plan: SparkPlan): SparkPlan = {
+    val resizeBatchesShuffleInputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleInput
+    val resizeBatchesShuffleOutputEnabled = VeloxConfig.get.veloxResizeBatchesShuffleOutput
+    if (!resizeBatchesShuffleInputEnabled && !resizeBatchesShuffleOutputEnabled) {
+      return plan
+    }
+
     val range = VeloxConfig.get.veloxResizeBatchesShuffleInputOutputRange
     plan.transformUp {
-      case shuffle: ColumnarShuffleExchangeExec
-          if shuffle.shuffleWriterType == HashShuffleWriterType &&
-            VeloxConfig.get.veloxResizeBatchesShuffleInput =>
+      case ColumnarResizeableShuffleExchangeExec(shuffle) if resizeBatchesShuffleInputEnabled =>

Review Comment:
   Thanks, sounds good. I’ll make that change.



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org