You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ga...@apache.org on 2026/07/12 01:39:36 UTC
(iceberg-cpp) branch main updated: build: add benchmark build scaffolding (#825)
This is an automated email from the ASF dual-hosted git repository.
wgtmac pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 263795e9 build: add benchmark build scaffolding (#825)
263795e9 is described below
commit 263795e9288fe4421c9248888ddd16aba677b8a4
Author: Timothy Wang <ti...@gmail.com>
AuthorDate: Sat Jul 11 18:39:30 2026 -0700
build: add benchmark build scaffolding (#825)
## 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/iceberg-cpp#1.
## Test Plan
- [x] Configured benchmark-enabled CMake build with
`-DICEBERG_BUILD_BENCHMARKS=ON`.
- [x] Built `metrics_evaluator_benchmark` on this branch.
- [x] Ran the smoke benchmark with `--benchmark_min_time=0.01s`.
- [x] 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
```bash
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
```
---
.github/workflows/cpp-linter.yml | 1 +
CMakeLists.txt | 1 +
meson.options | 7 +++++
src/iceberg/CMakeLists.txt | 4 +++
src/iceberg/benchmark/CMakeLists.txt | 41 ++++++++++++++++++++++++++++
src/iceberg/benchmark/benchmark_smoke.cc | 46 ++++++++++++++++++++++++++++++++
src/iceberg/benchmark/meson.build | 26 ++++++++++++++++++
src/iceberg/meson.build | 4 +++
subprojects/google-benchmark.wrap | 30 +++++++++++++++++++++
9 files changed, 160 insertions(+)
diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml
index 3dcf7ba4..44dd6e35 100644
--- a/.github/workflows/cpp-linter.yml
+++ b/.github/workflows/cpp-linter.yml
@@ -77,6 +77,7 @@ jobs:
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DICEBERG_BUILD_SQL_CATALOG=ON \
+ -DICEBERG_BUILD_BENCHMARKS=ON \
-DICEBERG_SQL_SQLITE=ON \
-DICEBERG_SQL_POSTGRESQL=ON \
-DICEBERG_SQL_MYSQL=ON
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f882356..db54b24e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,6 +40,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(ICEBERG_BUILD_STATIC "Build static library" ON)
option(ICEBERG_BUILD_SHARED "Build shared library" OFF)
option(ICEBERG_BUILD_TESTS "Build tests" ON)
+option(ICEBERG_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(ICEBERG_BUILD_BUNDLE "Build the battery included library" ON)
option(ICEBERG_BUILD_REST "Build rest catalog client" ON)
option(ICEBERG_BUILD_REST_INTEGRATION_TESTS "Build rest catalog integration tests" OFF)
diff --git a/meson.options b/meson.options
index c5357488..0448c61d 100644
--- a/meson.options
+++ b/meson.options
@@ -52,3 +52,10 @@ option(
)
option('tests', type: 'feature', description: 'Build tests', value: 'enabled')
+
+option(
+ 'benchmarks',
+ type: 'feature',
+ description: 'Build benchmarks',
+ value: 'disabled',
+)
diff --git a/src/iceberg/CMakeLists.txt b/src/iceberg/CMakeLists.txt
index da820c26..049a6125 100644
--- a/src/iceberg/CMakeLists.txt
+++ b/src/iceberg/CMakeLists.txt
@@ -365,3 +365,7 @@ endif()
if(ICEBERG_BUILD_TESTS)
add_subdirectory(test)
endif()
+
+if(ICEBERG_BUILD_BENCHMARKS)
+ add_subdirectory(benchmark)
+endif()
diff --git a/src/iceberg/benchmark/CMakeLists.txt b/src/iceberg/benchmark/CMakeLists.txt
new file mode 100644
index 00000000..0227c387
--- /dev/null
+++ b/src/iceberg/benchmark/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set(BENCHMARK_ENABLE_GTEST_TESTS
+ OFF
+ CACHE BOOL "" FORCE)
+set(BENCHMARK_ENABLE_INSTALL
+ OFF
+ CACHE BOOL "" FORCE)
+set(BENCHMARK_ENABLE_TESTING
+ OFF
+ CACHE BOOL "" FORCE)
+
+fetchcontent_declare(google_benchmark
+ GIT_REPOSITORY https://github.com/google/benchmark.git
+ GIT_TAG a4cf155615c63e019ae549e31703bf367df5b471 # v1.8.4
+ FIND_PACKAGE_ARGS
+ NAMES
+ benchmark
+ CONFIG)
+fetchcontent_makeavailable(google_benchmark)
+
+add_executable(benchmark_smoke benchmark_smoke.cc)
+target_link_libraries(benchmark_smoke
+ PRIVATE "$<IF:$<TARGET_EXISTS:iceberg_static>,iceberg_static,iceberg_shared>"
+ "$<IF:$<TARGET_EXISTS:benchmark::benchmark>,benchmark::benchmark,benchmark>"
+)
diff --git a/src/iceberg/benchmark/benchmark_smoke.cc b/src/iceberg/benchmark/benchmark_smoke.cc
new file mode 100644
index 00000000..abcc3555
--- /dev/null
+++ b/src/iceberg/benchmark/benchmark_smoke.cc
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <benchmark/benchmark.h>
+
+namespace iceberg {
+namespace {
+
+void BM_BenchmarkSmoke(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ benchmark::DoNotOptimize(state.iterations());
+ }
+
+ state.SetItemsProcessed(state.iterations());
+}
+
+BENCHMARK(BM_BenchmarkSmoke);
+
+} // namespace
+} // namespace iceberg
+
+int main(int argc, char** argv) {
+ benchmark::Initialize(&argc, argv);
+ if (benchmark::ReportUnrecognizedArguments(argc, argv)) {
+ return 1;
+ }
+ benchmark::RunSpecifiedBenchmarks();
+ benchmark::Shutdown();
+ return 0;
+}
diff --git a/src/iceberg/benchmark/meson.build b/src/iceberg/benchmark/meson.build
new file mode 100644
index 00000000..affc34e0
--- /dev/null
+++ b/src/iceberg/benchmark/meson.build
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+benchmark_dep = dependency('benchmark', required: true)
+
+benchmark_smoke = executable(
+ 'benchmark_smoke',
+ sources: files('benchmark_smoke.cc'),
+ dependencies: [iceberg_dep, benchmark_dep],
+)
+
+benchmark('benchmark_smoke', benchmark_smoke)
diff --git a/src/iceberg/meson.build b/src/iceberg/meson.build
index e5158a4b..7340bfa2 100644
--- a/src/iceberg/meson.build
+++ b/src/iceberg/meson.build
@@ -337,3 +337,7 @@ subdir('inspect')
if get_option('tests').enabled()
subdir('test')
endif
+
+if get_option('benchmarks').enabled()
+ subdir('benchmark')
+endif
diff --git a/subprojects/google-benchmark.wrap b/subprojects/google-benchmark.wrap
new file mode 100644
index 00000000..51f4e24d
--- /dev/null
+++ b/subprojects/google-benchmark.wrap
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[wrap-file]
+directory = benchmark-1.8.4
+source_url = https://github.com/google/benchmark/archive/refs/tags/v1.8.4.tar.gz
+source_filename = benchmark-1.8.4.tar.gz
+source_hash = 3e7059b6b11fb1bbe28e33e02519398ca94c1818874ebed18e504dc6f709be45
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/google-benchmark_1.8.4-5/benchmark-1.8.4.tar.gz
+patch_filename = google-benchmark_1.8.4-5_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/google-benchmark_1.8.4-5/get_patch
+patch_hash = 671ffed65f1e95e8c20edb7a06eb54476797e58169160b255f52dc71f4b83957
+wrapdb_version = 1.8.4-5
+
+[provide]
+dependency_names = benchmark, benchmark_main