Skip to content

Scale up syscall-dominated CodSpeed benchmarks - #1485

Merged
asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:claude/codspeed-benchmark-variance-131e5e
Sep 20, 2026
Merged

asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:claude/codspeed-benchmark-variance-131e5e

Conversation

@asvetlov

Copy link
Copy Markdown
Member

What do these changes do?

Scales up the working set of the pop(), popitem(), __delitem__(),
add() and item-insertion CodSpeed benchmarks in
tests/test_multidict_benchmarks.py. Comparing repeated CodSpeed runs
on the same master commit (via the CodSpeed MCP) showed these
particular pure-Python-backend benchmarks consistently flagged as
"dominated by syscalls": instrumentation mode cannot account for
syscall time, so it is excluded from the measured value, which both
understates the real cost and introduces run-to-run noise depending
on when a syscall happens to land during the measured window. Giving
each benchmark more instrumented work to do amortizes that overhead,
which is CodSpeed's own guidance for this class of measurement issue.

Are there changes in behavior for the user?

No. Only the size of the fixtures inside these benchmark functions
changed; no library code is touched.

Is it a substantial burden for the maintainers to support this?

No, it is a mechanical change to existing benchmark fixture sizes.

Related issue number

N/A

Checklist

  • I think the code is well written
  • N/A Unit tests for the changes exist -- this PR only touches benchmarks
  • N/A Documentation reflects the changes
  • N/A If you provide code modification, please add yourself to CONTRIBUTORS.txt
  • Add a new news fragment into the CHANGES/ folder
  • make doc-spelling passes and any new technical words are added to docs/spelling_wordlist.txt
Agent run details (optional, for reviewers)

Analysis: used the CodSpeed MCP to compare two runs of the same master
commit (7310298, runs 6aaf7cd3 vs 6aaf045b, and 9c08be4, runs
6aae2b4f vs 6aad8528). Both comparisons flagged the same cluster of
pure-Python pop/popitem/delitem/add/insert-style benchmarks as
"dominated by syscalls"; no other benchmarks were flagged.

Tests: pytest tests/test_multidict_benchmarks.py tests/test_views_benchmarks.py -q passed (269 passed) against both the
default C-extension build (built locally with setup.py build_ext --inplace to avoid touching the shared pyenv venv) and the pure-Python
backend (both backends are exercised in the same run via the
any_multidict_class-style fixtures). Could not reproduce an actual
CodSpeed instrumentation run locally (that requires the CodSpeed cloud
runner's valgrind-based environment); correctness of the benchmark
code was verified, but the claim that this reduces the "dominated by
syscalls" flag can only be confirmed once this branch runs through the
CodSpeed action in CI.

Lint: pre-commit run on the changed files (ruff, mypy, changelog
filename/user-role checks) passed. make doc-spelling passed after
adding syscalls to docs/spelling_wordlist.txt.

Drafted with Claude Code (Sonnet 5); reviewed by asvetlov.

🤖 Generated with Claude Code

Comparing repeated CodSpeed runs on the same master commit via the
CodSpeed MCP showed pop, popitem, delitem, add and item-insertion
benchmarks for the pure-Python backend consistently flagged as
"dominated by syscalls": instrumentation mode cannot account for
syscall time, so these measurements understate the real cost and
vary from run to run depending on when a syscall happens to land.
Scaling up the working set each benchmark does amortizes that
overhead over more instrumented work, which is CodSpeed's own
recommendation for this class of measurement noise.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 20, 2026
@codspeed

codspeed Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 74.75%

❌ 27 (👁 27) regressed benchmarks
✅ 239 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
👁 test_multidict_add_str[cs-c] 7.2 ms 15 ms -52.28%
👁 test_multidict_insert_str[cs-c] 94.1 µs 369.3 µs -74.53%
👁 test_multidict_popitem_str[ci-c] 276.8 µs 1,691 µs -83.63%
👁 test_multidict_popitem_str[cs-c] 150.4 µs 1,070.9 µs -85.96%
👁 test_multidict_pop_str[cs-c] 203.1 µs 796.9 µs -74.51%
👁 test_multidict_delitem_str[ci-c] 195.4 µs 888.6 µs -78.01%
👁 test_multidict_delitem_str[cs-c] 117.6 µs 524.5 µs -77.59%
👁 test_multidict_insert_str[ci-py] 3.1 ms 16.8 ms -81.32%
👁 test_multidict_add_str[ci-py] 284.4 ms 559.8 ms -49.2%
👁 test_multidict_popitem_str[ci-py] 2 ms 9.8 ms -79.26%
👁 test_multidict_pop_str[ci-py] 2.7 ms 12.8 ms -78.93%
👁 test_multidict_delitem_str[ci-py] 2.8 ms 13.9 ms -80.01%
👁 test_multidict_add_str[cs-py] 271.8 ms 536 ms -49.3%
👁 test_multidict_insert_str[cs-py] 2.9 ms 16.2 ms -81.93%
👁 test_multidict_pop_str[cs-py] 2.6 ms 12.1 ms -78.81%
👁 test_multidict_popitem_str[cs-py] 1.8 ms 8.9 ms -79.36%
👁 test_multidict_delitem_str[cs-py] 2.6 ms 13.2 ms -79.98%
👁 test_multidict_add_str[ci-c] 18.7 ms 39.5 ms -52.58%
👁 test_multidict_pop_str[ci-c] 308 µs 1,264.9 µs -75.65%
👁 test_cimultidict_delitem_istr[py] 2.7 ms 13.6 ms -79.92%
... ... ... ... ...

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


Comparing asvetlov:claude/codspeed-benchmark-variance-131e5e (7d38627) with master (eaca953)

Open in CodSpeed

@asvetlov
asvetlov marked this pull request as ready for review September 20, 2026 11:14
@asvetlov
asvetlov requested a review from webknjaz as a code owner September 20, 2026 11:14
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (eaca953) to head (7d38627).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1485   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         5934      5934           
  Branches       514       514           
=========================================
  Hits          5934      5934           
Flag Coverage Δ
CI-GHA 100.00% <100.00%> (ø)
pytest 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge.

What we checked:

  • Verified the pre-change harness run reported 32/32 passes in the before log. T-Rex
  • Verified the post-change harness run reported 32/32 passes in the after log. T-Rex
  • Verified the pytest run after the change completed with 32 tests passing and 137 deselected in the pytest-after log. T-Rex
  • Verified the authored executable harness script pr1485-benchmark-fixtures-check.py is present for validation. T-Rex

Reviews (1) · Last reviewed commit: "Scale up syscall-dominated CodSpeed benc..."

@asvetlov
asvetlov merged commit b8fc573 into aio-libs:master Sep 20, 2026
61 checks passed
@asvetlov
asvetlov deleted the claude/codspeed-benchmark-variance-131e5e branch September 20, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant