Skip to content

Speed up opening boundary matching - #328

Merged
Kludex merged 3 commits into
mainfrom
speed-up-opening-boundary
Sep 25, 2026
Merged

Kludex merged 3 commits into
mainfrom
speed-up-opening-boundary

Conversation

@Kludex

@Kludex Kludex commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

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 for max_size truncating the opening boundary; existing tests cover chunk splitting and malformed boundaries.

Performance

Local CPython 3.13.4 on macOS ARM64, medians of 15 interleaved timeit runs with a fresh parser per iteration:

Two-field form Before After Less parsing time
MultipartParser 22.01 µs 14.39 µs 34.6%
FormParser, collecting fields 30.63 µs 22.72 µs 25.8%

Large uploads and one-byte chunks were effectively unchanged; these are parser timings, not HTTP throughput measurements.

Validation

  • 161 tests pass with 100% package coverage.
  • Ruff, mypy, check-sdist, and the lockfile check pass.
  • The new regression test passes with -W error; the full suite exposes three existing unclosed-file warning failures, reproduced on main.

Review in cubic

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T19:29:49.421338Z 06d7f18 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 16.71%

⚠️ 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

⚡ 1 improved benchmark
✅ 4 untouched benchmarks
⏩ 5 skipped benchmarks1

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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. ↩

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread python_multipart/multipart.py
@Kludex
Kludex merged commit ce899b5 into main Sep 25, 2026
15 checks passed
@Kludex
Kludex deleted the speed-up-opening-boundary branch September 25, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant