Skip to content

build: add benchmark build scaffolding#825

Merged
wgtmac merged 1 commit into
apache:mainfrom
timothyw553:tw/benchmark-infra
Jul 12, 2026
Merged

build: add benchmark build scaffolding#825
wgtmac merged 1 commit into
apache:mainfrom
timothyw553:tw/benchmark-infra

Conversation

@timothyw553

@timothyw553 timothyw553 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in benchmark build path so future C++ microbenchmarks can live in-tree without affecting normal builds. Benchmarks stay disabled by default, and this PR keeps the executable intentionally small so reviewers can focus on CMake/Meson wiring and Google Benchmark integration.

  • Adds ICEBERG_BUILD_BENCHMARKS for CMake and a disabled-by-default benchmarks Meson feature.
  • Wires src/iceberg/benchmark into both build systems.
  • Adds Google Benchmark dependency setup for CMake and Meson.
  • Adds a tiny smoke benchmark so the new target is buildable in isolation.

Part of #690.

Stack

This is PR 1 of 2.

PR 2 adds the actual metrics evaluator benchmark cases on top of this scaffolding: timothyw553#1.

Test Plan

  • Configured benchmark-enabled CMake build with -DICEBERG_BUILD_BENCHMARKS=ON.
  • Built metrics_evaluator_benchmark on this branch.
  • Ran the smoke benchmark with --benchmark_min_time=0.01s.
  • Re-ran the default build and test suite on the top of the stack: 18/18 tests passed.
  • Meson wiring is syntax-reviewed but not locally executed because meson is not installed in this shell.

Verification Commands

cmake -S . -B build-bench-stack -G Ninja \
  -DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=NEVER \
  -DCMAKE_IGNORE_PREFIX_PATH=/opt/homebrew/anaconda3 \
  -DCMAKE_PREFIX_PATH='/opt/homebrew/opt/snappy;/opt/homebrew/opt/zstd' \
  -DICEBERG_BUILD_BENCHMARKS=ON
cmake --build build-bench-stack --target metrics_evaluator_benchmark
build-bench-stack/src/iceberg/benchmark/metrics_evaluator_benchmark --benchmark_min_time=0.01s
cmake --build build
ctest --test-dir build --output-on-failure

@timothyw553 timothyw553 force-pushed the tw/benchmark-infra branch 2 times, most recently from e922f8f to 0717dac Compare July 8, 2026 22:34
Comment thread src/iceberg/benchmark/CMakeLists.txt Outdated

fetchcontent_declare(google_benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.8.4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we use the commit SHA like gtest?

@timothyw553 timothyw553 Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. I pinned Google Benchmark to the v1.8.4 release commit SHA (a4cf155615c63e019ae549e31703bf367df5b471) and kept the version as an inline comment, matching the gtest style.

@wgtmac wgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! I just left some comments.

namespace iceberg {
namespace {

void BM_BenchmarkSmoke(benchmark::State& state) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the file name looks odd since it's unrelated to metrics evaluator.

@timothyw553 timothyw553 Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed the smoke benchmark so it isn't tied to metrics evaluator yet.

OFF
CACHE BOOL "" FORCE)

fetchcontent_declare(google_benchmark

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this to IcebergThirdpartyToolchain.cmake? I think we should move GTest to there, too.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR follows the gtest way ;) Maybe we can change that together, I have the same feeling at the first look.

@timothyw553 timothyw553 Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened #829 to track moving both GTest and Google Benchmark into IcebergThirdpartyToolchain.cmake. I’ll keep this PR scoped and follow the current GTest pattern here.

-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DICEBERG_BUILD_SQL_CATALOG=ON \
-DICEBERG_BUILD_BENCHMARKS=ON \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this but do not change other workflows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just so the benchmarks get linted. I previously did not have this and cpp-linter failed because the benchmark source wasn’t in compile_commands.json.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's keep it for now.

Comment thread src/iceberg/benchmark/CMakeLists.txt Outdated
CONFIG)
fetchcontent_makeavailable(google_benchmark)

add_executable(metrics_evaluator_benchmark metrics_evaluator_benchmark.cc)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add EXCLUDE_FROM_ALL so it does not build by default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I don’t think we need it. I set benchmarks to be off by default (see my CMakeLists.txt change), and when users set ICEBERG_BUILD_BENCHMARKS=ON, the benchmark target should build normally.

@timothyw553 timothyw553 Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... if we did add EXCLUDE_FROM_ALL then users would have to do

cmake --build build --target benchmark_a benchmark_b benchmark_c benchmark_d

to me a better pattern seems to be:

cmake -S . -B build -DICEBERG_BUILD_BENCHMARKS=ON
cmake --build build

and if user did want to just build specific targets then they can still do:

cmake --build build --target metrics_evaluator_benchmark

what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DICEBERG_BUILD_SQL_CATALOG=ON \
-DICEBERG_BUILD_BENCHMARKS=ON \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Let's keep it for now.

@wgtmac wgtmac merged commit 263795e into apache:main Jul 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants