Skip to content

Commit 4fe4b65

Browse files
sunchaowangyum
authored andcommitted
[SPARK-35315][TESTS] Keep benchmark result consistent between spark-submit and SBT
### What changes were proposed in this pull request? Set `IS_TESTING` to true in `BenchmarkBase`, before running benchmarks. ### Why are the changes needed? Currently benchmark can be done via 2 ways: `spark-submit`, or SBT command. However in the former Spark will miss some properties such as `IS_TESTING`, which is necessary to turn on/off certain behavior like codegen (`spark.sql.codegen.factoryMode`). Therefore, the result could differ between the two. In addition, the benchmark GitHub workflow is using the spark-submit approach. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? N/A Closes #32440 from sunchao/SPARK-35315. Authored-by: Chao Sun <[email protected]> Signed-off-by: Yuming Wang <[email protected]>
1 parent bbdbe0f commit 4fe4b65

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/src/test/scala/org/apache/spark/benchmark/BenchmarkBase.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package org.apache.spark.benchmark
1919

2020
import java.io.{File, FileOutputStream, OutputStream}
2121

22+
import org.apache.spark.internal.config.Tests.IS_TESTING
23+
2224
/**
2325
* A base class for generate benchmark results to a file.
2426
* For JDK9+, JDK major version number is added to the file names to distinguish the results.
@@ -42,6 +44,10 @@ abstract class BenchmarkBase {
4244
}
4345

4446
def main(args: Array[String]): Unit = {
47+
// turning this on so the behavior between running benchmark via `spark-submit` or SBT will
48+
// be consistent, also allow users to turn on/off certain behavior such as
49+
// `spark.sql.codegen.factoryMode`
50+
System.setProperty(IS_TESTING.key, "true")
4551
val regenerateBenchmarkFiles: Boolean = System.getenv("SPARK_GENERATE_BENCHMARK_FILES") == "1"
4652
if (regenerateBenchmarkFiles) {
4753
val version = System.getProperty("java.version").split("\\D+")(0).toInt

0 commit comments

Comments
 (0)