-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-27070] Fix performance bug in DefaultPartitionCoalescer #23986
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4ffb772
SPARK-27070: Don't use sort to find minimum PartitionGroup
fitermay 0803c63
add benchmark and incorporate suggestion from review
fitermay c8424af
SPARK-11316: Changes after review
fitermay 2566639
SPARK-11316: Revert change to foreach loop
fitermay 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| ================================================================================================ | ||
| Coalesced RDD , large scale | ||
| ================================================================================================ | ||
|
|
||
| Java HotSpot(TM) 64-Bit Server VM 1.8.0_201-b09 on Windows 10 10.0 | ||
| Intel64 Family 6 Model 63 Stepping 2, GenuineIntel | ||
| Coalesced RDD: Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | ||
| ------------------------------------------------------------------------------------------------------------------------ | ||
| Coalesce Num Partitions: 100 Num Hosts: 1 346 364 24 0.3 3458.9 1.0X | ||
| Coalesce Num Partitions: 100 Num Hosts: 5 258 264 6 0.4 2579.0 1.3X | ||
| Coalesce Num Partitions: 100 Num Hosts: 10 242 249 7 0.4 2415.2 1.4X | ||
| Coalesce Num Partitions: 100 Num Hosts: 20 237 242 7 0.4 2371.7 1.5X | ||
| Coalesce Num Partitions: 100 Num Hosts: 40 230 231 1 0.4 2299.8 1.5X | ||
| Coalesce Num Partitions: 100 Num Hosts: 80 222 233 14 0.4 2223.0 1.6X | ||
| Coalesce Num Partitions: 500 Num Hosts: 1 659 665 5 0.2 6590.4 0.5X | ||
| Coalesce Num Partitions: 500 Num Hosts: 5 340 381 47 0.3 3395.2 1.0X | ||
| Coalesce Num Partitions: 500 Num Hosts: 10 279 307 47 0.4 2788.3 1.2X | ||
| Coalesce Num Partitions: 500 Num Hosts: 20 259 261 2 0.4 2591.9 1.3X | ||
| Coalesce Num Partitions: 500 Num Hosts: 40 241 250 15 0.4 2406.5 1.4X | ||
| Coalesce Num Partitions: 500 Num Hosts: 80 235 237 3 0.4 2349.9 1.5X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 1 1050 1053 4 0.1 10503.2 0.3X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 5 405 407 2 0.2 4049.5 0.9X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 10 320 322 2 0.3 3202.7 1.1X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 20 276 277 0 0.4 2762.3 1.3X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 40 257 260 5 0.4 2571.2 1.3X | ||
| Coalesce Num Partitions: 1000 Num Hosts: 80 245 252 13 0.4 2448.9 1.4X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 1 3099 3145 55 0.0 30988.6 0.1X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 5 1037 1050 20 0.1 10374.4 0.3X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 10 626 633 8 0.2 6261.8 0.6X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 20 426 431 5 0.2 4258.6 0.8X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 40 328 341 22 0.3 3275.4 1.1X | ||
| Coalesce Num Partitions: 5000 Num Hosts: 80 272 275 4 0.4 2721.4 1.3X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 1 5516 5526 9 0.0 55156.8 0.1X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 5 1956 1992 48 0.1 19560.9 0.2X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 10 1045 1057 18 0.1 10447.4 0.3X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 20 637 658 24 0.2 6373.2 0.5X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 40 431 448 15 0.2 4312.9 0.8X | ||
| Coalesce Num Partitions: 10000 Num Hosts: 80 326 328 2 0.3 3263.4 1.1X | ||
|
|
||
|
|
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
core/src/test/scala/org/apache/spark/rdd/CoalescedRDDBenchmark.scala
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * 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 | ||
|
fitermay marked this conversation as resolved.
|
||
|
|
||
| import org.apache.spark.SparkContext | ||
| import org.apache.spark.benchmark.{Benchmark, BenchmarkBase} | ||
|
|
||
| /** | ||
| * Benchmark for CoalescedRDD. | ||
| * Measures rdd.coalesce performance under various combinations of | ||
| * coalesced partitions and preferred hosts | ||
| * To run this benchmark: | ||
| * {{{ | ||
| * 1. without sbt: | ||
| * bin/spark-submit --class <this class> --jars <spark core test jar> | ||
| * 2. build/sbt "core/test:runMain <this class>" | ||
| * 3. generate result: | ||
| * SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "core/test:runMain <this class>" | ||
| * Results will be written to "benchmarks/CoalescedRDD-results.txt". | ||
| * }}} | ||
| * */ | ||
| object CoalescedRDDBenchmark extends BenchmarkBase { | ||
|
fitermay marked this conversation as resolved.
|
||
| val seed = 0x1337 | ||
| val sc = new SparkContext(master = "local[4]", appName = "test") | ||
|
|
||
| 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) | ||
| } | ||
|
fitermay marked this conversation as resolved.
|
||
| } | ||
| } | ||
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.
Hi, All.
This seems to break
scala-2.11build.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.
Thanks. That’s unfortunate. I’ll fix it later tonight
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.
Then, let me revert this first to recover 2.11 build for the other PRs. Since this PR is already approved, I believe that the next PR will be easily accepted, @fitermay .
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.
@dongjoon-hyun @srowen: Would it be a good idea to extend the PR builder to run a compile with scala 2.11 (without any test run)?
I know it is an extra 10-15 minutes but for the 4 hours test run it might be worth preventing such situations on the other hand this must be very rare. What is your opinion?
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.
I agree with you @attilapiros . But, IIRC, there was a discussion on that issue and the decision at that time was the current cost is not high enough for that.
The committers have a responsibility to monitor their commit. And, we usually are able to do
HOTFIXor revert in a short time.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.
Ok, thanks.
Yes it must be very rare.
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.
We're going to drop 2.11 support soonish anyway, so I think for now we accept the occasional breaks and fix after the fact rather than double the PR builders.