Skip to content

Add benchmark suite and per-PR benchmark CI workflow - #185

Merged
berendkleinhaneveld merged 2 commits into
masterfrom
bench/suite-and-ci
Jul 7, 2026
Merged

Add benchmark suite and per-PR benchmark CI workflow#185
berendkleinhaneveld merged 2 commits into
masterfrom
bench/suite-and-ci

Conversation

@berendkleinhaneveld

Copy link
Copy Markdown
Collaborator

Summary

First PR of the performance series that supersedes #183 (split so each optimization is proven independently by CI).

  • Adds a pytest-benchmark suite under bench/, mirroring the sibling observ repo's setup. Scenarios: plain/bound element creation (10/100/1000), nested component mount (depth 10/50/200), attribute update at depth (10/50/200), keyed and unkeyed v-for reconciliation (append/prepend/reverse/shuffle × 10/100/1000), and a new unkeyed list grow/shrink scenario (100/1000, with and without sibling elements) that exposes the current O(n²) anchor recomputation when appending items.
  • Adds .github/workflows/benchmark.yml: on every PR it runs the suite against the master version of collagraph/ and against the PR version, fails when mean time regresses >5%, and uploads .benchmarks/ as an artifact. All benchmarks use DictRenderer + a synchronous event loop, so no Qt/GL system dependencies are needed.
  • Scopes the CI test job to tests so the 5-way Python matrix no longer collects the benchmark suite.
  • Adds pytest-benchmark/pytest-timeout to the dev group, benchmark display columns, a ruff per-file ignore for bench/*, and gitignores .benchmarks/.

Since this PR does not touch collagraph/ source, the benchmark workflow on this PR compares identical code and should report ~0% deltas — validating the pipeline itself. Follow-up PRs with the actual optimizations will then show their gains automatically in this workflow.

Test plan

  • uv run pytest tests -q — 349 passed, 1 skipped
  • uv run ruff check . / uv run ruff format --check . — clean
  • uv run pytest bench --collect-only — 42 benchmarks collected; new grow/shrink benchmarks run green locally
  • Benchmark workflow passes on this PR with ~0% deltas
  • CI test matrix no longer collects bench/

🤖 Generated with Claude Code

Adds a bench/ suite (element creation, component mount depth,
attribute update at depth, keyed/unkeyed v-for reconciliation, and
unkeyed list grow/shrink) using pytest-benchmark with DictRenderer and
synchronous event loop, mirroring the setup in the sibling observ repo.

The new benchmark workflow runs the suite twice on every PR - once
against the master version of collagraph/ and once against the PR
version - and fails when mean time regresses more than 5%. The CI test
job is scoped to the tests directory so the matrix does not execute
benchmarks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The allocation burst of list reconciliation triggers collection pauses
in some rounds, which inflated stddev on the grow benchmarks to ~40%
of the mean - far too noisy for the 5% regression gate in CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@berendkleinhaneveld
berendkleinhaneveld merged commit 3ef2163 into master Jul 7, 2026
10 checks passed
@berendkleinhaneveld
berendkleinhaneveld deleted the bench/suite-and-ci branch July 7, 2026 18:09
berendkleinhaneveld added a commit that referenced this pull request Jul 21, 2026
Features:
- Add pure-Python view API as alternative to cgx templates (#193)
- Support text elements for PySide widgets that display text (#191)

Fixes & internals:
- Fragment parenting overhaul (#162)
- Fix PyInstaller hook for CGX files inside packages (#184)
- Write compiled AST to temp file when CGX_DEBUG is set (#175)

Performance:
- Speed up mount path: cheap arity check, reuse first(), leaner emit (#186)
- Cache Fragment._component_parent() lookups (#187)
- Avoid redundant anchor lookups in Fragment.anchor() and unkeyed v-for (#188)

Documentation:
- Add MkDocs documentation with GitHub Pages deployment (#176)
- Add internals architecture documentation page (#194)
- Add docs badge and links to README (#192)

Tooling & CI:
- Add benchmark suite and per-PR benchmark CI workflow (#185)
- Make benchmark CI guard robust against run-to-run noise (#196)
- Update GitHub actions from Node 20 to Node 24 (#190)
- Migrate from pre-commit to prek (#195)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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