Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Set up continous benchmarking - #1075

Merged
provinzkraut merged 6 commits into
msgspec:mainfrom
provinzkraut:codspeed
Jun 16, 2026
Merged

provinzkraut merged 6 commits into
msgspec:mainfrom
provinzkraut:codspeed

Conversation

@provinzkraut

@provinzkraut provinzkraut commented Jun 16, 2026

Copy link
Copy Markdown
Member

Set up continous benchmarking via codespee.io. Closes #310.
For reasoning and decision making process, refer to #310 (comment)


Re-implement existing benchmarks in /benchmark as pytest style benchmarks in /tests/prof/perf, so they work with codspeed. I've kept around the existing benchmarks, for local use and to produce comparisons against other libraries. Over time we might chose to consolidate them, but I think we should evaluate codspeed for a bit before doing so.

  • Performance benchmarks on Linux amd64 + arm using codspeeds CPU instrumentation
  • Additional memory benchmarks on amd64

Limitations

Benchmarks only run on Linux, because codspeeds instrumentation requires a Linux toolchain. Wallclock benchmarking is available for macOS as well, however, much larger variance is expected there.

@provinzkraut
provinzkraut marked this pull request as draft June 16, 2026 10:43
@provinzkraut provinzkraut changed the title set up codspeed Set up continous benchmarking Jun 16, 2026
@codspeed

codspeed Bot commented Jun 16, 2026

Copy link
Copy Markdown

Congrats! CodSpeed is installed 🎉

🆕 47 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


ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Open in CodSpeed

@provinzkraut
provinzkraut marked this pull request as ready for review June 16, 2026 10:52
@provinzkraut
provinzkraut requested review from ofek and sobolevn June 16, 2026 13:09

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I think that we also need a import msgspec timing test! 👍

Comment thread .github/workflows/ci.yml Outdated
Comment thread tests/prof/perf/test_structs.py
Comment thread tests/prof/perf/test_structs.py Outdated
@provinzkraut

Copy link
Copy Markdown
Member Author

Awesome! I think that we also need a import msgspec timing test! 👍

Added, with some caveats

sobolevn
sobolevn previously approved these changes Jun 16, 2026

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks a lot for your work!

Comment thread tests/prof/perf/test_module.py Outdated
@provinzkraut
provinzkraut enabled auto-merge June 16, 2026 16:03
@provinzkraut
provinzkraut disabled auto-merge June 16, 2026 16:03
@provinzkraut
provinzkraut added this pull request to the merge queue Jun 16, 2026
Merged via the queue into msgspec:main with commit 978c667 Jun 16, 2026
17 checks passed
@provinzkraut
provinzkraut deleted the codspeed branch June 16, 2026 16:05
@provinzkraut

Copy link
Copy Markdown
Member Author

Mhm. Seems like codspeed is indeed a bit unstable: #962 (comment), because checks are running in different envs. Re-ran these 3x now. When run in the same env, they do same stable, but getting the same env as the previous runs, with 3 jobs seems like quite a bit of a gamble. Could probably improve this with self-hosted runners.

@ofek

ofek commented Jun 21, 2026

Copy link
Copy Markdown
Member

I tried to run the manual profiling job to check if the results are similar to Codspeed but it doesn't work now https://github.com/msgspec/msgspec/actions/runs/27883637649/job/82515828562

@provinzkraut

Copy link
Copy Markdown
Member Author

I tried to run the manual profiling job to check if the results are similar to Codspeed but it doesn't work now https://github.com/msgspec/msgspec/actions/runs/27883637649/job/82515828562

Probably because pytest-benchmark had to be replaced with pytest-codspeed, which isn't a 100% drop in?

Also, the results won't be comparable at all, since the codspeed tests run via the CPU simulation

@provinzkraut

Copy link
Copy Markdown
Member Author

So, I set up the threshold to 2%, down from the 10% default, and now pretty much every PR is failing again. Seems that there's still a lot of variance.

@ofek can we try setting up macro runners? I don't have the permissions for that: https://codspeed.io/docs/features/macro-runners#repository-access-configuration

@ofek

ofek commented Jun 21, 2026

Copy link
Copy Markdown
Member

I just followed that guide so everything should be set up now. Yes, I don't have high confidence due to the current variance and was trying to run the old workflow to verify.

@provinzkraut

Copy link
Copy Markdown
Member Author

Yes, I don't have high confidence due to the current variance and was trying to run the old workflow to verify.

I feel the same. Which is a shame because otherwise codspeed is really nice.

@ofek

ofek commented Jun 21, 2026

Copy link
Copy Markdown
Member

Do you think using the same measurement framework as CPython would help us with our micro-benchmarks? https://github.com/psf/pyperf

@ofek

ofek commented Jun 21, 2026

Copy link
Copy Markdown
Member

I'm not sure what we can do on GitHub-provided runners but what about some of the advice here? https://google.github.io/benchmark/reducing_variance.html

I found a nice quickstart setup gist https://gist.github.com/itzmeanjan/05dc3e946f635d00c5e0b21aae6203a7

@provinzkraut

Copy link
Copy Markdown
Member Author

Do you think using the same measurement framework as CPython would help us with our micro-benchmarks? https://github.com/psf/pyperf

Unfortunately not, as on-machine variance isn't our issue. As long as we get the same runner hardware, the results are stable. What tools like these can help with is stabilising results across runs on the same hardware, which codspeed already does through similar means.

I'm not sure what we can do on GitHub-provided runners but what about some of the advice here? https://google.github.io/benchmark/reducing_variance.html

I'll check those out!

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.

Set up continuous benchmarking

3 participants