fix(benchmarks): unblock codspeed runs on pytest 9#1647
Merged
Conversation
Both update benchmarks asserted that author.name differed after a random rewrite, but the rewrite drew from the same alphabet/length as the fixture-generated original (5 chars from string.ascii_letters), so a collision (~1/311M per call) eventually surfaced over many codspeed walltime iterations and CI runs. Prefix the rewritten name with "u_" so the new value can never structurally equal the original.
Merging this PR will degrade performance by 34.64%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| 👁 | WallTime | test_count[250] |
3 ms | 3.6 ms | -16.6% |
| 👁 | WallTime | test_avg[500] |
2.5 ms | 3.4 ms | -25.65% |
| 👁 | WallTime | test_max[250] |
2.4 ms | 3.4 ms | -27.16% |
| 👁 | WallTime | test_making_and_inserting_models_in_bulk[10] |
9.5 ms | 10.6 ms | -10.62% |
| 👁 | WallTime | test_get_or_none[250] |
2.6 ms | 3.5 ms | -25.38% |
| 👁 | WallTime | test_get_or_create_when_create[10] |
102.4 ms | 119.7 ms | -14.44% |
| 👁 | WallTime | test_get_or_create_when_create[40] |
413.6 ms | 484.2 ms | -14.57% |
| 👁 | WallTime | test_saving_models_individually[20] |
149.3 ms | 167.6 ms | -10.91% |
| 👁 | WallTime | test_values[250] |
5.5 ms | 6.4 ms | -14.2% |
| 👁 | WallTime | test_min[500] |
2.5 ms | 3.4 ms | -25.16% |
| 👁 | WallTime | test_first[500] |
2.5 ms | 3.3 ms | -25.67% |
| 👁 | WallTime | test_get_or_none[1000] |
2.7 ms | 3.5 ms | -24.14% |
| 👁 | WallTime | test_deleting_all[250] |
1.4 ms | 2.2 ms | -34.64% |
| 👁 | WallTime | test_avg[250] |
2.4 ms | 3.5 ms | -30.88% |
| 👁 | WallTime | test_get_or_create_when_create[20] |
209.4 ms | 240.7 ms | -13.01% |
| 👁 | WallTime | test_get_one[500] |
2.7 ms | 3.5 ms | -24.54% |
| 👁 | WallTime | test_get_or_none[500] |
2.7 ms | 3.5 ms | -24.56% |
| 👁 | WallTime | test_values_list[250] |
5.6 ms | 6.5 ms | -13.53% |
| 👁 | WallTime | test_get_or_create_when_get[1000] |
2.7 ms | 3.5 ms | -24.48% |
| 👁 | WallTime | test_get_one[250] |
2.7 ms | 3.5 ms | -24.18% |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Comparing fix/benchmarks-pytest9 (695f4ea) with master (53d2462)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
@pytest.mark.benchmark(...)decorator on theaio_benchmarkfixture inbenchmarks/conftest.py. Marks on fixtures never had any effect and pytest 9 promoted the deprecation to a hardPytestRemovedIn9Warningraised at conftest import time, so every benchmark run since thepytest 8.4.2 → 9.0.3bump (build(deps-dev): bump pytest from 8.4.2 to 9.0.3 #1609) hung and got auto-cancelled at the 24h job timeout."u_"intest_benchmark_update.pyandtest_benchmark_bulk_update.py. The assertionauthor.name != starting_first_namepreviously compared two random 5-char strings drawn fromstring.ascii_letters— over thousands of codspeed walltime iterations the ~1/311M per-call collision eventually surfaced (CI showed'DpwEX' != 'DpwEX'). The prefix makes the new value structurally unable to match.Without this, master has had no successful benchmark baseline since
53d2462(2026-03-31), which is why the recentfeature/flatten-fieldsPR (#1641) shows a phantom -35% regression and a "Different runtime environments detected" warning — codspeed is comparing against a 5-week-old run on different macro-runner hardware.Test plan
pytest benchmarks/test_benchmark_update.py benchmarks/test_benchmark_bulk_update.py --codspeedpasses locally on pytest 9.0.3 + pytest-codspeed 4.5.0