Skip to content

👷 fix(tools): route HTTP through httpx2 with tenacity retry#596

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:ci/bench-fetch-retry
Jul 7, 2026
Merged

👷 fix(tools): route HTTP through httpx2 with tenacity retry#596
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:ci/bench-fetch-retry

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Jul 7, 2026

Copy link
Copy Markdown
Member

The 🚀 CodSpeed job fetches the CSS and JS minify corpora over HTTP the first time each benchmark runs, and the tools/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 with 429 Too Many Requests, and because the stdlib urllib calls 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 one httpfetch.fetch_bytes helper built on httpx2 and wrapped in a tenacity retry. The retry stays narrow: it backs off with capped exponential wait on a dropped connection (TransportError) and the transient server statuses (429, 408, 425, the 5xx family), then re-raises at once anything a retry cannot fix, such as a 404 or 403. The corpus bytes are unchanged, so no benchmark baseline shifts; the fetch just survives a transient rate limit instead of failing the job.

httpx2 and tenacity join the test dependency group because the benchmark registry imports the corpus module during collection; both ship pure-Python py3-none-any wheels for every supported interpreter, the free-threaded builds included.

@gaborbernat gaborbernat added the enhancement New feature or request label Jul 7, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 9.42%

⚠️ 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
✅ 81 untouched benchmarks
⏩ 18 skipped benchmarks1

Performance Changes

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)

Open in CodSpeed

Footnotes

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

@gaborbernat gaborbernat force-pushed the ci/bench-fetch-retry branch from 33afab8 to be2e1ca Compare July 7, 2026 19:21
@gaborbernat gaborbernat changed the title 👷 fix(bench): retry corpus downloads on rate limit 👷 fix(tools): route HTTP through httpx2 with tenacity retry Jul 7, 2026
@gaborbernat gaborbernat force-pushed the ci/bench-fetch-retry branch from be2e1ca to 674736f Compare July 7, 2026 19:43
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.
@gaborbernat gaborbernat force-pushed the ci/bench-fetch-retry branch from 674736f to 42c3774 Compare July 7, 2026 20:17
@gaborbernat gaborbernat merged commit 60cca4c into tox-dev:main Jul 7, 2026
44 of 48 checks passed
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.
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.
@gaborbernat gaborbernat deleted the ci/bench-fetch-retry branch July 10, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant