Skip to content

ci: add CodSpeed continuous performance measurement#32

Merged
t41372 merged 2 commits into
mainfrom
codspeed-wizard-1784976703605
Jul 25, 2026
Merged

ci: add CodSpeed continuous performance measurement#32
t41372 merged 2 commits into
mainfrom
codspeed-wizard-1784976703605

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Sets up CodSpeed for continuous performance measurement on skit. This adds a pytest-codspeed benchmark suite in CPU simulation mode and a GitHub Actions workflow that runs it on every push to main and on pull requests, so performance changes are tracked and surfaced directly on PRs.

This integration is intentionally separate from the existing benchmarks/ pyperf pipeline and its budget contract — it does not touch or replace them. CodSpeed's simulation instrument provides deterministic, hardware-agnostic CPU measurements (low variance, per-benchmark flamegraphs) that complement the wall-time/footprint numbers the pyperf pipeline produces.

What was added

  • benchmarks/codspeed/ — a pytest-codspeed suite targeting skit's CPU-bound hot paths:
    • test_bench_analyzers.py — warm analyze() for python / shell / js / ts across 20 / 200 / 2000-line sources. Inputs are produced by the existing seeded generator (benchmarks/fixtures/sources.py), so they carry the real constructs each analyzer inspects (parameters, env-defaults, argument parsing).
    • test_bench_store.pystore.list_entries() and store.resolve() (first/last) over a 200-entry library built through the public store API, isolated via SKIT_*_DIR (the same isolation the test suite uses — no real library is touched).
  • .github/workflows/codspeed.yml — a CodSpeed workflow (ubuntu-latest) using OIDC authentication (id-token: write) and mode: simulation. It follows the repo's existing CI conventions: hash-pinned actions, permissions: {} by default, persist-credentials: false, PYTHONUTF8, and path-scoped triggers. Advisory by policy — path-filtered, so it is not intended as a required status check.
  • README — CodSpeed badge next to the existing badges.
  • pyproject.toml / uv.lockpytest-codspeed added to the dev dependency group; a per-file-ignores entry lets the benchmark tests use assert (mirroring the tests/** rule).

Verification

  • Ran locally with codspeed run --mode simulation -- uv run pytest benchmarks/codspeed/ --codspeed — all 15 benchmarks were measured and uploaded, and the run linked to t41372/skit.
  • The benchmark files pass the repo's quality gates: ruff check, ruff format --check, ty check, and zizmor (workflow audit).
  • The benchmark suite lives under benchmarks/ and is excluded from testpaths = ["tests"], so it does not run in the regular pytest job or affect the 100% coverage gate. The main suite still collects cleanly (5249 tests).

Next steps

  • Merge to establish the baseline on main. CodSpeed will start reporting per-PR comparisons on subsequent PRs.
  • Optionally extend coverage to other hot paths (e.g. TUI render/import spans) if you want them tracked here too.

Add a pytest-codspeed benchmark suite (simulation mode) covering skit's CPU-bound
hot paths and a GitHub Actions workflow that reports results to CodSpeed.

- benchmarks/codspeed/: analyzer parse (python/shell/js/ts across 20/200/2000
  lines) and store read paths (list_entries, resolve), isolated via SKIT_*_DIR
- .github/workflows/codspeed.yml: OIDC-authenticated CodSpeed run on ubuntu-latest
- README: CodSpeed badge
- pytest-codspeed added to the dev dependency group
@codspeed-hq

codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Congrats! CodSpeed is installed 🎉

🆕 15 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

@codspeed-hq
codspeed-hq Bot marked this pull request as ready for review July 25, 2026 11:02
@codspeed-hq
codspeed-hq Bot requested a review from t41372 July 25, 2026 11:04
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The benchmarks landed in benchmarks/codspeed/, which is the right home —
and which put them inside two contracts written for the pyperf pipeline.

The A/B harness import surface (runtime deps + pyperf + stdlib) exists
because benchmark-compare runs benchmarks/ under an older side's venv; a
dev-only import there kills every A/B run at startup. The CodSpeed
modules are pytest files that harness never imports (`python -m
benchmarks run` reaches benchmarks.suites.*), so they get an explicit,
reasoned exemption for exactly pytest and its plugin — not a widened
rule.

Coverage measures the whole benchmarks package, while testpaths keeps
the normal pytest run inside tests/, so these files would have been
collected by nothing and reported at 0%, taking the 100% floor with
them. They are benchmark subjects, like fixtures/noop.py, and are
omitted with the same reasoning.

Also: the runner label is pinned like benchmark.yml's — simulation mode
counts instructions rather than time, so the CPU is irrelevant, but the
image decides which library code those instructions run through, and
-latest rolling to a new release would land as a step change that reads
exactly like a regression. And cancel-in-progress now applies to pull
requests only: cancelling a main push would leave a hole in the very
baseline every later comparison is measured against.
@t41372
t41372 merged commit 9d9397c into main Jul 25, 2026
16 checks passed
@t41372
t41372 deleted the codspeed-wizard-1784976703605 branch July 25, 2026 11:37
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.

2 participants