Skip to content

[bot] Use llhttp's HTTP_ALL_METHOD_COUNT for the method table - #14584

Draft
Dreamsorcerer wants to merge 2 commits into
masterfrom
bot-llhttp-method-count
Draft

Dreamsorcerer wants to merge 2 commits into
masterfrom
bot-llhttp-method-count

Conversation

@Dreamsorcerer

Copy link
Copy Markdown
Member

This is from an agent via my MCP server, a human will verify it soon.


What do these changes do?

nodejs/llhttp#872 is resolved in llhttp 9.5.0, which master vendors since #14581: llhttp.h now defines HTTP_ALL_METHOD_COUNT, and llhttp_method_name() returns NULL for an unknown id instead of calling abort().

That makes the inline C block from #13174, which rebuilt the name table from HTTP_ALL_METHOD_MAP, unnecessary. This goes back to a plain loop over llhttp_method_name(), bounded by llhttp's count instead of the hardcoded 46 it used before #13174.

A NULL name is stored as None. llhttp has none today (ids 0-46 are all assigned) and the parser never reports an id it has no method for. The old table failed the import with an AssertionError in that case.

Are there changes in behavior for the user?

No. The table holds the same 47 names.

For downstreams: building with AIOHTTP_USE_SYSTEM_DEPS now needs llhttp 9.5.0 or newer. Against an older one the build stops with 'HTTP_ALL_METHOD_COUNT' undeclared.

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

No, it removes code. New llhttp methods are still picked up without a change here.

Related issue number

nodejs/llhttp#872, implemented upstream in nodejs/llhttp#880. Follows #13174. A backport needs llhttp 9.5.0 on that branch first (#14582, #14583).

Checklist

  • I think the code is well written
  • Unit tests for the changes exist (test_parse_query_method covers the highest method id; nothing new to test)
  • Documentation reflects the changes (N/A)
  • If you provide code modifications, please add yourself to CONTRIBUTORS.txt (N/A)
  • Add a new news fragment into the CHANGES/ folder
Local verification
  • Cython 3.3.2 (-Werror) with the vendored llhttp 9.5.0: tests/test_http_parser.py gives 1363 passed, 3 xfailed on 3.13 (same as master) and on 3.11. Full suite on 3.13 with C extensions: 6056 passed, 25 skipped, 17 xfailed.
  • llhttp_method_name() returns the same string as the old table for all 47 ids, and NULL for 47. A request line for each of the 47 names gives the same result from the C parser as on master: 35 decode to llhttp's name (including M-SEARCH and QUERY), and llhttp rejects the 12 RTSP / HTTP/2 ones.
  • NULL names, forced by patching a copy of llhttp.h (FLUSH, id 45, dropped from HTTP_ALL_METHOD_MAP; or HTTP_ALL_METHOD_COUNT raised to 50): the module imports and QUERY still decodes. With the same gap master raises AssertionError on import, or segfaults under python -O.
  • AIOHTTP_USE_SYSTEM_DEPS=1 against a shared llhttp 9.5.0 (CMake build, libllhttp.so.9.5): builds, and the parser tests pass. Against llhttp 9.4.4 the build fails with the error above.
  • pre-commit is clean on the changed files. Not run on Windows, macOS, PyPy, free-threaded builds or Python 3.12/3.14/3.15.

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.13%. Comparing base (abbb10c) to head (9d2d487).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14584   +/-   ##
=======================================
  Coverage   99.13%   99.13%           
=======================================
  Files         135      135           
  Lines       54630    54631    +1     
  Branches     2808     2808           
=======================================
+ Hits        54158    54159    +1     
  Misses        357      357           
  Partials      115      115           
Flag Coverage Δ
Autobahn 21.53% <ø> (ø)
CI-GHA 99.06% <ø> (ø)
OS-Linux 98.75% <ø> (ø)
OS-Windows 97.53% <ø> (+<0.01%) ⬆️
OS-macOS 98.37% <ø> (-0.02%) ⬇️
Py-3.11 98.32% <ø> (ø)
Py-3.12 98.40% <ø> (ø)
Py-3.13 98.39% <ø> (-0.01%) ⬇️
Py-3.14 98.45% <ø> (ø)
Py-3.15 98.45% <ø> (ø)
Py-3.15t 98.30% <ø> (+<0.01%) ⬆️
Py-pypy-3.12 96.99% <ø> (+<0.01%) ⬆️
VM-macos-latest 98.37% <ø> (-0.02%) ⬇️
VM-ubuntu-latest 98.75% <ø> (ø)
VM-windows-latest 97.53% <ø> (+<0.01%) ⬆️
cython-coverage 84.04% <100.00%> (+<0.01%) ⬆️

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.

@codspeed

codspeed Bot commented Dec 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 50 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 102 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing bot-llhttp-method-count (9d2d487) with master (abbb10c)

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Vizonex Vizonex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach is a lot better executed. Glad llhttp made these changes to begin with.

This branch has not been deployed

No deployments
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.

2 participants