-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-13131] [SQL] Use best and average time in benchmark #11018
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,52 +33,50 @@ import org.apache.spark.util.Benchmark | |
*/ | ||
class BenchmarkWholeStageCodegen extends SparkFunSuite { | ||
lazy val conf = new SparkConf().setMaster("local[1]").setAppName("benchmark") | ||
.set("spark.sql.shuffle.partitions", "1") | ||
lazy val sc = SparkContext.getOrCreate(conf) | ||
lazy val sqlContext = SQLContext.getOrCreate(sc) | ||
|
||
def testWholeStage(values: Int): Unit = { | ||
val benchmark = new Benchmark("rang/filter/aggregate", values) | ||
def runBenchmark(name: String, values: Int)(f: => Unit): Unit = { | ||
val benchmark = new Benchmark(name, values) | ||
|
||
benchmark.addCase("Without codegen") { iter => | ||
sqlContext.setConf("spark.sql.codegen.wholeStage", "false") | ||
sqlContext.range(values).filter("(id & 1) = 1").count() | ||
Seq(false, true).foreach { enabled => | ||
benchmark.addCase(s"$name codegen=$enabled") { iter => | ||
sqlContext.setConf("spark.sql.codegen.wholeStage", enabled.toString) | ||
f | ||
} | ||
} | ||
|
||
benchmark.addCase("With codegen") { iter => | ||
sqlContext.setConf("spark.sql.codegen.wholeStage", "true") | ||
sqlContext.range(values).filter("(id & 1) = 1").count() | ||
} | ||
benchmark.run() | ||
} | ||
|
||
def testWholeStage(values: Int): Unit = { | ||
|
||
runBenchmark("rang/filter/sum", values) { | ||
sqlContext.range(values).filter("(id & 1) = 1").groupBy().sum().collect() | ||
} | ||
/* | ||
Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
rang/filter/aggregate: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
------------------------------------------------------------------------------- | ||
Without codegen 7775.53 26.97 1.00 X | ||
With codegen 342.15 612.94 22.73 X | ||
Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
rang/filter/aggregate: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
------------------------------------------------------------------------------- | ||
rang/filter/aggregate codegen=false 12509.22 41.91 1.00 X | ||
rang/filter/aggregate codegen=true 846.38 619.45 14.78 X | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query is changed from |
||
*/ | ||
benchmark.run() | ||
} | ||
|
||
def testAggregateWithKey(values: Int): Unit = { | ||
val benchmark = new Benchmark("Aggregate with keys", values) | ||
|
||
benchmark.addCase("Aggregate w/o codegen") { iter => | ||
sqlContext.setConf("spark.sql.codegen.wholeStage", "false") | ||
sqlContext.range(values).selectExpr("(id & 65535) as k").groupBy("k").sum().collect() | ||
} | ||
benchmark.addCase(s"Aggregate w codegen") { iter => | ||
sqlContext.setConf("spark.sql.codegen.wholeStage", "true") | ||
runBenchmark("Aggregate w keys", values) { | ||
sqlContext.range(values).selectExpr("(id & 65535) as k").groupBy("k").sum().collect() | ||
} | ||
|
||
/* | ||
Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
Aggregate with keys: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
------------------------------------------------------------------------------- | ||
Aggregate w/o codegen 4254.38 4.93 1.00 X | ||
Aggregate w codegen 2661.45 7.88 1.60 X | ||
Aggregate w keys codegen=false 2589.00 8.10 1.00 X | ||
Aggregate w keys codegen=true 1645.38 12.75 1.57 X | ||
*/ | ||
benchmark.run() | ||
} | ||
|
||
def testBytesToBytesMap(values: Int): Unit = { | ||
|
@@ -138,18 +136,18 @@ class BenchmarkWholeStageCodegen extends SparkFunSuite { | |
|
||
/** | ||
Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
Aggregate with keys: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
BytesToBytesMap: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
------------------------------------------------------------------------------- | ||
hash 662.06 79.19 1.00 X | ||
BytesToBytesMap (off Heap) 2209.42 23.73 0.30 X | ||
BytesToBytesMap (on Heap) 2957.68 17.73 0.22 X | ||
hash 603.61 86.86 1.00 X | ||
BytesToBytesMap (off Heap) 3297.39 15.90 0.18 X | ||
BytesToBytesMap (on Heap) 3607.09 14.53 0.17 X | ||
*/ | ||
benchmark.run() | ||
} | ||
|
||
test("benchmark") { | ||
// testWholeStage(1024 * 1024 * 200) | ||
// testWholeStage(500 << 20) | ||
// testAggregateWithKey(20 << 20) | ||
// testBytesToBytesMap(1024 * 1024 * 50) | ||
// testBytesToBytesMap(50 << 20) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed offline, I don't think this is a good idea. at the very least if you want to compare best time, you should also report avg time, which is a more reasonable number to compare.