Skip to content

Add getall benchmarks for keys with many values - #1509

Merged
asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:benchmarks-getall-bitmap
Sep 21, 2026
Merged

asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:benchmarks-getall-bitmap

Conversation

@asvetlov

Copy link
Copy Markdown
Member

What do these changes do?

Adds three CodSpeed benchmarks for getall() on keys with many values, to give #1505 a baseline on paths the current benchmarks miss.

After #1505, getall() keeps up to 8 matches in a short inline list and only then starts a bitmap, which lives in a 4 KB inline buffer (32768 entries) and moves to the heap for bigger tables. The existing test_multidict_getall_str_hit_large_table has 8 values per key, so it no longer reaches the bitmap at all.

  • test_multidict_getall_str_hit_large_table_many_values: 16 values per key over 4096 keys (65536 entries), 128 lookups per run; covers the heap bitmap.
  • test_multidict_getall_str_hit_many_values: 64 values per key over 16 keys (1024 entries), each key looked up 8 times per run; covers the inline bitmap.
  • test_cimultidict_getall_istr_hit_many_values: the CIMultiDict/istr twin of the previous one.

Are there changes in behavior for the user?

No, benchmarks only.

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

No.

Related issue number

Related to #1505

Checklist

  • I think the code is well written
  • Unit tests for the changes exist: N/A, benchmarks only
  • Documentation reflects the changes: N/A
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt: N/A
  • 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)

Isolated venv on CPython 3.13.2, based on upstream/master 1ccffea.

C extension: pytest tests/test_multidict_benchmarks.py -q: 197 passed.
Pure Python (MULTIDICT_NO_EXTENSIONS=1, --no-c-extensions): 100 passed, including all new cases.
pre-commit run on changed files: passed. make doc-spelling: build succeeded.

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

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 21, 2026
@asvetlov
asvetlov marked this pull request as ready for review September 21, 2026 18:33
@asvetlov
asvetlov requested a review from webknjaz as a code owner September 21, 2026 18:33
@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge: the added benchmark cases collect and run successfully in both supported implementation modes.

What we checked:

  • Created an executable focused validation script for the newly added getall() benchmarks. T-Rex
  • Ran the selected getall() benchmarks with both the C extension and the pure-Python implementation across five parameterizations; all runs completed with Validation result: PASS. T-Rex
  • Authored an executable command script to reproduce the getall benchmarks for PR-1509. T-Rex
  • Verified the full observed output shows the expected parameterized benchmark IDs and a PASS result. T-Rex

Reviews (1) · Last reviewed commit: "Add getall benchmarks for keys with many..."

@codspeed

codspeed Bot commented Sep 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 288 untouched benchmarks
🆕 10 new benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_cimultidict_getall_istr_hit_many_values[c] N/A 3.8 ms N/A
🆕 test_cimultidict_getall_istr_hit_many_values[py] N/A 50.6 ms N/A
🆕 test_multidict_getall_str_hit_large_table_many_values[ci-c] N/A 1.5 ms N/A
🆕 test_multidict_getall_str_hit_large_table_many_values[ci-py] N/A 13.4 ms N/A
🆕 test_multidict_getall_str_hit_large_table_many_values[cs-c] N/A 1.3 ms N/A
🆕 test_multidict_getall_str_hit_large_table_many_values[cs-py] N/A 13.2 ms N/A
🆕 test_multidict_getall_str_hit_many_values[ci-c] N/A 3.9 ms N/A
🆕 test_multidict_getall_str_hit_many_values[ci-py] N/A 50.8 ms N/A
🆕 test_multidict_getall_str_hit_many_values[cs-c] N/A 3.7 ms N/A
🆕 test_multidict_getall_str_hit_many_values[cs-py] N/A 50.6 ms N/A

Comparing asvetlov:benchmarks-getall-bitmap (c57afa8) with master (1ccffea)

Open in CodSpeed

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1ccffea) to head (c57afa8).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1509   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         6204      6227   +23     
  Branches       560       565    +5     
=========================================
+ Hits          6204      6227   +23     
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.

@asvetlov
asvetlov merged commit 42ac4b3 into aio-libs:master Sep 21, 2026
152 of 157 checks passed
@asvetlov
asvetlov deleted the benchmarks-getall-bitmap branch September 21, 2026 18:49
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