Skip to content

ci: add CodSpeed performance benchmarks - #631

Draft
codspeed[bot] wants to merge 1 commit into
mainfrom
codspeed/setup-benchmarks
Draft

codspeed[bot] wants to merge 1 commit into
mainfrom
codspeed/setup-benchmarks

Conversation

@codspeed

@codspeed codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown

Summary

This PR sets up continuous performance tracking with CodSpeed. It adds a pytest-codspeed benchmark suite and a GitHub Actions workflow that runs it on every push to main and on every pull request.

What changed

  • benchmarks/: a new pytest benchmark suite with 21 benchmarks. It lives outside tests/, so python -m unittest discover -s tests does not pick it up.
    • test_bench_media_shrinker.py covers the CPU-bound paths of the CLI:
      • parse_silencedetect_intervals on 100 and 5,000 silence logs
      • build_segments with silence-aligned splits and with hard splits only
      • _parse_probe_payload on a multi-stream ffprobe payload
      • build_audio_plan for FLAC, Opus, AAC and MP3 across every segment of a 12h recording
      • calculate_audio_bitrate
    • test_bench_transcripts.py covers transcript post-processing:
      • SRT and WebVTT rendering
      • TranscriptIndex build, search and tokenization
      • diarize.merge_with_transcript
      • chapters.detect_chapters and chapter serialization
      • summarize.summarize_segments
    • All inputs are synthetic, deterministic and built in memory. Nothing calls ffmpeg, the filesystem or the network, so results stay stable under CodSpeed's CPU simulation instrument.
  • benchmarks/requirements-bench.txt: hash-pinned pytest and pytest-codspeed, compiled from requirements-bench.in. It follows the same pattern as fuzz/requirements-fuzz.txt. The benchmarked modules are stdlib-only, so the job does not need the full runtime lock.
  • .github/workflows/codspeed.yml: runs the suite in simulation mode on ubuntu-latest and authenticates with OIDC (id-token: write), so no secret is needed. It follows the conventions of the existing workflows:
    • action pinned by SHA (CodSpeedHQ/action v5.2.1)
    • persist-credentials: false
    • the same concurrency group and paths-ignore rules
    • workflow_dispatch, so CodSpeed can backfill baseline data
  • tests/test_workflow_security.py: now also checks the new workflow, so its checkout step keeps persist-credentials: false.
  • README.md: adds the CodSpeed badge and a short "Benchmarks" section.

Running locally

pip install --require-hashes -r benchmarks/requirements-bench.txt
python -m pytest benchmarks --codspeed

All 21 benchmarks passed locally under codspeed run --mode simulation.

Next steps

  • Once this is merged, the first run on main sets the baseline. After that, each PR gets a performance report comment.
  • Optionally, turn on performance checks in the CodSpeed dashboard so a regression can block a merge.
  • The Rust backend (rust-core) is mostly filesystem work (inventory, hashing, staging). If you want to track it too, the next step is a divan benchmark via codspeed-divan-compat, run in walltime mode on CodSpeed macro runners.

Add a pytest-codspeed benchmark suite covering the CPU-bound planning
and transcript-processing paths, a hash-pinned benchmark requirements
file, and a CodSpeed GitHub Actions workflow running in simulation mode.
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b118e593-5794-48ee-9d0e-05ae2f1778ac

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed

codspeed Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Author

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