mbutrovich commented on code in PR #3028: URL: https://github.com/apache/datafusion-comet/pull/3028#discussion_r2665379984
########## spark/src/test/scala/org/apache/spark/sql/benchmark/CometHashExpressionBenchmark.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.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") { + prepareTable( + dir, + spark.sql(s""" + SELECT + CASE WHEN value % 100 = 0 THEN NULL ELSE CONCAT('string_', CAST(value AS STRING)) END AS c_str, Review Comment: Same comment as in #3026 > Would you add a succinct comment that gives a high level summary of the data distribution you're trying to create? We can certainly read through the CASE WHEN logic, but ... it's not obvious what the underlying values and math is hard. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
