GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ci: shard CodSpeed benchmarks across jobs instead of xdist processes by invictustitan2 · Pull Request #669 · commit-check/commit-check

Conversation

@invictustitan2

@invictustitan2 invictustitan2 commented Nov 8, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Follow-up to #668.

Why this follow-up, rather than leaving #668 as-is. #668 got the speedup (benchmark job ~54 min → ~10 min) but shipped it with the CodSpeed Performance Analysis check red — "Merging this PR will degrade performance by 11.1%" on test_no_terminal_output_produced. That was a false positive (#668 changed no commit_check/ code; the benchmark is capsys/stdout-bound, i.e. one of the "136 benchmarks dominated by system calls" CodSpeed cannot simulate consistently, and running it in an xdist worker process shifted its simulated number). The problem is that it isn't a one-off: with in-job pytest-xdist -n auto, those syscall-dominated benchmarks will keep shifting across PRs, so the benchmark gate will keep throwing false regressions. A gate that cries wolf gets ignored — and then a real regression slips through unnoticed. This PR keeps #668's parallelism and speedup while removing that failure mode.

The fix: shard across CI jobs instead of across processes in one job. Each shard runs single-process, so every benchmark is measured in the same context as the old serial run — the simulated numbers are stable — and CodSpeed aggregates the shards into one report. This is the approach the CodSpeed docs list first (-n auto is offered only as a fallback "if you cannot split across CI jobs").

Why pytest-split and not the pytest-test-groups in the CodSpeed docs. On this project's pytest (9.0.3), pytest-test-groups does not split when --codspeed is active — pytest-codspeed and pytest-test-groups both wrap pytest_collection_modifyitems, and the net result is that every shard collects the full benchmark set (which is exactly the "same benchmark run multiple times" case the docs warn against). pytest-split partitions the --codspeed selection correctly: 5 disjoint groups of 133/133/133/133/129 = 661 benchmarks, verified locally, and a shard runs green.

Change

  • .github/workflows/codspeed.yml: strategy.matrix.shard: [1..5]; run: pytest tests/ --codspeed --splits 5 --group ${{ matrix.shard }}. (fail-fast: false so one shard's result doesn't cancel the others.)
  • pyproject.toml: [test] extra pytest-xdist → pytest-split. uv.lock regenerated.

Note on check names. The matrix turns the single Run benchmarks check into Run benchmarks (1..5). If Run benchmarks is a required status check in branch protection, the required-check name will need updating to match.

Tuning. 5 shards ≈ 11 min/shard here; bump the matrix list for more parallelism (each shard has ~1 min fixed setup).

Summary by CodeRabbit

  • Tests
    • Benchmark checks now run in five separate groups. Each group runs independently, so a failure in one does not stop the others. This changes how benchmark results are reported; it does not change product functionality.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@invictustitan2
ci: shard CodSpeed benchmarks across jobs instead of xdist processes
d9a809a
Follow-up to commit-check#668. commit-check#668 parallelized the benchmark job with pytest-xdist
(-n auto), which cut it from ~54 min to ~10 min but left the CodSpeed
check red with a false 11.1% regression: running a syscall-bound
benchmark in an xdist worker shifts its simulated number even though no
code changed. Those false regressions will recur on future PRs and erode
the gate, so trade in-process parallelism for sharding across CI jobs.

Each shard runs single-process, so benchmarks are measured in the same
context as a serial run (stable numbers); CodSpeed aggregates the shards.
This is the approach the CodSpeed docs list first.

- codspeed.yml: strategy.matrix.shard [1..5]; run pytest with
  --splits/--group; fail-fast: false.
- pyproject.toml: [test] pytest-xdist -> pytest-split; uv.lock relocked.

Uses pytest-split, not the docs' pytest-test-groups: under --codspeed on
pytest 9 the latter does not split (every shard runs the full set).
pytest-split partitions into 5 disjoint groups (133/133/133/133/129=661);
a shard runs green locally.
@invictustitan2
invictustitan2 requested a review from a team as a code owner November 8, 2026 17:07
@invictustitan2
invictustitan2 requested review from shenxianpeng and removed request for a team November 8, 2026 17:07
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CodSpeed benchmark workflow now runs five pytest-split groups as separate matrix jobs with fail-fast disabled. The test dependency group replaces pytest-xdist with pytest-split.

Changes: CodSpeed benchmark sharding

Layer / File(s) Summary
Configure sharded benchmark jobs
.github/workflows/codspeed.yml, pyproject.toml
The test dependency group replaces pytest-xdist with pytest-split. The CodSpeed workflow runs five matrix shards, each assigned a pytest-split group, and disables fail-fast.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related issues

  • Issue 663 asks to reduce CodSpeed benchmark job time through parallel execution. This PR uses five matrix shards, one of the approaches described in the issue.

Possibly related PRs

  • commit-check/commit-check#668: This PR replaces the pytest-xdist workflow and dependency changes introduced by PR 668 with pytest-split matrix sharding.
Merge Risk: Minimal · up to d9a80

The sharded benchmark configuration is mergeable after normal checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says the CodSpeed benchmarks are sharded across CI jobs instead of running in pytest-xdist worker processes. The raw summary confirms this main change: the codspeed workflow now uses five ma…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says the CodSpeed benchmarks are sharded across CI jobs instead of running in pytest-xdist worker processes. The raw summary confirms this main change: the codspeed workflow now uses five matrix shards with pytest-split groups, and the test extra swaps pytest-xdist for pytest-split. The title is concise, specific, and follows the conventional-commit style. It names the primary change, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ded2afb2-bb8b-458b-ac8b-4fdf6866e9de
Commits

