Skip to content

perf(pm): fan out registry http clients#3036

Closed
elrrrrrrr wants to merge 1 commit into
perf/pm-split-resolver-mock-providerfrom
perf/pm-split-resolver-http-client-pool
Closed

perf(pm): fan out registry http clients#3036
elrrrrrrr wants to merge 1 commit into
perf/pm-split-resolver-mock-providerfrom
perf/pm-split-resolver-http-client-pool

Conversation

@elrrrrrrr
Copy link
Copy Markdown
Contributor

Summary

Review-sized split from #3028 / #2948, stacked after #3035.

Fans registry manifest requests across a small native reqwest client pool:

  • keeps wasm on a single browser-backed client;
  • uses four native clients with independent keep-alive pools;
  • round-robins get_client() with a relaxed atomic counter;
  • preserves proxy/DNS/client-builder error handling.

This isolates the GHA/npmjs Cloudflare single-pool bottleneck experiment into one small PR.

Size

Validation

  • cargo fmt
  • cargo check -p utoo-ruborist
  • cargo clippy --all-targets -- -D warnings --no-deps

pack-napi still warns locally because next.js is a symlink in this worktree; clippy exits successfully.

@elrrrrrrr elrrrrrrr added A-Pkg Manager Area: Package Manager benchmark Run pm-bench on PR labels May 21, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a pool of HTTP clients for non-WASM targets to improve request distribution across multiple IP addresses, utilizing a round-robin selection mechanism via an atomic counter. For WASM targets, the single-client implementation is maintained. Feedback was provided to include a compile-time assertion ensuring the client pool size is greater than zero, which prevents a potential division-by-zero panic during client retrieval.

/// independent keep-alive pools to fan out when npmjs/full-manifest
/// concurrency is raised.
#[cfg(not(target_arch = "wasm32"))]
const CLIENT_POOL_SIZE: usize = 4;
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.

medium

While CLIENT_POOL_SIZE is currently a constant set to 4, it would be safer to add a compile-time assertion to ensure it is never accidentally set to 0. If it were 0, the HTTP_CLIENTS initialization would succeed with an empty Vec, but get_client() would subsequently panic due to a division by zero in the modulo operation on line 118. This approach ensures the bug is caught at compile-time, adhering to the principle that panics should be treated as bugs to be fixed.

Suggested change
const CLIENT_POOL_SIZE: usize = 4;
const CLIENT_POOL_SIZE: usize = 4;
#[cfg(not(target_arch = "wasm32"))]
const _: () = assert!(CLIENT_POOL_SIZE > 0, "CLIENT_POOL_SIZE must be at least 1");
References
  1. Panics should be treated as unrecoverable bugs that need to be fixed, not as transient, recoverable errors. A compile-time assertion ensures the configuration is valid and prevents a runtime panic.

@elrrrrrrr elrrrrrrr force-pushed the perf/pm-split-resolver-mock-provider branch from f59d68b to 8c06b60 Compare May 21, 2026 22:32
@elrrrrrrr elrrrrrrr force-pushed the perf/pm-split-resolver-http-client-pool branch 2 times, most recently from 5b73204 to e68b1b8 Compare May 21, 2026 23:09
@elrrrrrrr elrrrrrrr force-pushed the perf/pm-split-resolver-mock-provider branch from 519961e to a7138a9 Compare May 21, 2026 23:39
@elrrrrrrr elrrrrrrr force-pushed the perf/pm-split-resolver-http-client-pool branch from e68b1b8 to 5b0b1ce Compare May 21, 2026 23:39
@github-actions
Copy link
Copy Markdown

📊 pm-bench-phases · 599034d · linux (ubuntu-latest)

Workflow run — ant-design

PMs: utoo (this branch) · utoo-npm (latest published) · bun (latest)

npmjs.org

p0_full_cold

PM wall ±σ user sys RSS pgMinor
bun 12.24s 2.44s 10.28s 10.20s 578M 301.4K
utoo-next 20.59s 17.40s 10.99s 13.38s 951M 119.2K
utoo-npm 19.25s 12.51s 11.09s 13.67s 963M 121.0K
utoo 10.45s 2.26s 10.84s 13.23s 1.02G 117.7K
PM vCtx iCtx netRX netTX cache node_mod lock
bun 24.0K 14.7K 1.19G 7M 1.86G 1.75G 1M
utoo-next 172.0K 103.6K 1.16G 6M 1.71G 1.70G 2M
utoo-npm 186.6K 123.3K 1.16G 6M 1.71G 1.70G 2M
utoo 153.7K 98.4K 1.16G 6M 1.71G 1.70G 2M

p1_resolve

PM wall ±σ user sys RSS pgMinor
bun 4.38s 2.18s 3.86s 1.09s 472M 179.6K
utoo-next 4.96s 2.59s 5.52s 1.88s 611M 89.0K
utoo-npm 3.60s 0.15s 5.68s 2.21s 600M 80.0K
utoo 6.19s 3.01s 5.51s 1.92s 610M 80.2K
PM vCtx iCtx netRX netTX cache node_mod lock
bun 15.0K 2.9K 202M 3M 107M - 1M
utoo-next 57.5K 71.0K 200M 3M 7M 3M 2M
utoo-npm 86.4K 85.2K 200M 3M 7M 3M 2M
utoo 58.9K 72.1K 200M 3M 7M 3M 2M

p3_cold_install

PM wall ±σ user sys RSS pgMinor
bun 6.67s 0.07s 6.37s 10.25s 537M 196.4K
utoo-next 8.45s 0.18s 5.09s 11.33s 469M 58.4K
utoo-npm 9.06s 1.25s 5.21s 11.46s 433M 57.4K
utoo 8.24s 0.32s 5.09s 11.23s 460M 59.2K
PM vCtx iCtx netRX netTX cache node_mod lock
bun 7.5K 8.4K 1019M 4M 1.76G 1.76G 1M
utoo-next 120.1K 58.7K 990M 3M 1.70G 1.70G 2M
utoo-npm 130.5K 57.8K 990M 3M 1.70G 1.70G 2M
utoo 120.3K 62.8K 990M 3M 1.70G 1.70G 2M

p4_warm_link

PM wall ±σ user sys RSS pgMinor
bun 3.28s 0.15s 0.19s 2.34s 135M 32.7K
utoo-next 2.20s 0.10s 0.49s 3.74s 78M 18.3K
utoo-npm 2.17s 0.04s 0.49s 3.68s 79M 18.1K
utoo 2.17s 0.07s 0.50s 3.74s 79M 18.9K
PM vCtx iCtx netRX netTX cache node_mod lock
bun 403 23 5M 56K 1.91G 1.75G 1M
utoo-next 40.5K 18.7K 9K 11K 1.70G 1.70G 2M
utoo-npm 41.7K 19.2K 8K 5K 1.70G 1.70G 2M
utoo 43.1K 19.7K 8K 24K 1.71G 1.70G 2M

npmmirror.com: no output captured.

@elrrrrrrr
Copy link
Copy Markdown
Contributor Author

Closing this temporary fine-grained draft split. We are replacing it with a smaller 9-PR review stack based on the source PRs.

@elrrrrrrr elrrrrrrr closed this May 25, 2026
@elrrrrrrr elrrrrrrr deleted the perf/pm-split-resolver-http-client-pool branch May 25, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager benchmark Run pm-bench on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant