Repository navigation
Drop ALWAYS_INLINE from three walk helpers - #1701
Merged
asvetlov merged 1 commit intoOct 6, 2026
Merged
Conversation
Keep the pin on md_walk_with_hash(): out of line, getall's visitor call becomes indirect and getall costs 6-8% more. A check_inlining.py rule now guards it. Fold _md_seen_release() into its only caller.
asvetlov
marked this pull request as ready for review
October 6, 2026 11:15
4 of 6 tasks
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>
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?
Drops
ALWAYS_INLINEfrom_md_walk_all_scan(),md_walk_all()andmd_walk()inwalk.h, and folds_md_seen_release()intomd_walk_with_hash(), its only caller.md_walk_with_hash()keeps its pin: out of line, the visitor call ingetallbecomes indirect. Callgrind onCIMultiDict.getall, Ir per call:With this PR,
updatemoves +0.1-0.2% and every other operation stays within 1 Ir. A newtools/check_inlining.pyrule keepsmd_walk_with_hash()inline in thegetallentry points; it fails when the pin is removed.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
CONTRIBUTORS.txt(N/A)CHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Opus 5.5; reviewed by @asvetlov.
Agent run details (optional, for reviewers)
Tests:
pytest -qon the C extension, 3.14.7 (4089 passed) and 3.14.7t (4074 passed), run on the all-pins-dropped variant; the final tree differs from it only by the restored pin. Pure-Python leg not run, since only C changed.Inlining:
tools/check_inlining.pyok on 3.14.7 (24 rules) and 3.14.7t (26 rules).Perf:
benchmarks/callgrind_driver.py --include-multidict-only --impl cimultidict_cagainst 70299d2.