Skip to content

refactor(benchmarks): subcommand-scoped CLI flags via subparsers#149

Merged
lesnik512 merged 1 commit into
mainfrom
refactor/benchmarks-cli-subparsers
Jul 17, 2026
Merged

refactor(benchmarks): subcommand-scoped CLI flags via subparsers#149
lesnik512 merged 1 commit into
mainfrom
refactor/benchmarks-cli-subparsers

Conversation

@lesnik512

Copy link
Copy Markdown
Member

What

The benchmarks CLI registered command as one positional with choices and hung every flag (--messages, --repeats, --write-baseline, --markdown) on the single top-level parser. argparse accepted any flag with either command, but each flag is read by only one — so python -m benchmarks run --markdown parsed and silently did nothing.

Split into real run/check subparsers, each owning its own flags. Misplaced flags now error at parse time (error: unrecognized arguments: --markdown, exit 2).

How

  • _build_parser() builds the two subparsers (run: --messages/--repeats/--write-baseline; check: --markdown); dispatch stays if args.command == "check".
  • main(argv=None) takes an optional argv so the grammar is unit-testable without spinning up Postgres.
  • No change to the happy paths the just recipes use (run …, check, check --markdown).

Testing

  • 5 new grammar tests: run --markdown and check --write-baseline raise SystemExit; check --markdown / run --messages … --write-baseline parse to the right namespace; a subcommand is required. 20/20 in tests/test_benchmarks.py pass; ruff + ty clean.
  • Verified live: python -m benchmarks run --markdown exits 2; --help lists the run/check subcommands.

Design: planning/changes/2026-07-17.04-benchmarks-cli-subparsers.md

🤖 Generated with Claude Code

The flat parser hung every flag off one positional command, so `run
--markdown` (and other cross-command flag misuse) parsed and silently
no-oped. Split into `run`/`check` subparsers owning their own flags, so a
misplaced flag is an argparse error. Extract _build_parser() and give
main(argv=None) an optional argv so the grammar is unit-testable without
Postgres.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Benchmark gate

✅ gate passed

scenario msg/s delete/msg WALrec/msg WALB/msg fpi upd del dead_tup
consumer/w1/b10 1047 1.000 6.78 917 242 5000 5000 10000
consumer/w1/b100 1069 1.000 6.82 919 243 5000 5000 10000
consumer/w2/b10 1224 1.000 6.79 954 242 5000 5000 10000
consumer/w2/b100 1476 1.000 6.72 955 243 5000 5000 10000
consumer/w4/b10 1103 1.000 6.77 960 242 5000 5000 10000
consumer/w4/b100 1683 1.000 6.86 1035 244 5000 5000 10000
consumer/w1/b100/tfbs100 6994 0.010 6.07 1116 243 5000 5000 10000
producer/w1/b100 2227 0.000 3.04 584 0 0 0 0

Gated (fails the build): delete_calls + tuple counters (upd/del/ins) + the producer's insert_calls/select_calls, exact; wal_records within a 10% band. msg/s, WAL bytes and total calls are informational (timing/FPI noise).

@lesnik512
lesnik512 merged commit 3041b7a into main Jul 17, 2026
7 checks passed
@lesnik512
lesnik512 deleted the refactor/benchmarks-cli-subparsers branch July 17, 2026 19:06
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.

1 participant