Skip to content

Commit

Permalink
[SPARK-35315][TESTS] Keep benchmark result consistent between spark-s…
Browse files Browse the repository at this point in the history
…ubmit 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 apache#32440 from sunchao/SPARK-35315.

Authored-by: Chao Sun <[email protected]>
Signed-off-by: Yuming Wang <[email protected]>
  • Loading branch information
sunchao authored and wangyum committed May 5, 2021
1 parent bbdbe0f commit 4fe4b65
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.apache.spark.benchmark

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

import org.apache.spark.internal.config.Tests.IS_TESTING

/**
* A base class for generate benchmark results to a file.
* For JDK9+, JDK major version number is added to the file names to distinguish the results.
Expand All @@ -42,6 +44,10 @@ abstract class BenchmarkBase {
}

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

0 comments on commit 4fe4b65

Please sign in to comment.