Skip to content
Merged
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
3 changes: 2 additions & 1 deletion bench-orchestrator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ Vortex targets name an integration (`file` or `datasource`) and a scan engine (`
coverage made with `with_all_scans` runs every valid combination, and each combination becomes a
matrix entry of its own, `{id}-{engine}-{integration}-{scan}`, on its own machine. The default
entry keeps the case's id. Every entry of a case shares its `group`, and the PR comment job merges
a group's results into one table. `nightly` covers every scan on every benchmark; `develop` and
a group's results into one table. `nightly` covers every scan on every benchmark, except the
combinations in `NIGHTLY_SKIP_SCANS` (DataFusion datasource v1); `develop` and
`pr-scan` cover them on ClickBench and TPC-H SF=1 on NVMe. The other PR presets run the default
scans only.

Expand Down
39 changes: 23 additions & 16 deletions bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
),
"pr-all": "The union of the pr, pr-compact and pr-full matrices (action/bench-all).",
"pr-full": ("Every regular SQL benchmark at full PR target coverage (action/bench-sql-extended)."),
"nightly": "SF=100 TPC-H and nested TPC-H, and SF=10/100 TPC-DS, on NVMe and S3, with every Vortex scan.",
"nightly": (
"SF=100 TPC-H and nested TPC-H, and SF=10/100 TPC-DS, on NVMe and S3, with every Vortex scan "
"except DataFusion datasource v1."
),
}

# Reusable target coverage
Expand Down Expand Up @@ -74,9 +77,15 @@
# as a matrix entry, and so a machine, of its own, so covering them all adds machines, not wall time.


def with_all_scans(coverage: Coverage) -> Coverage:
"""Run every valid integration and scan engine combination for the `vortex` format."""
return replace(coverage, scans=ScanCoverage.ALL)
def with_all_scans(coverage: Coverage, skip: tuple[tuple[Integration, ScanEngine], ...] = ()) -> Coverage:
"""Run every valid integration and scan engine combination for the `vortex` format, except `skip`."""
return replace(coverage, scans=ScanCoverage.ALL, skip_scans=skip)


# Nightly leaves out DataFusion's datasource integration on the v1 scan, the legacy code path. At
# SF=10 and SF=100 it hangs on TPC-DS q62 until the job times out, and the runner shuts down during
# TPC-H q18. Nightly run 44843664966 lost six jobs to it.
NIGHTLY_SKIP_SCANS = ((Integration.DATASOURCE, ScanEngine.V1),)


DEFAULT = Coverage(DEFAULT_TARGETS)
Expand Down Expand Up @@ -106,7 +115,7 @@ def with_all_scans(coverage: Coverage) -> Coverage:
# Concrete benchmark cases

# TPC-DS SF=100 runs one target per job, each on its own machine, so a single slow target cannot
# push the others past the job timeout and lose their results.
# push the others past the job timeout and lose their results. It leaves out `NIGHTLY_SKIP_SCANS`.
TPCDS_SF100_TARGETS = (
(BenchmarkTarget(Engine.DATAFUSION, Format.PARQUET), "DataFusion, Parquet"),
(BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX), "DataFusion, Vortex"),
Expand All @@ -116,10 +125,6 @@ def with_all_scans(coverage: Coverage) -> Coverage:
BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX, Integration.FILE, ScanEngine.V1),
"DataFusion, Vortex, file v1",
),
(
BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX, Integration.DATASOURCE, ScanEngine.V1),
"DataFusion, Vortex, datasource v1",
),
(
BenchmarkTarget(Engine.DUCKDB, Format.VORTEX, Integration.FILE, ScanEngine.V1),
"DuckDB, Vortex, file v1",
Expand Down Expand Up @@ -379,8 +384,9 @@ def _tpcds_sf100_job(target: BenchmarkTarget) -> str:
name="Nested TPC-H on S3",
storage=Storage.S3,
scale_factor=100,
local_dir="vortex-bench/data/tpch-nested/100.0/list",
remote_key="tpch-nested/100.0/list",
# `scale_factor=100` generates the data under `100`, not `100.0`.
local_dir="vortex-bench/data/tpch-nested/100/list",
remote_key="tpch-nested/100/list",
runs={"nightly": DEFAULT},
),
BenchmarkCase(
Expand All @@ -395,17 +401,18 @@ def _tpcds_sf100_job(target: BenchmarkTarget) -> str:
),
)

# Presets whose every benchmark runs every valid integration and scan engine combination. TPC-DS
# SF=100 lists its targets one per job already, see `TPCDS_SF100_TARGETS`. PR presets other than
# `pr-scan` keep the default scans, so the extra machines are opt-in.
ALL_SCAN_PRESETS = ("nightly",)
# Presets whose every benchmark runs every valid integration and scan engine combination, except
# the combinations each one skips. TPC-DS SF=100 lists its targets one per job already, see
# `TPCDS_SF100_TARGETS`. PR presets other than `pr-scan` keep the default scans, so the extra
# machines are opt-in.
ALL_SCAN_PRESETS = {"nightly": NIGHTLY_SKIP_SCANS}


def _with_all_scan_presets(benchmark: BenchmarkCase) -> BenchmarkCase:
if benchmark in TPCDS_SF100_CASES:
return benchmark
runs = {
preset: with_all_scans(coverage) if preset in ALL_SCAN_PRESETS else coverage
preset: with_all_scans(coverage, ALL_SCAN_PRESETS[preset]) if preset in ALL_SCAN_PRESETS else coverage
for preset, coverage in benchmark.runs.items()
}
return replace(benchmark, runs=runs)
Expand Down
6 changes: 5 additions & 1 deletion bench-orchestrator/bench_orchestrator/ci_matrix/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dataclasses import dataclass, replace
from enum import Enum

from ..config import SCAN_COMBINATIONS, Benchmark, BenchmarkTarget, Format, SizeFormat
from ..config import SCAN_COMBINATIONS, Benchmark, BenchmarkTarget, Format, Integration, ScanEngine, SizeFormat
from .targets import TargetSet


Expand Down Expand Up @@ -38,6 +38,8 @@ class Coverage:
scans: ScanCoverage = ScanCoverage.DEFAULT
# Formats written after the queries only to record their file sizes. No query reads them.
size_formats: tuple[SizeFormat, ...] = ()
# Integration and scan engine combinations that `ScanCoverage.ALL` does not add.
skip_scans: tuple[tuple[Integration, ScanEngine], ...] = ()

def resolved_targets(self, benchmark: Benchmark) -> TargetSet:
"""Return the targets this coverage runs in `benchmark`, with every scan engine named.
Expand All @@ -54,6 +56,8 @@ def resolved_targets(self, benchmark: Benchmark) -> TargetSet:
if target.format is not Format.VORTEX:
continue
for integration, scan in SCAN_COMBINATIONS:
if (integration, scan) in self.skip_scans:
continue
candidate = replace(target, integration=integration, scan=scan)
if candidate not in resolved and candidate.is_supported(benchmark):
alternates.append(candidate)
Expand Down
11 changes: 9 additions & 2 deletions bench-orchestrator/bench_orchestrator/ci_matrix/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Render declarative benchmark coverage as GitHub Actions matrices."""

from ..config import Benchmark, BenchmarkTarget, Engine, Format, Integration, ScanEngine, SizeFormat
from ..config import SCAN_COMBINATIONS, Benchmark, BenchmarkTarget, Engine, Format, Integration, ScanEngine, SizeFormat
from .model import BenchmarkCase, Catalog, Coverage, ScanCoverage, Storage
from .targets import TargetSet
from .validate import validate_catalog
Expand Down Expand Up @@ -39,12 +39,19 @@ def merge_coverage(benchmark: Benchmark, coverages: list[Coverage]) -> Coverage:
targets = targets | resolved
formats.update(_data_formats(coverage, resolved))
size_formats.update(coverage.size_formats)
scans = ScanCoverage.ALL if any(c.scans is ScanCoverage.ALL for c in coverages) else ScanCoverage.DEFAULT
all_scans = [c for c in coverages if c.scans is ScanCoverage.ALL]
scans = ScanCoverage.ALL if all_scans else ScanCoverage.DEFAULT
return Coverage(
targets,
data_formats=tuple(fmt for fmt in _FORMAT_ORDER if fmt in formats),
scans=scans,
size_formats=tuple(fmt for fmt in SizeFormat if fmt in size_formats),
# Skip a combination only when every coverage that adds scans skips it.
skip_scans=tuple(
combination
for combination in SCAN_COMBINATIONS
if all_scans and all(combination in c.skip_scans for c in all_scans)
),
)


Expand Down
39 changes: 25 additions & 14 deletions bench-orchestrator/tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"duckdb-parquet",
"duckdb-vortex",
"datafusion-vortex-file-v1",
"datafusion-vortex-datasource-v1",
"duckdb-vortex-file-v1",
)
),
Expand All @@ -92,6 +91,8 @@
),
}
SCAN_SUFFIXES = ("datafusion-file-v1", "datafusion-datasource-v1", "duckdb-file-v1")
# Nightly skips DataFusion datasource v1, see `NIGHTLY_SKIP_SCANS`.
NIGHTLY_SCAN_SUFFIXES = ("datafusion-file-v1", "duckdb-file-v1")


def _entries(preset: str) -> list[dict[str, object]]:
Expand Down Expand Up @@ -134,6 +135,7 @@ def _group_targets(preset: str) -> dict[str, set[tuple[str, str]]]:
("duckdb", "vortex [file, v2]"),
("duckdb", "vortex [file, v1]"),
}
NIGHTLY_SCANS = ALL_SCANS - {("datafusion", "vortex [datasource, v1]")}
DEFAULT_SCANS = {
("datafusion", "parquet"),
("datafusion", "vortex [file, v2]"),
Expand All @@ -157,14 +159,16 @@ def test_matrix_presets(preset: str, expected_groups: tuple[str, ...]) -> None:
def test_every_scan_runs_on_a_machine_of_its_own(preset: str) -> None:
groups = _groups(preset)
entries = {entry["id"]: entry for entry in _entries(preset)}
suffixes = NIGHTLY_SCAN_SUFFIXES if preset == "nightly" else SCAN_SUFFIXES
scans = NIGHTLY_SCANS if preset == "nightly" else ALL_SCANS

assert groups["tpch-nvme"]["ids"] == ["tpch-nvme", *(f"tpch-nvme-{suffix}" for suffix in SCAN_SUFFIXES)]
assert ALL_SCANS <= _group_targets(preset)["tpch-nvme"]
assert groups["tpch-nvme"]["ids"] == ["tpch-nvme", *(f"tpch-nvme-{suffix}" for suffix in suffixes)]
assert scans <= _group_targets(preset)["tpch-nvme"]
# The default entry keeps the case's id and history and records its data; a scan's entry
# generates only the Vortex files it reads.
assert entries["tpch-nvme"]["records_data"] is True
assert ("datafusion", "vortex [file, v1]") not in _targets(entries["tpch-nvme"])
for suffix in SCAN_SUFFIXES:
for suffix in suffixes:
entry = entries[f"tpch-nvme-{suffix}"]
assert entry["group"] == "tpch-nvme"
assert len(_targets(entry)) == 1
Expand Down Expand Up @@ -217,22 +221,21 @@ def test_tpcds_sf100_runs_one_target_per_job() -> None:
entry for entry in _entries("nightly") if str(entry["id"]).startswith("tpcds-") and "-100-" in str(entry["id"])
]

assert len(nightly) == 14
assert len(nightly) == 12
assert all(len(_targets(entry)) == 1 for entry in nightly)
assert {target for entry in nightly for target in _targets(entry)} == ALL_SCANS
assert {target for entry in nightly for target in _targets(entry)} == NIGHTLY_SCANS
s3_keys = [entry["remote_key"] for entry in nightly if "remote_key" in entry]
assert len(s3_keys) == len(set(s3_keys)) == 7
assert len(s3_keys) == len(set(s3_keys)) == 6


def test_nightly_runs_every_scan() -> None:
def test_nightly_runs_every_scan_except_datasource_v1() -> None:
groups = _group_targets("nightly")

assert groups["tpch-s3"] == ALL_SCANS
assert groups["tpch-s3"] == NIGHTLY_SCANS
# Nested TPC-H reads list layouts, which the v2 scan cannot read yet.
assert groups["tpch-nested-s3"] == {
("datafusion", "parquet"),
("datafusion", "vortex [file, v1]"),
("datafusion", "vortex [datasource, v1]"),
("duckdb", "parquet"),
("duckdb", "vortex [file, v1]"),
}
Expand Down Expand Up @@ -260,20 +263,28 @@ def test_only_pr_scan_adds_scans_to_pull_requests(preset: str) -> None:
assert all(entry["id"] == entry["group"] for entry in _entries(preset))


def test_nightly_runs_every_valid_scan() -> None:
def test_nightly_runs_every_valid_scan_except_datasource_v1() -> None:
for benchmark_id, targets in _group_targets("nightly").items():
if "-100-" in benchmark_id:
continue
engines = {engine for engine, fmt in targets if fmt.startswith("vortex [")}
scans = {(engine, fmt) for engine, fmt in targets if fmt.startswith("vortex [")}
expected = {(engine, "vortex [file, v1]") for engine in engines} | (
{("datafusion", "vortex [datasource, v1]")} if "datafusion" in engines else set()
)
expected = {(engine, "vortex [file, v1]") for engine in engines}
if not benchmark_id.startswith("tpch-nested"):
expected |= {(engine, "vortex [file, v2]") for engine in engines}
assert scans == expected, benchmark_id


@pytest.mark.parametrize("preset", ["develop", "nightly", "pr-full", "pr-all"])
def test_s3_local_dir_names_the_generated_scale_factor(preset: str) -> None:
# prepare-data writes under the scale factor exactly as passed, so `100` and `100.0` differ.
for entry in _entries(preset):
if "local_dir" not in entry or "scale_factor" not in entry:
continue
numbers = [part for part in str(entry["local_dir"]).split("/") if part.replace(".", "", 1).isdigit()]
assert numbers in ([], [entry["scale_factor"]]), entry["id"]


def test_scan_targets_round_trip_through_targets_json() -> None:
entries = {entry["id"]: entry for entry in _entries("pr-scan")}

Expand Down
Loading