-
Notifications
You must be signed in to change notification settings - Fork 267
perf: Add microbenchmark for hash expressions #3028
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
Merged
+74
−0
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48cc37b
add microbenchmark for hash expressions
andygrove 9af4184
skip some CI workflows for benchmark changes
andygrove 6869f79
skip failing suite
andygrove b1ed4d3
Merge branch 'skip-ci-bench' into hash-bench
andygrove c213912
skip more workflows on benchmark PRs
andygrove cec2982
Merge branch 'skip-more-workflows-on-benchmark-prs' into hash-bench
andygrove ece06ef
Merge remote-tracking branch 'apache/main' into hash-bench
andygrove 828a455
address feedback
andygrove 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
74 changes: 74 additions & 0 deletions
74
spark/src/test/scala/org/apache/spark/sql/benchmark/CometHashExpressionBenchmark.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,74 @@ | ||
| /* | ||
| * 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.benchmark | ||
|
|
||
| case class HashExprConfig( | ||
| name: String, | ||
| query: String, | ||
| extraCometConfigs: Map[String, String] = Map.empty) | ||
|
|
||
| /** | ||
| * Comprehensive benchmark for Comet hash expressions. To run this benchmark: | ||
| * {{{ | ||
| * SPARK_GENERATE_BENCHMARK_FILES=1 make benchmark-org.apache.spark.sql.benchmark.CometHashExpressionBenchmark | ||
| * }}} | ||
| * Results will be written to "spark/benchmarks/CometHashExpressionBenchmark-**results.txt". | ||
| */ | ||
| object CometHashExpressionBenchmark extends CometBenchmarkBase { | ||
|
|
||
| private val hashExpressions = List( | ||
| HashExprConfig("xxhash64_single", "SELECT xxhash64(c_str) FROM parquetV1Table"), | ||
| HashExprConfig("xxhash64_multi", "SELECT xxhash64(c_str, c_int, c_long) FROM parquetV1Table"), | ||
| HashExprConfig("murmur3_hash_single", "SELECT hash(c_str) FROM parquetV1Table"), | ||
| HashExprConfig("murmur3_hash_multi", "SELECT hash(c_str, c_int, c_long) FROM parquetV1Table"), | ||
| HashExprConfig("sha1", "SELECT sha1(c_str) FROM parquetV1Table"), | ||
| HashExprConfig("sha2_224", "SELECT sha2(c_str, 224) FROM parquetV1Table"), | ||
| HashExprConfig("sha2_256", "SELECT sha2(c_str, 256) FROM parquetV1Table"), | ||
| HashExprConfig("sha2_384", "SELECT sha2(c_str, 384) FROM parquetV1Table"), | ||
| HashExprConfig("sha2_512", "SELECT sha2(c_str, 512) FROM parquetV1Table")) | ||
|
|
||
| override def runCometBenchmark(mainArgs: Array[String]): Unit = { | ||
| val values = 1024 * 1024 | ||
|
|
||
| runBenchmarkWithTable("Hash expression benchmarks", values) { v => | ||
| withTempPath { dir => | ||
| withTempTable("parquetV1Table") { | ||
| // Data distribution: 1% NULL per column | ||
| // - c_str: unique strings "string_0" through "string_N" | ||
| // - c_int: integers 0-999,999 (cycling) | ||
| // - c_long: large values 0 to ~1 billion | ||
| prepareTable( | ||
| dir, | ||
| spark.sql(s""" | ||
| SELECT | ||
| CASE WHEN value % 100 = 0 THEN NULL ELSE CONCAT('string_', CAST(value AS STRING)) END AS c_str, | ||
| CASE WHEN value % 100 = 1 THEN NULL ELSE CAST(value % 1000000 AS INT) END AS c_int, | ||
| CASE WHEN value % 100 = 2 THEN NULL ELSE CAST(value * 1000 AS LONG) END AS c_long | ||
| FROM $tbl | ||
| """)) | ||
|
|
||
| hashExpressions.foreach { config => | ||
| runExpressionBenchmark(config.name, v, config.query, config.extraCometConfigs) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Same comment as in #3026