Skip to content

Skip cookie extraction without Set-Cookie - #1107

Merged
Kludex merged 4 commits into
mainfrom
perf/cookie-extraction-fast-path
Aug 5, 2026
Merged

Skip cookie extraction without Set-Cookie#1107
Kludex merged 4 commits into
mainfrom
perf/cookie-extraction-fast-path

Conversation

@Kludex

@Kludex Kludex commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Skip CookieJar.extract_cookies() when a response has no Set-Cookie header.

The current path constructs urllib request/response compatibility wrappers and an email message for every response, even though most responses cannot update the cookie jar. Checking the already-parsed response headers first avoids that work while preserving cookie handling when Set-Cookie is present.

Related to #827.

Benchmark

The #827 localhost benchmark uses 100 requests at concurrency 20 after a 100-request warmup. Median across three 10-round runs:

main This PR
Total time 42.14 ms 38.75 ms

This is an approximately 8% improvement for HTTPX2 in this workload.

Validation

  • Added a regression test proving that the cookie jar is not invoked without Set-Cookie.
  • Existing multiple-Set-Cookie coverage continues to pass.
  • Full suite: 1,909 passed, 1 skipped.
  • Mypy, Ruff, formatting, and git diff --check pass.

Review in cubic

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

@codspeed-hq

codspeed-hq Bot commented Aug 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing perf/cookie-extraction-fast-path (ebb0f94) with main (89c644d)

Open in CodSpeed

Footnotes

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d3dfd3464

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/httpx2/httpx2/_models.py Outdated

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

Copy link
Copy Markdown
Contributor

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

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/httpx2/httpx2/_models.py Outdated
@Kludex
Kludex enabled auto-merge (squash) August 5, 2026 10:42
@Kludex
Kludex merged commit da4452a into main Aug 5, 2026
17 checks passed
@Kludex
Kludex deleted the perf/cookie-extraction-fast-path branch August 5, 2026 10:47
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