Skip to content

Outline md_get_all - #1727

Merged
asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:md-get-all-outline
Oct 7, 2026
Merged

asvetlov merged 1 commit into
aio-libs:masterfrom
asvetlov:md-get-all-outline

Conversation

@asvetlov

@asvetlov asvetlov commented Oct 7, 2026

Copy link
Copy Markdown
Member

What do these changes do?

Dropped ALWAYS_INLINE static inline from md_get_all(), making it a plain static function. GCC keeps one out-of-line copy shared by multidict_getall and multidict_proxy_getall, so the #1530 rule in tools/check_inlining.py no longer holds and was removed.

Cost (callgrind, Ir per op, CPython 3.14.7): getall +20 to +24 Ir, i.e. +2.4% GIL and +2.7 to +2.9% FT for both MultiDict and CIMultiDict. On FT, setdefault_new moved -1.5% and MultiDict contains_hit -1.4%; nothing else moved more than 0.3%.

Are there changes in behavior for the user?

No.

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

No.

Related issue number

N/A

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (N/A, no behaviour change; existing suite covers getall)
  • 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)
Build Operation Before After Change
GIL MultiDict.getall 820.0 840.0 +2.44%
GIL CIMultiDict.getall 866.3 888.3 +2.54%
FT MultiDict.getall 836.4 860.4 +2.87%
FT CIMultiDict.getall 880.8 904.8 +2.72%

Measured with benchmarks/callgrind_driver.py --include-multidict-only against 1a94ccd.

Tests: pytest -q passed with the C extension on 3.14, 3.14t and 3.10, and with MULTIDICT_NO_EXTENSIONS=1 --no-c-extensions on 3.14.
Inlining: tools/check_inlining.py ok on 3.14.7 and 3.14.7t.
Docs: make doc-spelling passed.

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

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Oct 7, 2026
@codspeed

codspeed Bot commented Oct 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 706 untouched benchmarks


Comparing asvetlov:md-get-all-outline (31b421f) with master (d0858e4)

Open in CodSpeed

@asvetlov
asvetlov marked this pull request as ready for review October 7, 2026 08:29
@asvetlov
asvetlov requested a review from webknjaz as a code owner October 7, 2026 08:29
@asvetlov
asvetlov merged commit 7c34e1f into aio-libs:master Oct 7, 2026
53 checks passed
@asvetlov
asvetlov deleted the md-get-all-outline branch October 7, 2026 08:35
asvetlov added a commit that referenced this pull request Oct 7, 2026
<!-- Thank you for your contribution! -->

## What do these changes do?

Drops `inline` from `_md_seen_test_and_add()` and `ALWAYS_INLINE static
inline` from `md_walk_with_hash()` in `walk.h`, leaving both plain
`static`, and removes the `md_walk_with_hash` rule from
`tools/check_inlining.py` that #1701 added.

GCC now keeps one out-of-line `md_walk_with_hash()` with
`_md_seen_test_and_add()` inlined into it, shared by `getall` and
`md_walk()`; `md_walk.constprop.0` goes away, and `md_get_all()`
(outlined in #1727) folds back into `multidict_getall()`. `.text`
shrinks by 2752 bytes on GIL and 1312 on FT.

The cost is the indirect visitor call #1701 measured. Callgrind against
`409f8d1a`, Ir per call:

| build | operation | MultiDict | CIMultiDict |
|---|---|---|---|
| GIL 3.14.7 | `getall` | 840.0 -> 875.8 (+4.3%) | 888.3 -> 926.1
(+4.3%) |
| GIL 3.14.7 | `getitem_istr` | +0.7% | unchanged |
| FT 3.14.7t | `getall` | 860.4 -> 883.2 (+2.7%) | 906.6 -> 928.8
(+2.4%) |
| FT 3.14.7t | `setitem_insert` | +1.4% | +2.2% |
| FT 3.14.7t | `delitem` | +1.1% | -1.9% |
| FT 3.14.7t | `setitem_replace` | -1.3% | -2.6% |
| FT 3.14.7t | `iter_keys` | -3.6% | -3.4% |
| FT 3.14.7t | `setitem_istr` | +0.6% | -3.3% |

Every other row moved by under 1%. The FT rows other than `getall` do
not reach the changed code; they move with the layout of the smaller
binary.

## Are there changes in behavior for the user?

No.

## 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, no behavior change)
- [x] 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`

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

<details>
<summary>Agent run details (optional, for reviewers)</summary>

Measurement: `benchmarks/callgrind_driver.py --include-multidict-only
--impl {multidict_c,cimultidict_c}`, base and changed trees installed
into separate venvs per build.

Codegen: `tools/codegen_diff.py --ref 409f8d1` reports 120 of 320
functions differ on 3.14.7 and 140 of 324 on 3.14.7t; `multidict_getall`
59 -> 291 instructions on GIL with `md_get_all` folded in.

Tests: `pytest -q --no-cov` on 3.10.17 (4093 passed) and 3.14.7t (4074
passed). Pure-Python leg not run, no Python change.
`tools/check_inlining.py` passes on 3.14.7 and 3.14.7t (16 and 19
rules). Pre-commit and `make doc-spelling` pass.
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:automation-signals 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