Repository navigation
Run mutating benchmarks as copy plus operation in a loop - #1494
Merged
asvetlov merged 1 commit intoSep 21, 2026
Merged
Conversation
The insertion, update() and clear() benchmarks mutated a single multidict shared across rounds, so only the first round measured the intended operation. The pop(), popitem(), __delitem__(), __setitem__() and same-key add() benchmarks did a single copy per round, letting per-round overhead dominate. All of them now copy a base multidict and apply the operation 100 times per round, matching the add() and extend() benchmarks.
asvetlov
marked this pull request as ready for review
September 21, 2026 08:39
Merging this PR will degrade performance by 98.05%
Performance Changes
Comparing |
asvetlov
enabled auto-merge (squash)
September 21, 2026 08:47
asvetlov
disabled auto-merge
September 21, 2026 08:47
Contributor
|
asvetlov
enabled auto-merge (squash)
September 21, 2026 08:48
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1494 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 37 37
Lines 5983 6005 +22
Branches 521 536 +15
=========================================
+ Hits 5983 6005 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 of 6 tasks
asvetlov
added a commit
that referenced
this pull request
Sep 21, 2026
) <!-- Thank you for your contribution! --> ## What do these changes do? Moves the CodSpeed benchmark job to Python 3.14, and makes the `repr()` and view inequality benchmarks repeat their operation 100 times, the way the other benchmarks already loop. The benchmark job timeout goes from 10 to 15 minutes, since the job takes about 9.5 minutes. The high "variability" figures on the CodSpeed dashboard (up to about 140%) come from benchmark redefinitions in #1494 and from the real `add()` and `getall()` performance changes in #1466 and #1484, not from run-to-run noise. A same-commit rerun on master (242e5bd) reported 266 of 266 benchmarks unchanged. The dashboard window will age out by itself. ## Are there changes in behavior for the user? No, only benchmarks and CI change. The reshaped benchmarks, and the move to 3.14, will cause a one-time jump in their CodSpeed history. ## Is it a substantial burden for the maintainers to support this? No. ## Related issue number N/A ## Checklist - [x] I think the code is well written - [ ] Unit tests for the changes exist: N/A, this only changes benchmarks and CI - [ ] Documentation reflects the changes: N/A - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt`: N/A - [x] Add a new news fragment into the `CHANGES/` folder - [x] `make doc-spelling` passes and any new technical words are added to `docs/spelling_wordlist.txt` <details> <summary>Agent run details (optional, for reviewers)</summary> Measurement: valgrind is not available locally, so a small pytest plugin emulated pytest-codspeed's simulation mode, including the `gc.collect()`/`gc.disable()` and `random.seed(0)` that `plugin._measure` does, followed by one warmup call and one measured call. It recorded user-space retired instructions with `perf_event_open`, pinned to P-cores. Each run allocated a different number of dummy objects first, to mimic unrelated heap changes between commits. The suite ran on CPython 3.15.0rc2 with `PYTHONHASHSEED=0`, 40 runs per variant, using the same seeds for both. - master benchmarks: every benchmark within 3.6% max/min spread; the worst was `test_items_view_not_equals[ci-py]`, followed by `test_values_view_repr[ci-c]` at 2.4%. - this branch: every benchmark within 3.3% spread; the looped benchmarks all dropped below 2%. An earlier revision also added a `gc_disabled` fixture, based on a harness that did not replicate pytest-codspeed's own GC handling. It was redundant and has been removed. Tests (3.14.2): `pytest` passed (2059 passed, 21 skipped); `pytest --no-c-extensions` passed (1037 passed); `pytest --codspeed --codspeed-mode simulation` passed (269 benchmarks). 3.15 was tried first but dropped: setup-python has no prebuilt 3.15 yet, so the job compiled CPython and ran even longer. Lint: `pre-commit run` on the changed files passed; `make doc-spelling` passed. </details> Drafted with Claude Code (Opus 5); reviewed by asvetlov. --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.
What do these changes do?
Reorganizes the mutating CodSpeed benchmarks to copy a base multidict and apply the operation 100 times per round, the way the
add()andextend()benchmarks already work.The insertion,
update()andclear()benchmarks mutated one multidict shared across rounds, so only the first round measured the intended operation (later rounds replaced existing keys or cleared an empty dict). Thepop(),popitem(),__delitem__(),__setitem__()and same-keyadd()benchmarks did a single copy per round, which let per-round overhead dominate. Working-set sizes per copy were reduced so the pure-Python legs stay at a similar per-round cost.Are there changes in behavior for the user?
No, benchmarks only. Reported numbers for the touched benchmarks will shift since they now measure a different amount of work.
Is it a substantial burden for the maintainers to support this?
No.
Related issue number
N/A
Checklist
CONTRIBUTORS.txt: N/ACHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Code (Claude Opus 5); reviewed by @asvetlov.
Agent run details (optional, for reviewers)
Tests:
pytest tests/test_multidict_benchmarks.py tests/test_views_benchmarks.py -qon 3.14t with the in-place C extension build: 269 passed (bothcandpybackend params).CodSpeed walltime local run of touched benchmarks: all pass; pure-Python
add_same_key~0.4 s/round after shrinking to 100 values.Lint: pre-commit hooks pass; mypy skipped because it crashes with an INTERNAL ERROR on the unmodified file too.