Skip to content

Commit 433f13b

Browse files
committed
Fix
1 parent fca22b7 commit 433f13b

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

sql/core/src/test/scala/org/apache/spark/sql/execution/WholeStageCodegenSuite.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
package org.apache.spark.sql.execution
1919

20-
import java.util.concurrent.ExecutionException
21-
2220
import org.apache.spark.sql.Row
23-
import org.apache.spark.sql.catalyst.expressions.codegen.{CodeAndComment, CodegenContext, CodeGenerator}
21+
import org.apache.spark.sql.catalyst.expressions.codegen.{CodeAndComment, CodeGenerator}
2422
import org.apache.spark.sql.execution.aggregate.HashAggregateExec
2523
import org.apache.spark.sql.execution.joins.BroadcastHashJoinExec
2624
import org.apache.spark.sql.execution.joins.SortMergeJoinExec
@@ -151,7 +149,7 @@ class WholeStageCodegenSuite extends SparkPlanTest with SharedSQLContext {
151149
}
152150
}
153151

154-
def genGroupByCodeGenContext(caseNum: Int): CodeAndComment = {
152+
def genGroupByCode(caseNum: Int): CodeAndComment = {
155153
val caseExp = (1 to caseNum).map { i =>
156154
s"case when id > $i and id <= ${i + 1} then 1 else 0 end as v$i"
157155
}.toList
@@ -180,10 +178,10 @@ class WholeStageCodegenSuite extends SparkPlanTest with SharedSQLContext {
180178
}
181179

182180
test("SPARK-21871 check if we can get large code size when compiling too long functions") {
183-
val codeWithShortFunctions = genGroupByCodeGenContext(3)
181+
val codeWithShortFunctions = genGroupByCode(3)
184182
val (_, maxCodeSize1) = CodeGenerator.compile(codeWithShortFunctions)
185183
assert(maxCodeSize1 < SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.defaultValue.get)
186-
val codeWithLongFunctions = genGroupByCodeGenContext(20)
184+
val codeWithLongFunctions = genGroupByCode(20)
187185
val (_, maxCodeSize2) = CodeGenerator.compile(codeWithLongFunctions)
188186
assert(maxCodeSize2 > SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.defaultValue.get)
189187
}

sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/AggregateBenchmark.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,20 @@ class AggregateBenchmark extends BenchmarkBase {
334334
.sum()
335335
.collect()
336336

337-
benchmark.addCase(s"hugeMethodLimit = 8000") { iter =>
337+
benchmark.addCase("codegen = F") { iter =>
338+
sparkSession.conf.set(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, "false")
339+
f()
340+
}
341+
342+
benchmark.addCase("codegen = T hugeMethodLimit = 10000") { iter =>
338343
sparkSession.conf.set(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, "true")
339-
sparkSession.conf.set(SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key, "8000")
344+
sparkSession.conf.set(SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key, "10000")
340345
f()
341346
}
342347

343-
benchmark.addCase(s"hugeMethodLimit = 16000") { iter =>
348+
benchmark.addCase("codegen = T hugeMethodLimit = 1500") { iter =>
344349
sparkSession.conf.set(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key, "true")
345-
sparkSession.conf.set(SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key, "16000")
350+
sparkSession.conf.set(SQLConf.WHOLESTAGE_HUGE_METHOD_LIMIT.key, "1500")
346351
f()
347352
}
348353

@@ -354,8 +359,9 @@ class AggregateBenchmark extends BenchmarkBase {
354359
355360
max function bytecode size: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative
356361
------------------------------------------------------------------------------------------------
357-
hugeMethodLimit = 8000 1043 / 1159 0.6 1591.5 1.0X
358-
hugeMethodLimit = 16000 3908 / 3996 0.2 5962.9 0.3X
362+
codegen = F 709 / 803 0.9 1082.1 1.0X
363+
codegen = T hugeMethodLimit = 10000 3485 / 3548 0.2 5317.7 0.2X
364+
codegen = T hugeMethodLimit = 1500 636 / 701 1.0 969.9 1.1X
359365
*/
360366
}
361367

0 commit comments

Comments
 (0)