Speed up opening boundary matching - #328
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merging this PR will improve performance by 16.71%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_parse_multipart_simple_form |
498.4 µs | 427 µs | +16.71% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing speed-up-opening-boundary (582240e) with main (fc922ef)
Footnotes
-
5 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. ↩
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Match complete opening boundaries with
bytes.startswith(), retaining byte-by-byte parsing for fragmented or mismatched boundaries and the existing delimiter validation. Keep one regression test formax_sizetruncating the opening boundary; existing tests cover chunk splitting and malformed boundaries.Performance
Local CPython 3.13.4 on macOS ARM64, medians of 15 interleaved
timeitruns with a fresh parser per iteration:MultipartParserFormParser, collecting fieldsLarge uploads and one-byte chunks were effectively unchanged; these are parser timings, not HTTP throughput measurements.
Validation
check-sdist, and the lockfile check pass.-W error; the full suite exposes three existing unclosed-file warning failures, reproduced onmain.AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.