aiohttp icon indicating copy to clipboard operation
aiohttp copied to clipboard

Add HTTP parser memory regression tests

Open codingkiddo opened this issue 5 months ago • 2 comments

What do these changes do?

This adds HTTP parser memory regression coverage for oversized inputs.

The new tests cover a small first slice of #12736:

  • a very long request line
  • a very long header line

The tests measure peak memory usage while feeding already-created input into the parser, so the large test input allocation itself is not included in the measured peak.

Are there changes in behavior for the user?

No. This is a test-only change and does not change runtime behavior or public APIs.

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

No. The change only adds focused regression tests for existing HTTP parser behavior.

The memory threshold is intentionally conservative to reduce the chance of CI flakiness across platforms and Python versions. The tests are also limited to a small HTTP parser scope, leaving the broader multipart and chunked-parser cases from #12736 for follow-up PRs.

Related issue number

Part of #12736

Checklist

  • [x] I think the code is well written
  • [x] Unit tests for the changes exist
  • [x] Documentation reflects the changes
  • [x] If you provide code modification, please add yourself to CONTRIBUTORS.txt
  • [x] Add a new news fragment into the CHANGES/ folder

codingkiddo avatar Jun 08 '26 07:06 codingkiddo

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 98.95%. Comparing base (86c33ba) to head (6996a9e). :warning: Report is 4 commits behind head on master. :white_check_mark: All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12871   +/-   ##
=======================================
  Coverage   98.95%   98.95%           
=======================================
  Files         131      131           
  Lines       47719    47743   +24     
  Branches     2475     2475           
=======================================
+ Hits        47219    47243   +24     
  Misses        376      376           
  Partials      124      124           
Flag Coverage Δ
Autobahn 22.26% <20.00%> (-0.01%) :arrow_down:
CI-GHA 98.92% <100.00%> (+<0.01%) :arrow_up:
OS-Linux 98.68% <100.00%> (+<0.01%) :arrow_up:
OS-Windows 97.07% <100.00%> (+<0.01%) :arrow_up:
OS-macOS 97.95% <100.00%> (+<0.01%) :arrow_up:
Py-3.10 98.17% <100.00%> (-0.01%) :arrow_down:
Py-3.11 98.42% <100.00%> (+<0.01%) :arrow_up:
Py-3.12 98.51% <100.00%> (-0.01%) :arrow_down:
Py-3.13 98.49% <100.00%> (+<0.01%) :arrow_up:
Py-3.14 98.51% <100.00%> (+<0.01%) :arrow_up:
Py-3.14t 97.58% <100.00%> (+<0.01%) :arrow_up:
Py-pypy-3.11 97.42% <48.00%> (-0.04%) :arrow_down:
VM-macos 97.95% <100.00%> (+<0.01%) :arrow_up:
VM-ubuntu 98.68% <100.00%> (+<0.01%) :arrow_up:
VM-windows 97.07% <100.00%> (+<0.01%) :arrow_up:
cython-coverage 38.17% <100.00%> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 08 '26 07:06 codecov[bot]

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 72 skipped benchmarks[^skipped]


Comparing codingkiddo:test/http-parser-memory-regression (6996a9e) with master (86c33ba)

Open in CodSpeed

[^skipped]: 72 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.

codspeed[bot] avatar Jun 08 '26 08:06 codspeed[bot]