Skip to content

Commit 929fc50

Browse files
bench: cover multi-key sorts over small input batches
1 parent 91cd7ff commit 929fc50

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎benchmarks/bench.sh‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ hj: Benchmark for simple hash joins, testing various join sc
177177
smj: Benchmark for simple sort merge joins, testing various join scenarios
178178
dict: Benchmark for dictionary-encoded group-by scenarios
179179
array_agg_distinct: 1000K-group, two-row-per-group array_agg(DISTINCT) benchmark
180+
sort_small_batches: Two-key sort over small in-memory input batches
180181
compile_profile: Compile and execute TPC-H across selected Cargo profiles, reporting timing and binary size
181182
182183
@@ -296,6 +297,9 @@ main() {
296297
# Data is generated inline by the suite's load SQL.
297298
echo "projection_subquery: no external data to generate"
298299
;;
300+
sort_small_batches)
301+
echo "sort_small_batches: no external data to generate"
302+
;;
299303
asof_join)
300304
data_asof_join
301305
;;
@@ -698,6 +702,9 @@ main() {
698702
array_agg_distinct)
699703
run_array_agg_distinct
700704
;;
705+
sort_small_batches)
706+
run_sort_small_batches
707+
;;
701708
compile_profile)
702709
run_compile_profile "${PROFILE_ARGS[@]}"
703710
;;
@@ -1841,6 +1848,14 @@ run_array_agg_distinct() {
18411848
bash -c "$SQL_CARGO_COMMAND"
18421849
}
18431850

1851+
run_sort_small_batches() {
1852+
echo "Running sort_small_batches benchmark..."
1853+
debug_run env BENCH_NAME=sort_small_batches \
1854+
BENCH_RESULTS_FILE="$(sql_results_file sort_small_batches)" \
1855+
${QUERY:+BENCH_QUERY="${QUERY}"} \
1856+
bash -c "$SQL_CARGO_COMMAND"
1857+
}
1858+
18441859

18451860
compare_benchmarks() {
18461861
BASE_RESULTS_DIR="${SCRIPT_DIR}/results"

‎benchmarks/sql_benchmarks/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ in the community:
4242
| `pwmj` | Piecewise merge join: classic `INNER`/`LEFT`/`RIGHT`/`FULL` joins over `lhs.key < rhs.key`. Subgroups (`--subgroup`) are match regimes: `no_match`, `null_heavy`, `half_match`, `selective`, `all_match`. Generated with `range()`, no data needed. |
4343
| `smj` | Sort‑merge join benchmark |
4444
| `sort tpch` | Sorting benchmarks against the TPC-H lineitem table |
45+
| `sort_small_batches` | Two-key in-memory sort over two million rows in 32-row batches; data is generated before timing. |
4546
| `taxi` | NYC taxi dataset benchmark |
4647
| `tpcds` | TPC‑DS queries |
4748
| `tpch` | TPC‑H queries |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name Q01
2+
group sort_small_batches
3+
4+
load
5+
-- Keep small input batches in memory; setup runs outside the timed query.
6+
SET datafusion.execution.target_partitions = 1;
7+
8+
load
9+
SET datafusion.execution.batch_size = 32;
10+
11+
load
12+
CREATE TABLE sort_input AS
13+
SELECT value % 997 AS sort_key, value
14+
FROM range(2000000);
15+
16+
init
17+
SET datafusion.execution.batch_size = 8192;
18+
19+
expect_plan SortExec
20+
21+
run
22+
-- Two keys exercise row-format merging of the small sorted runs.
23+
SELECT sort_key, value FROM sort_input ORDER BY sort_key, value;
24+
25+
cleanup
26+
DROP TABLE sort_input;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
description = "Two-key sort over small in-memory input batches"
2+
3+
[[examples]]
4+
command = "cargo run --release --bin benchmark_runner -- sort_small_batches --iterations 5"
5+
description = "Sort two million rows loaded in 32-row batches."

0 commit comments

Comments
 (0)