dongjoon-hyun commented on a change in pull request #23986: [SPARK-27070] Fix performance bug in DefaultPartitionCoalescer URL: https://github.com/apache/spark/pull/23986#discussion_r263903799
########## File path: core/src/test/scala/org/apache/spark/rdd/CoalescedRDDBenchmark.scala ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.rdd +import scala.collection.immutable + +import org.apache.spark.{DebugFilesystem, SparkConf, SparkContext} +import org.apache.spark.benchmark.{Benchmark, BenchmarkBase} + +object CoalescedRDDBenchmark extends BenchmarkBase { + + val seed = 0x1337 + var conf = new SparkConf(false) + val sc = new SparkContext( + "local[4]", + "test", + conf.set("spark.hadoop.fs.file.impl", classOf[DebugFilesystem].getName)) + + private def coalescedRDD(numIters: Int): Unit = { + val numBlocks = 100000 + val benchmark = new Benchmark("Coalesced RDD", numBlocks, output = output) + for (numPartitions <- Seq(100, 500, 1000, 5000, 10000)) { + for (numHosts <- Seq(1, 5, 10, 20, 40, 80)) { + + import collection.mutable + val hosts = mutable.ArrayBuffer[String]() + (1 to numHosts).foreach(hosts += "m" + _) + hosts.length + val rnd = scala.util.Random + rnd.setSeed(seed) + val blocks: immutable.Seq[(Int, Seq[String])] = (1 to numBlocks).map { i => + (i, hosts(rnd.nextInt(hosts.size)) :: Nil) + } + + benchmark.addCase( + s"Coalesce Num Partitions: $numPartitions Num Hosts: $numHosts", + numIters) { _ => + performCoalesce(blocks, numPartitions) + } + } + } + + benchmark.run() + } + + private def performCoalesce(blocks: immutable.Seq[(Int, Seq[String])], numPartitions: Int) { + sc.makeRDD(blocks).coalesce(numPartitions).partitions + } + + override def runBenchmarkSuite(mainArgs: Array[String]): Unit = { + val numIters = 3 + runBenchmark("Coalesced RDD , large scale") { + coalescedRDD(numIters) + } Review comment: Also, we need include the generated test result like `KryoBenchmark`. If you run as a guide, you will get the generate file. Please simply add it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
