Skip to content

perf(db): add reproducible baseline runner - #97

Merged
Antruly merged 1 commit into
masterfrom
perf/orm-bench
Nov 27, 2026
Merged

Antruly merged 1 commit into
masterfrom
perf/orm-bench

Conversation

@Antruly

@Antruly Antruly commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Part of #95. Parent: #88. Do not close #95: this is the baseline/methodology phase; ORM end-to-end numbers are blocked on #91/#92.

What changed

  • bench/orm/run_db_baseline.sh — reproducible driver around the existing bench_db binary. It leaves the measurement semantics untouched and adds:
    • a fresh timestamped result directory per invocation (atomic mkdir, no overwrite);
    • N rotations, raw stdout/stderr and GNU time reports preserved per run;
    • machine, compiler, CMake flags, SQLite version, git revision, binary sha256 and exact command in meta.txt/meta.tsv;
    • summary.txt, summary.json, TSV/CSV aggregates for per-call, bulk, loop-stall and concurrency cases;
    • non-zero exit on a failed run, with the raw evidence kept.
  • bench/orm/README.md — baseline protocol, build/run commands, result layout, definition of every column, how to compare future ORM numbers, and the rule that shared-CI smoke runs are not release numbers.
  • .gitignore — ignore bench/orm/results/ raw local output.

No database, ORM, server or C ABI code is changed.

Verification

Build: Release, SQLite 3.45.1, g++ 13.3.0, bench_db from the existing source.

$ bench/orm/run_db_baseline.sh --build-dir build-db-bench --reps 1 \
    --out /tmp/orm95-check --label check
[1/1] run-01 ... ok  wall=5.12s maxrss=8516KB
完成。

The generated summary.json parses with python3 -m json.tool; summary.txt contains the per-call, bulk, loop-stall and concurrency tables.

Example readings from this development-machine run (not a release gate):

point select (param)     2000 samples  mean 6.1 us  p50 5.9 us  p99 9.4 us
insert autocommit        1000 samples  mean 1035.3 us  p99 1540.5 us
insert in txn               3 samples  mean 6.1 ms  165398 rows/s
fetch 10k rows              3 samples  mean 3.4 ms  2913467 rows/s
loop stall, sync          max gap 1247032 us
loop stall, db_async      max gap 1446 us
pool(4) vs 4 clients      median 0.96x
pool(4) vs 1 shared       median 0.42x

Failure path:

$ bench/orm/run_db_baseline.sh --url 'bogus://not-a-db' --reps 1 \
    --out /tmp/orm95-fail
[1/1] run-01 ... 失败(exit 2)
exit=1
summary.txt: FAILED: run-01 exit=2

Two consecutive invocations produced distinct timestamped directories; the second did not touch the first.

Not verified

  • MySQL and PostgreSQL: no server/client headers available in this environment; no numbers are claimed.
  • PostgreSQL native async vs thread-pool path: no PostgreSQL service.
  • ORM end-to-end and pure construction/mapping overhead: ORM is not implemented yet ([ORM] 结果映射与 CRUD #91/[ORM] 事务与异步集成 #92).
  • p95, per-request CPU, allocations, BLOB, column scaling, 10x result-set memory, ODBC and Windows/MSVC.
  • This run is a development-machine baseline (powersave governor, loadavg ~3.4), not a fixed-runner release measurement.
  • The driver is shell/awk only; bash -n passes, but no shellcheck is installed on this machine.

Review focus

  • Result-directory and failure semantics: no overwrite, evidence retained, non-zero exit.
  • Whether the JSON schema (uvcpp-db-baseline/1) has the fields needed for the later ORM A/B gate.
  • Keep bench_db.cpp untouched so historical numbers remain comparable.

Drive the existing bench_db measurement without changing its semantics, record machine/build/database metadata, keep every run in a fresh timestamped directory, and emit raw logs plus text/JSON/TSV summaries for the 1.12.0 db baseline.
@Antruly

Antruly commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Local review before merge: the baseline driver ran five SQLite rounds, generated valid summary.json plus raw logs, kept consecutive runs in separate directories, and returned exit 1 for a bad URL. It intentionally leaves bench_db measurement semantics untouched. MySQL/PostgreSQL, p95 and ORM numbers remain explicitly unverified until later work.

@Antruly
Antruly merged commit 4029b7c into master Nov 27, 2026
20 of 49 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.

[Performance] 数据库同步/异步与 ORM 性能基准和回归门禁

1 participant