navid/veins / impl-rust / veins-cpprewrite/BENCHES.md
BENCHES.md
← veins-cpprewrite · 8726 bytes · raw · download
Showing source. View rendered.
# veins benchmarks
Two reproducible benchmark sets are kept here: a local-core comparison that includes
the Rust subset, and the native network comparison between the C++ rewrite and Spectre.
## Local core: Rust subset vs C++ vs Spectre
Generated 2026-11-27 by `bench/core_bench.py`.
### Environment
| Implementation | Binary |
|:---|:---|
| Rust | `veins-rust v0.1.0 (veins-store 1)` |
| C++ | `veins v0.0.1 (veins-store 1)` |
| Spectre | `veins v0.0.1 (veins-store 1)` |
```
host: Darwin arm64
cpu: Apple M2
repeats: 5 (median reported)
cpu pinning: no
```
### Scope
The Rust binary implements the local-core subset: `init`, `status`, `log`, `go`/`commit`, `co`/`checkout`, `bmk set|ls|rm`, `self-test`, and `version`.
It uses the same FastCDC parameters, BLAKE3 object IDs, zstd level 1, pack/index layout, operation log, and stat-cache invalidation window as the reference.
The subset does not implement merge/conflict objects, rebase/undo, the git bridge, ignore files, or the network protocol. The workload below contains no renames, ignores, merges, or network traffic, so the measured local operations are directly comparable.
### Workload
- Base snapshot: 2.95 MiB, 42 files.
- 20 edit/commit revisions, 8 checkouts, 5 repeats, median reported.
- Each revision rewrites about 1% of a 120,000-line generated C file and three small module files.
- Each `go` performs the same snapshot, describe, and new-empty-change sequence as the reference, including all operation-log writes.
- Store size includes `.veins` packs, indexes, operation heads, the native commit map, and the stat cache.
### Summary
| Metric | Rust | C++ | Spectre | C++ / Rust | Spectre / Rust |
|:---|---:|---:|---:|---:|---:|
| Commit total [s] | 0.252 (0.250-0.262) | 0.280 (0.279-0.291) | 0.310 (0.309-0.330) | 1.11x | 1.23x |
| Checkout total [s] | 0.162 (0.161-0.165) | 0.175 (0.172-0.179) | 0.181 (0.179-0.196) | 1.08x | 1.12x |
| Store size [MiB] | 8.28 (8.28-8.37) | 8.28 (8.28-8.37) | 10.60 (10.60-10.69) | 1.00x | 1.28x |
Each cell is the median with the observed min-max range in parentheses.
A ratio above 1 means the other implementation took longer or used more space than Rust.
### Repeats
| Repeat | Rust commit [s] | C++ commit [s] | Spectre commit [s] | Rust checkout [s] | C++ checkout [s] | Spectre checkout [s] |
|:---|---:|---:|---:|---:|---:|---:|
| 1 | 0.262 | 0.291 | 0.330 | 0.165 | 0.172 | 0.195 |
| 2 | 0.250 | 0.280 | 0.310 | 0.162 | 0.172 | 0.196 |
| 3 | 0.252 | 0.281 | 0.309 | 0.161 | 0.179 | 0.179 |
| 4 | 0.252 | 0.279 | 0.309 | 0.162 | 0.175 | 0.179 |
| 5 | 0.257 | 0.280 | 0.311 | 0.165 | 0.177 | 0.181 |
### Notes
- Both implementations use the same FastCDC parameters, BLAKE3 object IDs, zstd level 1, pack/index layout, operation log, and stat-cache racy window.
- Each `go` performs the same snapshot, describe, and new-empty-change sequence in both implementations, including three operation writes.
- The Rust subset omits ignore-file parsing and similarity-based rename detection. This workload has neither ignore files nor renames, so both implementations see the same file set and perform the same exact-rename scan.
- Rust and C++ store sizes are equal at this resolution; Spectre stores the same logical history with a different packing policy.
- This is a single-machine run. Treat differences below roughly 5% as noise.
### Reproduce
```sh
cd veins-rust
cargo build --release
cd ../veins-cpprewrite
python3 bench/core_bench.py --repeats 5 --markdown-out bench/core_bench.md
```
## Networking: C++ rewrite vs Spectre
Generated 2026-11-27 16:15:11 UTC by `bench/net_bench.sh`.
The Rust subset is not included in this section because it does not implement a
network transport.
### Environment
```
host: Darwin arm64
cpu: Apple M2
hyperfine: hyperfine 1.20.0
c++ vn: veins v0.0.1 (veins-store 1)
spectre vn: veins v0.0.1 (veins-store 1)
runs: 10 (clone/fetch/push/checkout), 20 (whoami)
warmup: 1 (clone/fetch/push/checkout), 2 (whoami)
```
### Dataset
- `bench_src`: 361 working files, 5.7M on disk including packs.
- 360 small text files in 18 directories.
- 2 MiB `big_old.bin` in the `oldbig` history.
- 1 MiB `big_head.bin` in `main`.
- `push_pristine`: a separate 20-file repository, so push does not transfer the large dataset.
### What each benchmark does
| Benchmark | Operation |
|:---|:---|
| `clone-file` | Full clone over `file://`: handshake, refs, history, head chunks, checkout. Includes spawning one local server per run. |
| `fetch-file` | `vn fetch origin` with no new remote refs. Both clients start from a full `-blobs:all` clone. |
| `lazy-checkout-file` | `vn co oldbig` in a `-blobs:none` clone, fetching the 2 MiB old blob from the promisor over `file://`. |
| `push-file` | Push one new commit from a prepared client to a freshly reset copy of `push_pristine` over `file://`. |
| `whoami-file` | Connect, authenticate, `WHOAMI`, close over `file://`. |
| `clone-ssh` | Full clone over `ssh://`, using a local `ssh` shim that runs the remote `vn serve -stdio` command. |
| `clone-tls` | Full clone over TLS 1.3 with a pinned self-signed certificate. Uses long-running servers. |
| `whoami-tls` | Connect, authenticate, `WHOAMI`, close over TLS 1.3. |
Lower is better. Hyperfine reports wall-clock time; the relative column is against the fastest command.
### Summary
| Benchmark | C++ mean | Spectre mean | Spectre / C++ |
|:---|---:|---:|---:|
| Clone file:// | 35.9 ms | 61.0 ms | 1.70x |
| Fetch file:// | 24.6 ms | 31.2 ms | 1.27x |
| Lazy checkout file:// | 253.1 ms | 420.2 ms | 1.66x |
| Push file:// | 17.0 ms | 16.0 ms | 0.94x |
| Whoami file:// | 9.7 ms | 12.5 ms | 1.28x |
| Clone ssh:// | 42.5 ms | 66.6 ms | 1.57x |
| Clone TLS 1.3 | 37.9 ms | 64.9 ms | 1.71x |
| Whoami TLS 1.3 | 10.0 ms | 14.8 ms | 1.48x |
A ratio above 1 means Spectre took longer than C++.
### Results
#### Clone over file://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 35.9 ± 0.3 | 35.5 | 36.3 | 1.00 |
| `Spectre` | 61.0 ± 1.8 | 58.2 | 63.4 | 1.70 ± 0.05 |
#### Fetch over file://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 24.6 ± 0.4 | 23.9 | 25.1 | 1.00 |
| `Spectre` | 31.2 ± 1.0 | 30.2 | 32.6 | 1.27 ± 0.04 |
#### Lazy checkout over file://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 253.1 ± 7.1 | 247.7 | 272.4 | 1.00 |
| `Spectre` | 420.2 ± 14.5 | 402.5 | 451.8 | 1.66 ± 0.07 |
#### Push over file://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 17.0 ± 6.8 | 12.3 | 32.0 | 1.06 ± 0.43 |
| `Spectre` | 16.0 ± 0.4 | 15.7 | 16.8 | 1.00 |
#### Whoami over file://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 9.7 ± 0.6 | 8.7 | 10.5 | 1.00 |
| `Spectre` | 12.5 ± 0.2 | 12.1 | 12.9 | 1.28 ± 0.08 |
#### Clone over ssh://
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 42.5 ± 0.4 | 41.9 | 43.2 | 1.00 |
| `Spectre` | 66.6 ± 1.2 | 64.4 | 67.8 | 1.57 ± 0.03 |
#### Clone over TLS 1.3
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 37.9 ± 1.4 | 35.9 | 39.8 | 1.00 |
| `Spectre` | 64.9 ± 1.6 | 62.0 | 67.7 | 1.71 ± 0.07 |
#### Whoami over TLS 1.3
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `C++` | 10.0 ± 0.2 | 9.4 | 10.4 | 1.00 |
| `Spectre` | 14.8 ± 0.3 | 14.0 | 15.2 | 1.48 ± 0.04 |
### Notes
- Spectre clone destinations are absolute paths on macOS. The reference checkout hardcodes Linux's `AT_FDCWD` value (`-100`); with a relative destination it cannot open the working directory on macOS.
- `file://` and `ssh://` include server process startup. `clone-tls` and `whoami-tls` use long-running servers, so they isolate protocol and TLS cost more closely.
- These runs reproduce the reference's transfer behavior: fetch `haves` are operation heads (so metadata is re-sent), and push sends all objects reachable from the bookmark rather than using `HAVE_QUERY`.
- Lazy checkout fetches one missing chunk per promisor connection in both implementations, so it is intentionally a worst-case/read-ahead-free measurement.
- `push-file` is only a few milliseconds of real work; process startup noise can dominate. Read the min/max columns alongside the mean.
- Treat differences below roughly 10 ms as noise; this is a single-machine run, not a controlled lab measurement.
### Reproduce
```sh
cd veins-cpprewrite
cmake -S . -B build && cmake --build build -j
./bench/net_bench.sh
```