Skip to content

Make the remaining walk.h helpers plain static functions - #1722

Merged
asvetlov merged 2 commits into
aio-libs:masterfrom
asvetlov:walk-h-plain-static
Oct 7, 2026
Merged

asvetlov merged 2 commits into
aio-libs:masterfrom
asvetlov:walk-h-plain-static

Conversation

@asvetlov

@asvetlov asvetlov commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

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

  • I think the code is well written
  • Unit tests for the changes exist (N/A, no behavior change)
  • 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

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

Agent run details (optional, for reviewers)

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 409f8d1a 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.

@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 degrade performance by 11%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 3 (👁 3) regressed benchmarks
✅ 703 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
👁 test_cimultidict_getall_istr_hit_many_values[c] 1.9 ms 2.2 ms -11.06%
👁 test_multidict_getall_str_hit_many_values[ci-c] 1.9 ms 2.1 ms -11.64%
👁 test_multidict_getall_str_hit_many_values[cs-c] 1.9 ms 2.1 ms -10.3%

Comparing asvetlov:walk-h-plain-static (1c5cc5e) with master (409f8d1)

Open in CodSpeed

@asvetlov
asvetlov marked this pull request as ready for review October 7, 2026 13:54
@asvetlov
asvetlov requested a review from webknjaz as a code owner October 7, 2026 13:54
@asvetlov
asvetlov merged commit 1f79c17 into aio-libs:master Oct 7, 2026
52 checks passed
@asvetlov
asvetlov deleted the walk-h-plain-static branch October 7, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:mixed-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