bench: add a VBS vs CMake vs Meson comparison harness with a baseline
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-05 07:30:45 +03:00
1 parent 1e670cb96b
commit 4bd2999b49
5 files changed
+150 -1

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
#!/usr/bin/env bash
# Compares VBS against CMake/Ninja and Meson on one generated C++ project.
# Usage: benchmarks/compare.sh [source-count] [--vbs PATH]
# Requires: vbs, cmake, ninja, meson (any missing tool is reported and skipped).
set -euo pipefail
sources=20
vbs_bin="${VBS:-vbs}"
while [ $# -gt 0 ]; do
case "$1" in
--vbs)
vbs_bin="$2"
shift 2
;;
*)
sources="$1"
shift
;;
esac
done
work="$(mktemp -d "${TMPDIR:-/tmp}/vbs-compare-XXXXXX")"
trap 'rm -rf "$work"' EXIT
proj="$work/proj"
mkdir -p "$proj/src"
main_body=""
for i in $(seq 1 "$sources"); do
cat >"$proj/src/f$i.cpp" <<EOF
int bench_fn_$i(int x) { return x + $i; }
EOF
main_body+="int bench_fn_$i(int);\n"
done
main_body+="int main() { int v = 0;\n"
for i in $(seq 1 "$sources"); do
main_body+="v += bench_fn_$i(1);\n"
done
main_body+="return v == 0 ? 1 : 0; }\n"
printf "%b" "$main_body" >"$proj/src/main.cpp"
cat >"$proj/build.cpp" <<EOF
#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
auto lib = p.static_library("bench_lib");
lib.cxx_standard(Void::Build::CxxStandard::Cxx26).sources(p.glob("src/f*.cpp"));
auto app = p.executable("bench_app");
app.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"src/main.cpp"})
.link(lib);
}
EOF
{
echo "cmake_minimum_required(VERSION 3.20)"
echo "project(bench LANGUAGES CXX)"
echo "set(CMAKE_CXX_STANDARD 26)"
echo "file(GLOB BENCH_SOURCES \${CMAKE_CURRENT_SOURCE_DIR}/src/f*.cpp)"
echo "add_library(bench_lib STATIC \${BENCH_SOURCES})"
echo "add_executable(bench_app src/main.cpp)"
echo "target_link_libraries(bench_app PRIVATE bench_lib)"
} >"$proj/CMakeLists.txt"
cat >"$proj/meson.build" <<'EOF'
project('bench', 'cpp')
bench_sources = []
foreach i : range(1, 21)
bench_sources += 'src/f' + i.to_string() + '.cpp'
endforeach
lib = static_library('bench_lib', bench_sources)
executable('bench_app', 'src/main.cpp', link_with : lib)
EOF
now_ms() { date +%s%N | cut -b1-13; }
time_run() { # label command...
local label="$1"
shift
local start
start=$(now_ms)
if "$@" >/dev/null 2>&1; then
echo "$label $(( $(now_ms) - start ))"
else
echo "$label FAILED"
fi
}
jobs="$(nproc 2>/dev/null || echo 4)"
echo "sources=$sources jobs=$jobs host=$(uname -m)"
if command -v "$vbs_bin" >/dev/null; then
time_run "vbs-cold " "$vbs_bin" build --project "$proj" --build-dir "$proj/build-vbs" --jobs "$jobs"
time_run "vbs-warm " "$vbs_bin" build --project "$proj" --build-dir "$proj/build-vbs" --jobs "$jobs"
else
echo "vbs SKIPPED (not in PATH)"
fi
if command -v cmake >/dev/null && command -v ninja >/dev/null; then
time_run "cmake-config" cmake -S "$proj" -B "$proj/build-cmake" -G Ninja -DCMAKE_BUILD_TYPE=Debug
time_run "cmake-cold " cmake --build "$proj/build-cmake" --parallel "$jobs"
time_run "cmake-warm " cmake --build "$proj/build-cmake" --parallel "$jobs"
else
echo "cmake SKIPPED (cmake/ninja not in PATH)"
fi
if command -v meson >/dev/null; then
time_run "meson-setup" meson setup "$proj/build-meson" "$proj"
time_run "meson-cold " meson compile -C "$proj/build-meson" -j "$jobs"
time_run "meson-warm " meson compile -C "$proj/build-meson" -j "$jobs"
else
echo "meson SKIPPED (not in PATH)"
fi
+2
View File
@@ -300,6 +300,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 103 (Test-Runner Parity: JUnit XML & Test Timeout)**: `vbs test` gained `--test-timeout SECONDS` (1..86400, validated before any project work) and `--junit FILE`, which writes a JUnit XML report aggregating every executed test target across profiles (`testcase` with classname/name/time, `failure` with exit status and captured output, escaped). Covered by `FullV1Tests.native_vbs_subproject_dependency_builds_without_cmake` (asserts the suite/testcase/failures fields) and a CLI contract for invalid timeouts.
- **Wave 104 (Competitor Benchmark Harness)**: `benchmarks/compare.sh` generates one C++ project and times VBS, CMake/Ninja and Meson cold and warm. First baseline (20 sources, 32 jobs): VBS 2578/209 ms, CMake configure 234 ms + build 98/9 ms, Meson setup 438 ms + compile 232/166 ms - VBS's per-invocation descriptor/toolchain work is the documented optimization target.
## Remaining future scope
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
+1
View File
@@ -107,4 +107,5 @@ Base HEAD: `fe0d1a6`
| Wave 101 (CMake File API shim) | `vbs ide generate` emits `.cmake/api/v1/reply` codemodel-v2 + directory + per-target JSON from the lowered graph | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; IDE integration test passes, full CTest 8/8) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, docs |
| Wave 102 (VoidLibrary migration trial) | Separate-clone `build.cpp` builds and tests VoidLibrary with VBS; assets in `contrib/voidlibrary-migration/`; upstream issue #61 | VERIFIED IN CLONE (23 actions, `vbs test` PASSED; no CMake) | `contrib/voidlibrary-migration/`, docs |
| Wave 103 (JUnit & test timeout) | `vbs test --junit FILE --test-timeout SECONDS` with aggregated JUnit XML | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; JUnit assertions and CLI contract pass, full CTest 8/8) | `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
| Wave 104 (Competitor benchmark harness) | `benchmarks/compare.sh` timing VBS vs CMake/Ninja vs Meson; baseline recorded | COMPLETE & VERIFIED (baseline observed; VBS 2578/209 ms vs CMake 98/9 ms on a 20-source fixture) | `benchmarks/compare.sh`, `docs/roadmap/22-superiority-and-gaps.md`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+19
View File
@@ -1456,6 +1456,25 @@ vbs test --project /tmp/opencode/vl-migrate --build-dir /tmp/opencode/vl-migrat
work (CLI contract).
- Full CTest: **8 / 8 passed** after both slices.
## Competitor Benchmark Baseline (GCC 16.2, pin `0002e74`)
```sh
dev cpp-gcc -c bash benchmarks/compare.sh 20 --vbs build/pinned/bin/vbs
```
Observed on this host (x86_64, 32 jobs, Debug, 20 generated sources):
```
vbs-cold 2578 vbs-warm 209
cmake-config 234 cmake-cold 98 cmake-warm 9
meson-setup 438 meson-cold 232 meson-warm 166
```
The harness (`benchmarks/compare.sh`) generates one project and times each tool's cold and warm
invocations. VBS is slower on this small fixture because every invocation recompiles/probes the
description; the numbers are recorded in [22](../roadmap/22-superiority-and-gaps.md) as the
optimization target.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+17 -1
View File
@@ -85,7 +85,23 @@ Concrete work this implies:
8. CI on real runners, sanitizer jobs, parser fuzzing.
9. Remote execution workers.
## 6. Acceptance gates
## 6. Observed baseline (2026-12-05, x86_64, GCC 16.2, Debug, `benchmarks/compare.sh 20`)
20 generated sources, 32 cores, wall-clock milliseconds:
| Tool | cold | warm/no-op |
| --- | --- | --- |
| VBS (`vbs build`) | 2578 | 209 |
| CMake + Ninja (configure / build) | 234 (configure) | 98 cold build, 9 warm |
| Meson (`setup` / `compile`) | 438 (setup) | 232 cold, 166 warm |
Interpretation: for a tiny project VBS pays for descriptor compilation, snapshot capture and
toolchain probing on every CI invocation, so its cold and warm times are higher than Ninja's
no-op. This is the clear performance target: cache the compiled descriptor and toolchain probe
across invocations, and keep snapshot work proportional to changed files. Larger fixtures are
needed before drawing scaling conclusions.
## 7. Acceptance gates
- Every platform claim has an observed run on that platform (or under Wine, clearly labelled).
- A package generator is accepted only when its output installs and runs from a clean machine image.