-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-12913] [SQL] Improve performance of stat functions #10960
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
Changes from 1 commit
61edd5e
3c8d737
ae83955
1481bb4
448e0e1
1b95b7c
ae78e81
1086810
383c193
ab32659
7e57a1a
5f98588
fe6fe50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,7 +190,7 @@ case class WholeStageCodegen(plan: CodegenSupport, children: Seq[SparkPlan]) | |
| """ | ||
| // try to compile, helpful for debug | ||
| // println(s"${CodeFormatter.format(source)}") | ||
| CodeGenerator.compile(source) | ||
| // CodeGenerator.compile(source) | ||
|
Contributor
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. Any reason to comment this line out?
Contributor
Author
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. no reason, will bring it back. |
||
|
|
||
| rdd.mapPartitions { iter => | ||
| val clazz = CodeGenerator.compile(source) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,11 @@ import org.apache.spark.util.Benchmark | |
| * build/sbt "sql/test-only *BenchmarkWholeStageCodegen" | ||
| */ | ||
| class BenchmarkWholeStageCodegen extends SparkFunSuite { | ||
| lazy val conf = new SparkConf().setMaster("local[1]").setAppName("benchmark") | ||
| lazy val sc = SparkContext.getOrCreate(conf) | ||
| lazy val sqlContext = SQLContext.getOrCreate(sc) | ||
|
|
||
| def testWholeStage(values: Int): Unit = { | ||
| val conf = new SparkConf().setMaster("local[1]").setAppName("benchmark") | ||
| val sc = SparkContext.getOrCreate(conf) | ||
| val sqlContext = SQLContext.getOrCreate(sc) | ||
|
|
||
| val benchmark = new Benchmark("Single Int Column Scan", values) | ||
|
|
||
|
|
@@ -54,7 +55,42 @@ class BenchmarkWholeStageCodegen extends SparkFunSuite { | |
| benchmark.run() | ||
| } | ||
|
|
||
| ignore("benchmark") { | ||
| testWholeStage(1024 * 1024 * 200) | ||
| def testStddev(values: Int): Unit = { | ||
|
Contributor
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 test actually touches both |
||
|
|
||
| val benchmark = new Benchmark("stddev", values) | ||
|
|
||
| benchmark.addCase("stddev w/o codegen") { iter => | ||
| sqlContext.setConf("spark.sql.codegen.wholeStage", "false") | ||
| sqlContext.range(values).groupBy().agg("id" -> "stddev").collect() | ||
| } | ||
|
|
||
| benchmark.addCase("stddev w codegen") { iter => | ||
| sqlContext.setConf("spark.sql.codegen.wholeStage", "true") | ||
| sqlContext.range(values).groupBy().agg("id" -> "stddev").collect() | ||
| } | ||
|
|
||
| /** | ||
| Using ImperativeAggregate: | ||
|
Contributor
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. Add |
||
|
|
||
| Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
| stddev: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
| ------------------------------------------------------------------- | ||
| stddev w/o codegen 10157.82 10.32 1.00 X | ||
| stddev w codegen 10528.03 9.96 0.96 X | ||
|
|
||
| Using DeclarativeAggregate: | ||
|
|
||
| Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz | ||
| stddev: Avg Time(ms) Avg Rate(M/s) Relative Rate | ||
| ------------------------------------------------------------------- | ||
| stddev w/o codegen 4128.44 25.40 1.00 X | ||
| stddev w codegen 1400.25 74.88 2.95 X | ||
| */ | ||
| benchmark.run() | ||
| } | ||
|
|
||
| test("benchmark") { | ||
|
Contributor
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. Shall we add a comment and say those benchmarks are skipped in normal build, or change |
||
| // testWholeStage(200 << 20) | ||
| testStddev(100 << 20) | ||
| } | ||
| } | ||
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.
Creating a Cast() here is very expensive