-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-25589][SQL][TEST] Add BloomFilterBenchmark #22605
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
================================================================================================ | ||
ORC Write | ||
================================================================================================ | ||
|
||
OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64 | ||
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | ||
Write 100M rows: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative | ||
------------------------------------------------------------------------------------------------ | ||
Without bloom filter 16765 / 17587 6.0 167.7 1.0X | ||
With bloom filter 20060 / 20626 5.0 200.6 0.8X | ||
|
||
|
||
================================================================================================ | ||
ORC Read | ||
================================================================================================ | ||
|
||
OpenJDK 64-Bit Server VM 1.8.0_181-b13 on Linux 3.10.0-862.3.2.el7.x86_64 | ||
Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | ||
Read a row from 100M rows: Best/Avg Time(ms) Rate(M/s) Per Row(ns) Relative | ||
------------------------------------------------------------------------------------------------ | ||
Without bloom filter 1857 / 1904 53.9 18.6 1.0X | ||
With bloom filter 1399 / 1437 71.5 14.0 1.3X | ||
|
||
|
87 changes: 87 additions & 0 deletions
87
sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/BloomFilterBenchmark.scala
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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.sql.execution.benchmark | ||
|
||
import scala.util.Random | ||
|
||
import org.apache.spark.benchmark.Benchmark | ||
|
||
/** | ||
* Benchmark to measure read performance with Bloom filters. | ||
* | ||
* Currently, only ORC supports bloom filters, we will add Parquet BM as soon as it becomes | ||
* available. | ||
* | ||
* To run this benchmark: | ||
* {{{ | ||
* 1. without sbt: bin/spark-submit --class <this class> <spark sql test jar> | ||
* 2. build/sbt "sql/test:runMain <this class>" | ||
* 3. generate result: SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "sql/test:runMain <this class>" | ||
* Results will be written to "benchmarks/BloomFilterBenchmark-results.txt". | ||
* }}} | ||
*/ | ||
object BloomFilterBenchmark extends SqlBasedBenchmark { | ||
import spark.implicits._ | ||
|
||
private val scaleFactor = 100 | ||
private val N = scaleFactor * 1000 * 1000 | ||
private val df = spark.range(N).map(_ => Random.nextInt) | ||
|
||
private def writeBenchmark(): Unit = { | ||
withTempPath { dir => | ||
val path = dir.getCanonicalPath | ||
|
||
runBenchmark(s"ORC Write") { | ||
val benchmark = new Benchmark(s"Write ${scaleFactor}M rows", N, output = output) | ||
benchmark.addCase("Without bloom filter") { _ => | ||
df.write.mode("overwrite").orc(path + "/withoutBF") | ||
} | ||
benchmark.addCase("With bloom filter") { _ => | ||
df.write.mode("overwrite") | ||
.option("orc.bloom.filter.columns", "value").orc(path + "/withBF") | ||
} | ||
benchmark.run() | ||
} | ||
} | ||
} | ||
|
||
private def readBenchmark(): Unit = { | ||
withTempPath { dir => | ||
val path = dir.getCanonicalPath | ||
|
||
df.write.orc(path + "/withoutBF") | ||
df.write.option("orc.bloom.filter.columns", "value").orc(path + "/withBF") | ||
|
||
runBenchmark(s"ORC Read") { | ||
val benchmark = new Benchmark(s"Read a row from ${scaleFactor}M rows", N, output = output) | ||
benchmark.addCase("Without bloom filter") { _ => | ||
spark.read.orc(path + "/withoutBF").where("value = 0").count | ||
} | ||
benchmark.addCase("With bloom filter") { _ => | ||
spark.read.orc(path + "/withBF").where("value = 0").count | ||
} | ||
benchmark.run() | ||
} | ||
} | ||
} | ||
|
||
override def runBenchmarkSuite(): Unit = { | ||
writeBenchmark() | ||
readBenchmark() | ||
} | ||
} |
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.
I think we should also add this ORC feature to the SQL doc.
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.
Sorry, but Apache ORC is an independent Apache project which has its own website and documents. We should respect that. If we introduce new ORC configuration one by one in Apache Spark website, it will eventually duplicate Apache ORC document in Apache Spark document.
We had better guide ORC fans to Apache ORC website. If something is missing there, they can file an ORC JIRA, not SPARK JIRA.