|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +# Compare shuffle write sizes between Spark and Comet shuffle. |
| 22 | +# |
| 23 | +# This benchmark measures actual shuffle write bytes reported by Spark |
| 24 | +# to quantify the overhead of Comet's Arrow IPC shuffle format. |
| 25 | +# See https://github.com/apache/datafusion-comet/issues/3882 |
| 26 | +# |
| 27 | +# Prerequisites: |
| 28 | +# - SPARK_HOME set to a Spark 3.5 installation |
| 29 | +# - Comet JAR built (make) |
| 30 | +# - Input parquet data generated (see generate_data.py) |
| 31 | +# |
| 32 | +# Usage: |
| 33 | +# ./run_shuffle_size_benchmark.sh /path/to/parquet/data |
| 34 | +# |
| 35 | +# Environment variables: |
| 36 | +# COMET_JAR Path to Comet JAR (default: auto-detected from repo) |
| 37 | +# SPARK_MASTER Spark master URL (default: local[*]) |
| 38 | +# EXECUTOR_MEMORY Executor memory (default: 16g) |
| 39 | +# OFFHEAP_SIZE Off-heap memory for Comet (default: 16g) |
| 40 | + |
| 41 | +set -e |
| 42 | + |
| 43 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 44 | +DATA_PATH="${1:?Usage: $0 /path/to/parquet/data}" |
| 45 | +COMET_JAR="${COMET_JAR:-$SCRIPT_DIR/../../spark/target/comet-spark-spark3.5_2.12-0.15.0-SNAPSHOT.jar}" |
| 46 | +SPARK_MASTER="${SPARK_MASTER:-local[*]}" |
| 47 | +EXECUTOR_MEMORY="${EXECUTOR_MEMORY:-16g}" |
| 48 | +OFFHEAP_SIZE="${OFFHEAP_SIZE:-16g}" |
| 49 | + |
| 50 | +if [ -z "$SPARK_HOME" ]; then |
| 51 | + echo "Error: SPARK_HOME is not set" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | + |
| 55 | +if [ ! -f "$COMET_JAR" ]; then |
| 56 | + echo "Error: Comet JAR not found at $COMET_JAR" |
| 57 | + echo "Build with 'make' or set COMET_JAR to the correct path." |
| 58 | + exit 1 |
| 59 | +fi |
| 60 | + |
| 61 | +echo "========================================" |
| 62 | +echo "Shuffle Size Comparison Benchmark" |
| 63 | +echo "========================================" |
| 64 | +echo "Data path: $DATA_PATH" |
| 65 | +echo "Comet JAR: $COMET_JAR" |
| 66 | +echo "Spark master: $SPARK_MASTER" |
| 67 | +echo "Executor memory: $EXECUTOR_MEMORY" |
| 68 | +echo "Off-heap size: $OFFHEAP_SIZE" |
| 69 | +echo "========================================" |
| 70 | + |
| 71 | +# Run Spark baseline (no Comet) |
| 72 | +echo "" |
| 73 | +echo ">>> Running SPARK (no Comet) shuffle size benchmark..." |
| 74 | +$SPARK_HOME/bin/spark-submit \ |
| 75 | + --master "$SPARK_MASTER" \ |
| 76 | + --executor-memory "$EXECUTOR_MEMORY" \ |
| 77 | + --conf spark.comet.enabled=false \ |
| 78 | + "$SCRIPT_DIR/run_benchmark.py" \ |
| 79 | + --data "$DATA_PATH" \ |
| 80 | + --mode spark \ |
| 81 | + --benchmark shuffle-size |
| 82 | + |
| 83 | +# Run Comet Native shuffle |
| 84 | +echo "" |
| 85 | +echo ">>> Running COMET NATIVE shuffle size benchmark..." |
| 86 | +$SPARK_HOME/bin/spark-submit \ |
| 87 | + --master "$SPARK_MASTER" \ |
| 88 | + --executor-memory "$EXECUTOR_MEMORY" \ |
| 89 | + --jars "$COMET_JAR" \ |
| 90 | + --driver-class-path "$COMET_JAR" \ |
| 91 | + --conf spark.executor.extraClassPath="$COMET_JAR" \ |
| 92 | + --conf spark.plugins=org.apache.spark.CometPlugin \ |
| 93 | + --conf spark.shuffle.manager=org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager \ |
| 94 | + --conf spark.sql.extensions=org.apache.comet.CometSparkSessionExtensions \ |
| 95 | + --conf spark.memory.offHeap.enabled=true \ |
| 96 | + --conf spark.memory.offHeap.size="$OFFHEAP_SIZE" \ |
| 97 | + --conf spark.comet.enabled=true \ |
| 98 | + --conf spark.comet.exec.shuffle.mode=native \ |
| 99 | + --conf spark.comet.explainFallback.enabled=true \ |
| 100 | + "$SCRIPT_DIR/run_benchmark.py" \ |
| 101 | + --data "$DATA_PATH" \ |
| 102 | + --mode native \ |
| 103 | + --benchmark shuffle-size |
| 104 | + |
| 105 | +echo "" |
| 106 | +echo "========================================" |
| 107 | +echo "BENCHMARK COMPLETE" |
| 108 | +echo "========================================" |
| 109 | +echo "Compare 'Shuffle write' and 'Bytes/record' between the two runs above." |
0 commit comments