Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11018#discussion_r51526980
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/BenchmarkWholeStageCodegen.scala
 ---
    @@ -33,41 +33,40 @@ 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
    --- End diff --
    
    The query is changed from `.count()` to `.groupBy().sum().collect()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to