Reviewing files that changed from the base of the PR and between 2d78e79 and d9a809a.

Files ignored due to path filters: 1

  • uv.lock is excluded by !**/*.lock
Files selected for processing: 2

  • .github/workflows/codspeed.yml
  • pyproject.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2d78e79) to head (d9a809a).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #669   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         2495      2495           
  Branches       484       484           
=========================================
  Hits          2495      2495           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@invictustitan2
invictustitan2 marked this pull request as draft November 8, 2026 17:31
@invictustitan2

invictustitan2 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Moving this to draft — the sharding works, but I can't validate CodSpeed's shard aggregation from a fork PR, and I don't want it merged until that's confirmed in-repo. Details:

What works (verified on this PR's CI run):

  • The 5 matrix shards split the benchmark set cleanly via pytest-split: 133 / 133 / 133 / 133 / 129 = 661 benchmarks, disjoint and complete, every shard green.
  • Each shard uploaded to CodSpeed successfully (Performance data uploaded, tokenless/public-repo auth).

The problem: CodSpeed posted no aggregated report on this PR — no CodSpeed Performance Analysis check, no report comment, ~1h after the shards finished (for comparison, the single-job run on #668 reported within minutes). In the shard logs, each of the 5 uploads got a different CodSpeed run hash, i.e. they were recorded as five separate runs (each with only 1/5 of the benchmarks) rather than one run split five ways — so none is a valid comparison against the all-661 baseline, and nothing aggregates.

What it is not: not an auth/OIDC gap. I checked a repo that shards CodSpeed successfully (django-language-server) and it uses only permissions: contents: read — no id-token: write — so OIDC isn't required for aggregation.

Best read: the combination that fails here is fork PR + sharding. #668 (fork, single job) reported fine; in-repo sharded setups report fine; but CodSpeed doesn't seem to correlate several tokenless uploads from a fork PR's workflow run into one report. The CodSpeed docs say shards aggregate when "split within a single CI workflow" but don't document the fork case, and I couldn't find a public fork-PR sharded example that aggregated.

Why this matters before merging: the CodSpeed workflow also runs on push to main. If sharded aggregation fails there too, the default-branch benchmark gate would go silent (no report at all) — which is worse than the status quo. That needs to be confirmed on a branch inside this repo (where the fork limitation doesn't apply), or on a throwaway push, before this is safe to land.

Suggested next step: if you're open to the sharded approach, the decisive test is pushing this codspeed.yml to an in-repo branch and confirming CodSpeed emits one merged report across the 5 shards. If it does, I'll finish this out; if in-repo sharding has the same issue, the single-job -n auto already on main (#668) is the pragmatic keep, and the only downside there is occasional false-regression flags on the ~136 syscall-dominated benchmarks (measurement artifacts, since those run in a worker process under -n auto).

Happy to carry whichever direction you prefer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Nov 8, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.47%

3 warnings

⚠️ 134 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

⚡ 1 improved benchmark
✅ 660 untouched benchmarks
⏩ 131 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_no_terminal_output_produced 1,070.1 µs 951.5 µs +12.47%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing invictustitan2:ci/shard-codspeed-benchmarks (d9a809a) with main (2d78e79)

Open in CodSpeed

Footnotes

  1. 131 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@invictustitan2

invictustitan2 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Correction — I was wrong above, and I'm un-drafting. CodSpeed's aggregated report did post; it was just slow for the sharded run (~1h+ after the shards finished, vs minutes for a single job). Aggregation across the 5 shards worked fine on this fork PR — the five different run hashes I flagged were a red herring (each upload gets its own hash; CodSpeed still merges them by commit into one report). My earlier "fork + sharding doesn't aggregate" conclusion was premature impatience on my part. Apologies for the noise.

The result is exactly what this PR was for — CodSpeed Performance Analysis is green:

Merging this PR will improve performance by 12.47% — ⚡ 1 improved, ✅ 660 untouched.

The one changed benchmark is the same test_no_terminal_output_produced that #668 flagged as an 11.1% regression: 1,070.1 µs → 951.5 µs (+12.47%). That's the artifact being undone — under -n auto it ran in an xdist worker and measured ~1,070 µs; single-process per shard it measures ~951 µs (its true value). The other 660 are untouched, which is the point: sharding keeps the per-benchmark numbers stable because each shard runs single-process, while still parallelizing across 5 jobs.

So the full picture is now confirmed end-to-end: 5 disjoint shards (133/133/133/133/129 = 661) via pytest-split, aggregated into one report, green, no false regression.

One real caveat still stands: the matrix turns the single Run benchmarks check into Run benchmarks (1..5), so if Run benchmarks is a required status check in branch protection, the required-check names would need updating.

Ready for review whenever you'd like to take a look.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@invictustitan2
invictustitan2 marked this pull request as ready for review November 8, 2026 17:45
@invictustitan2 invictustitan2 mentioned this pull request Nov 8, 2026
Many CodSpeed benchmarks are dominated by system calls — simulation can't measure them, so they add noise #670
Open
shenxianpeng
shenxianpeng approved these changes Nov 8, 2026
View reviewed changes
@shenxianpeng
shenxianpeng merged commit 654872a into commit-check:main Nov 8, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@shenxianpeng shenxianpeng mentioned this pull request Nov 8, 2026
ci: balance CodSpeed shards by measured benchmark durations #671
Closed
@shenxianpeng shenxianpeng added the chore label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@shenxianpeng shenxianpeng shenxianpeng approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

chore

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@invictustitan2 @shenxianpeng
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.