andygrove commented on code in PR #6805: URL: https://github.com/apache/datafusion-comet/pull/6805#discussion_r4234815794
########## spark/src/test/scala/org/apache/spark/sql/benchmark/CometShuffleReadKillBenchmark.scala: ########## @@ -0,0 +1,380 @@ +/* + * 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 + +import java.io.File +import java.nio.charset.StandardCharsets +import java.util.concurrent.atomic.AtomicLong +import java.util.concurrent.locks.LockSupport + +import scala.collection.mutable + +import org.apache.spark.{SparkConf, TaskContext} +import org.apache.spark.rdd.RDD +import org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd} +import org.apache.spark.sql.SparkSession +import org.apache.spark.sql.comet.{CometColumnarToRowExec, CometExec, CometNativeColumnarToRowExec, CometNativeExec} +import org.apache.spark.sql.execution.{InputAdapter, SparkPlan} +import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec +import org.apache.spark.sql.functions.col +import org.apache.spark.sql.internal.SQLConf + +import org.apache.comet.{CometConf, CometSparkSessionExtensions} + +/** + * Measures how long a Comet reduce task keeps running after it is killed while it reads its + * shuffle (review of apache/datafusion-comet#6805). + * + * One map task writes the whole shuffle as one block, and one reduce task reads it with a native + * project on top. On the `aqe` path the project reads the shuffle directly in native code + * (`ShuffleScan` over `CometShuffleBlockIterator`), which Comet does only behind an AQE query + * stage. On the `noaqe` path it reads it through `NativeBatchDecoderIterator`. + * + * Each trial runs the reduce task alone over the same shuffle. A kill trial cancels the job + * `KillAfterMs` after the task starts, with or without interrupting the task's thread, as + * `spark.job.interruptOnCancel` selects, and measures how long the task runs after the cancel, + * until its completion listeners run. A trial without a kill measures the whole task. + * + * With `variants=fix,head`, the default, the variants run in turn in one JVM. `head` sets the + * local property `spark.comet.benchmark.skipKillCheck`, which only a temporary benchmark build + * reads: it makes `readAsRawStream` skip its kill check, as #6805 did before the fix. Any other + * variant name only labels the classes on the classpath. `paths=aqe,noaqe` selects the read + * paths, `rows=N` the rows of the shuffle and `trials=N` the trials. + */ +object CometShuffleReadKillBenchmark extends CometBenchmarkBase { Review Comment: Could both new benchmarks come out of this PR? They read as tooling for this review, and both scaladocs say so. Their kill-check A/B sets `spark.comet.benchmark.skipKillCheck`, which only a temporary build reads. Nothing in the tree reads it, so the default `fix` and `head` variants here run the same code, and so do the two `killcheck` arms of `CometHashJoinTaskTimeBenchmark`. `CometHashJoinTaskTimeBenchmark` looks like the skew-join reproduction that #6528 says is not in a PR yet. I think it deserves its own PR against that issue, without the kill-check mode, where it can be reviewed on its own. At 1,084 lines it would be the largest benchmark in the tree. Dropping it here also fixes the red lint jobs, which all come from two `s` interpolators with nothing to interpolate at lines 633 and 658. -- 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]
