👷 fix(tools): route HTTP through httpx2 with tenacity retry#596
Merged
Conversation
Merging this PR will improve performance by 9.42%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_feature[text-content] |
2 ms | 1.8 ms | +9.42% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing gaborbernat:ci/bench-fetch-retry (42c3774) with main (fe744a7)
Footnotes
-
18 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. ↩
33afab8 to
be2e1ca
Compare
be2e1ca to
674736f
Compare
The CodSpeed job and the tools/generate_* scripts fetch pinned corpora and Unicode/PSL/IANA data over the network. A burst of concurrent CI runs draws a 429 from GitHub and the CDNs, and the stdlib urllib calls had no retry, so one rate-limited GET failed the whole run. Route every tool fetch through a shared httpfetch.fetch_bytes built on httpx2 and a tenacity retry that backs off on the transient statuses (429, the 5xx family) and dropped connections, and re-raises a 4xx a retry cannot fix.
674736f to
42c3774
Compare
gaborbernat
added a commit
to gaborbernat/turbohtml
that referenced
this pull request
Jul 9, 2026
A benchmark worker runs in an isolated venv holding pyperf, turbohtml and one competitor. Since the tools moved onto httpx2 (tox-dev#596), building a case imported an HTTP client that venv has never had, so `python -m bench <anything>` died at import with ModuleNotFoundError before it timed a single operation. The download only happens on a cold cache, so import it there, and build the cases in the orchestrator first, where the client lives. The workers read the cache it leaves behind.
This was referenced Jul 9, 2026
gaborbernat
added a commit
to gaborbernat/turbohtml
that referenced
this pull request
Jul 9, 2026
A benchmark worker runs in an isolated venv holding pyperf, turbohtml and one competitor. Since the tools moved onto httpx2 (tox-dev#596), building a case imported an HTTP client that venv has never had, so `python -m bench <anything>` died at import with ModuleNotFoundError before it timed a single operation. The download only happens on a cold cache, so import it there, and build the cases in the orchestrator first, where the client lives. The workers read the cache it leaves behind.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
🚀 CodSpeedjob fetches the CSS and JS minify corpora over HTTP the first time each benchmark runs, and thetools/generate_*scripts pull pinned Unicode, PSL, and IANA data the same way. When several CI runs start close together, GitHub and the npm CDNs answer one of those GETs with429 Too Many Requests, and because the stdliburllibcalls had no retry a single rate-limited response raised straight out of the run and turned it red. 🚦Every network fetch in
tools/now goes through onehttpfetch.fetch_byteshelper built onhttpx2and wrapped in atenacityretry. The retry stays narrow: it backs off with capped exponential wait on a dropped connection (TransportError) and the transient server statuses (429,408,425, the5xxfamily), then re-raises at once anything a retry cannot fix, such as a404or403. The corpus bytes are unchanged, so no benchmark baseline shifts; the fetch just survives a transient rate limit instead of failing the job.httpx2andtenacityjoin thetestdependency group because the benchmark registry imports the corpus module during collection; both ship pure-Pythonpy3-none-anywheels for every supported interpreter, the free-threaded builds included.