Skip to content

Commit ff154d8

Browse files
2010YOUY01Rich-T-kid
authored andcommitted
chore(benchmark): Fix/update compile profile benchmark (apache#21223)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes #. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> The existing compile profile benchmark is not able to run due to the benchmark binary change, and recently there are several new profiles added. This PR updates the benchmark. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> I have tested it locally ``` yongting@Yongtings-MacBook-Pro-2 ~/C/d/benchmarks (update-compile-prof…)> ./bench.sh run compile_profile ... Summary Profile Compile Run Size --------------------------------------------------- dev 80.81s 11.26s 238.6MB release 370.69s 1.01s 62.4MB ci 7.51s 7.69s 194.5MB ci-optimized 215.97s 1.13s 114.0MB release-nonlto 15.95s 1.05s 128.0MB profiling 953.66s 0.98s 75.9MB ``` Also, there is a ongoing work to run benchmarks in CI in case it break again: apache#21165 ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent b7ae2c6 commit ff154d8

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

‎benchmarks/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Generate the data required for the compile profile helper (TPC-H SF=1):
9595
./bench.sh data compile_profile
9696
```
9797

98-
Run the benchmark across all default Cargo profiles (`dev`, `release`, `ci`, `release-nonlto`):
98+
Run the benchmark across all default Cargo profiles (`dev`, `release`, `ci`, `ci-optimized`, `release-nonlto`, `profiling`):
9999

100100
```shell
101101
./bench.sh run compile_profile

‎benchmarks/compile_profile.py‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
"""Compile profile benchmark runner for DataFusion.
2121
22-
Builds the `tpch` benchmark binary with several Cargo profiles (e.g. `--release` or `--profile ci`), runs the full TPC-H suite against the Parquet data under `benchmarks/data/tpch_sf1`, and reports compile time, execution time, and resulting
23-
binary size.
22+
Builds the `dfbench` benchmark binary with several Cargo profiles
23+
(e.g. `--release` or `--profile ci`), runs the full TPC-H suite against
24+
the Parquet data under `benchmarks/data/tpch_sf1`, and reports compile
25+
time, execution time, and resulting binary size.
2426
2527
See `benchmarks/README.md` for usages.
2628
"""
@@ -40,12 +42,15 @@
4042
DEFAULT_ITERATIONS = 1
4143
DEFAULT_FORMAT = "parquet"
4244
DEFAULT_PARTITIONS: int | None = None
43-
TPCH_BINARY = "tpch.exe" if os.name == "nt" else "tpch"
45+
BENCHMARK_PACKAGE = "datafusion-benchmarks"
46+
BENCHMARK_BINARY = "dfbench.exe" if os.name == "nt" else "dfbench"
4447
PROFILE_TARGET_DIR = {
4548
"dev": "debug",
4649
"release": "release",
4750
"ci": "ci",
51+
"ci-optimized": "ci-optimized",
4852
"release-nonlto": "release-nonlto",
53+
"profiling": "profiling",
4954
}
5055

5156

@@ -62,7 +67,10 @@ def parse_args() -> argparse.Namespace:
6267
"--profiles",
6368
nargs="+",
6469
default=list(PROFILE_TARGET_DIR.keys()),
65-
help="Cargo profiles to test (default: dev release ci release-nonlto)",
70+
help=(
71+
"Cargo profiles to test "
72+
"(default: dev release ci ci-optimized release-nonlto profiling)"
73+
),
6674
)
6775
parser.add_argument(
6876
"--data",
@@ -84,9 +92,25 @@ def timed_run(command: Iterable[str]) -> float:
8492

8593
def cargo_build(profile: str) -> float:
8694
if profile == "dev":
87-
command = ["cargo", "build", "--bin", "tpch"]
95+
command = [
96+
"cargo",
97+
"build",
98+
"--package",
99+
BENCHMARK_PACKAGE,
100+
"--bin",
101+
"dfbench",
102+
]
88103
else:
89-
command = ["cargo", "build", "--profile", profile, "--bin", "tpch"]
104+
command = [
105+
"cargo",
106+
"build",
107+
"--profile",
108+
profile,
109+
"--package",
110+
BENCHMARK_PACKAGE,
111+
"--bin",
112+
"dfbench",
113+
]
90114
return timed_run(command)
91115

92116

@@ -102,14 +126,13 @@ def run_benchmark(profile: str, data_path: Path) -> float:
102126
binary_dir = PROFILE_TARGET_DIR.get(profile)
103127
if not binary_dir:
104128
raise ValueError(f"unknown profile '{profile}'")
105-
binary_path = REPO_ROOT / "target" / binary_dir / TPCH_BINARY
129+
binary_path = REPO_ROOT / "target" / binary_dir / BENCHMARK_BINARY
106130
if not binary_path.exists():
107131
raise FileNotFoundError(f"compiled binary not found at {binary_path}")
108132

109133
command = [
110134
str(binary_path),
111-
"benchmark",
112-
"datafusion",
135+
"tpch",
113136
"--iterations",
114137
str(DEFAULT_ITERATIONS),
115138
"--path",
@@ -132,7 +155,7 @@ def run_benchmark(profile: str, data_path: Path) -> float:
132155

133156
def binary_size(profile: str) -> int:
134157
binary_dir = PROFILE_TARGET_DIR[profile]
135-
binary_path = REPO_ROOT / "target" / binary_dir / TPCH_BINARY
158+
binary_path = REPO_ROOT / "target" / binary_dir / BENCHMARK_BINARY
136159
return binary_path.stat().st_size
137160

138161

0 commit comments

Comments
 (0)