Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ You might want to adjust the results location to avoid overwriting previous resu
Environment configuration that was picked up by datafusion is logged at `info` level.
To verify that datafusion picked up your configuration, run the benchmarks with `RUST_LOG=info` or higher.

### Control iterations and timing

For benchmarks that run with `benchmark_runner`, which writes results that `bench.sh compare` reads, `bench.sh` forwards the query argument and the following environment variables to `benchmark_runner`.
It passes each option only when its variable is set.

| Variable | `benchmark_runner` option | Meaning |
| ------------------------------ | --------------------------------- | ------------------------------------------------------------------------------ |
| `[query]` argument of `bench.sh run` | `--query` | Runs one query |
| `BENCH_SUBGROUP` | `--subgroup` | Runs one subgroup of the suite |
| `SIMULATE_LATENCY=true` | `--simulate-latency` | Serves local files as if they were remote object storage |
| `ITERATIONS` | `--iterations` | Recorded iterations after one discarded warm-up iteration. Defaults to 5 unless `MAX_TIME` is set |
| `MAX_TIME` | `--max-time` | Runs each query adaptively for up to this many seconds |
| `LOCKSTEP_IN`, `LOCKSTEP_OUT` | `--lockstep-in`, `--lockstep-out` | FIFOs that let an orchestrator run two checkouts in lockstep. Set both or none |

```shell
ITERATIONS=10 ./bench.sh run tpch
MAX_TIME=30 ./bench.sh run tpch 21
```

## Comparing performance of main and a branch

For TPC-H
Expand Down
74 changes: 56 additions & 18 deletions benchmarks/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ DATAFUSION_DIR directory to use (default $DATAFUSION_DIR)
RESULTS_NAME folder where the benchmark files are stored
SIMULATE_LATENCY Serve local files as if they were remote object storage: per-request
latency, per-connection bandwidth and paginated LIST (default false)
ITERATIONS Recorded iterations per query (benchmark_runner benchmarks only)
MAX_TIME Seconds to run each query adaptively (benchmark_runner benchmarks only)
LOCKSTEP_IN Lockstep control FIFO (benchmark_runner benchmarks only, needs LOCKSTEP_OUT)
LOCKSTEP_OUT Lockstep report FIFO (benchmark_runner benchmarks only, needs LOCKSTEP_IN)
DATAFUSION_* Set the given datafusion configuration
"
exit 1
Expand Down Expand Up @@ -822,6 +826,47 @@ sql_results_file() {
echo "${RESULTS_DIR}/criterion/$1.json"
}

# Runs a SQL benchmark suite with benchmark_runner in its plain (non-Criterion)
# mode, which writes dfbench-format JSON that `compare` reads.
#
# Usage: run_benchmark_runner <results name> <suite> [suite options...]
#
# The results go to ${RESULTS_DIR}/<results name>.json. Pass suite options as
# flags, not environment variables, so that they show in the trace and do not
# leak into later benchmarks. This function forwards QUERY, BENCH_SUBGROUP,
# SIMULATE_LATENCY, MAX_TIME, LOCKSTEP_IN and LOCKSTEP_OUT when they are set.
# ITERATIONS defaults to 5, the count dfbench used, unless MAX_TIME is set.
run_benchmark_runner() {
local results_file="${RESULTS_DIR}/$1.json"
shift
local args=("$@" -o "${results_file}")
if [ -n "${QUERY}" ]; then
args+=(--query "${QUERY}")
fi
if [ -n "${BENCH_SUBGROUP}" ]; then
args+=(--subgroup "${BENCH_SUBGROUP}")
fi
if [ "${SIMULATE_LATENCY}" = "true" ]; then
args+=(--simulate-latency)
fi
if [ -n "${ITERATIONS}" ]; then
args+=(--iterations "${ITERATIONS}")
elif [ -z "${MAX_TIME}" ]; then
args+=(--iterations 5)
fi
if [ -n "${MAX_TIME}" ]; then
args+=(--max-time "${MAX_TIME}")
fi
if [ -n "${LOCKSTEP_IN}" ]; then
args+=(--lockstep-in "${LOCKSTEP_IN}")
fi
if [ -n "${LOCKSTEP_OUT}" ]; then
args+=(--lockstep-out "${LOCKSTEP_OUT}")
fi
echo "RESULTS_FILE: ${results_file}"
debug_run $CARGO_COMMAND --bin benchmark_runner -- "${args[@]}"
}

# Runs the tpch benchmark
run_tpch() {
SCALE_FACTOR=$1
Expand All @@ -830,16 +875,16 @@ run_tpch() {
exit 1
fi
FORMAT=$2
# The parquet run keeps the dfbench file name so that `compare` matches
# results from older checkouts.
if [ "$FORMAT" = "parquet" ]; then
RESULTS_NAME="tpch_sf${SCALE_FACTOR}"
else
RESULTS_NAME="tpch_${FORMAT}_sf${SCALE_FACTOR}"
fi
echo "Running tpch benchmark..."

debug_run env BENCH_NAME=tpch \
BENCH_RESULTS_FILE="$(sql_results_file tpch_sf${SCALE_FACTOR}_${FORMAT})" \
BENCH_SIZE="${SCALE_FACTOR}" \
DATA_DIR="${DATA_DIR}" \
TPCH_FILE_TYPE="${FORMAT}" \
SIMULATE_LATENCY="${SIMULATE_LATENCY}" \
${QUERY:+BENCH_QUERY="${QUERY}"} \
bash -c "$SQL_CARGO_COMMAND"
run_benchmark_runner "${RESULTS_NAME}" tpch --format "${FORMAT}" --scale-factor "${SCALE_FACTOR}" \
--path "${DATA_DIR}"
}

# Synthesizes two parquet datasets used to measure per-file metadata
Expand Down Expand Up @@ -1041,15 +1086,8 @@ run_tpch_mem() {
exit 1
fi
echo "Running tpch_mem benchmark..."

debug_run env BENCH_NAME=tpch \
BENCH_RESULTS_FILE="$(sql_results_file tpch_mem_sf${SCALE_FACTOR})" \
BENCH_SIZE="${SCALE_FACTOR}" \
DATA_DIR="${DATA_DIR}" \
TPCH_FILE_TYPE="mem" \
SIMULATE_LATENCY="${SIMULATE_LATENCY}" \
${QUERY:+BENCH_QUERY="${QUERY}"} \
bash -c "$SQL_CARGO_COMMAND"
run_benchmark_runner "tpch_mem_sf${SCALE_FACTOR}" tpch --format mem --scale-factor "${SCALE_FACTOR}" \
--path "${DATA_DIR}"
}

# Runs the tpcds benchmark
Expand Down