perf(install): cap tarball downloads at 128 and reuse their connections #2037
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2037"
general
weight: 0.35
jdx
Problem
aube downloads tarballs over HTTP/1.1, so every tarball in flight holds its own TCP + TLS connection. Two settings made a cold install open far more connections than it needed:
maxsocketsdefault). When a download finished while more than 64 connections were idle, hyper closed that connection. When demand rose again, aube opened new ones.On a cold install of the vlt benchmarks'
babylonfixture against registry.npmjs.org, aube opened about 400 TCP + TLS connections (172–669 across runs) and typically left 200–490 sockets in TIME_WAIT. While debugging aubepkg/aube#2031 we saw all of aube's pooled connections to the npm CDN go silent at once while new connections still worked. Opening fewer connections lowers aube's footprint on the CDN and on any middlebox in between.Change
TARBALL_MAX_CONCURRENCY), down from 256. 128 is also the top of the defaultnetworkConcurrencyseed (workers × 3, clamped to 16–128), so the limiter still starts where it did. Below the cap it adapts as before.networkConcurrencyabove 128 still raises the tarball ceiling, as before.maxsockets, when set, still sizes both pools.maxsocketsandnetworkConcurrencysetting docs (themaxsocketsdefault was documented asnetworkConcurrency x 3; it was 64) and a comment that still assumed tarballs were multiplexed over HTTP/2.Results
Real registry (
babylon, cold, no lockfile)Each run is a fresh
HOME, store and cache, usingaube install --ignore-scriptsagainst registry.npmjs.org from one Linux machine (Ryzen 9 7950X3D, 32 threads, home connection). Connections areconnect()calls to port 443 recorded withstrace -f --seccomp-bpf -e trace=connect. Only IPv4 is counted: this host has no IPv6 route, so its IPv6 attempts fail at once. "Peak open" is the most established :443 sockets the aube process held, sampled every 50 ms withss.The final build against main, 6 interleaved runs each (no stalls in this window):
| | new connections (median, range) | peak open | TIME_WAIT left | time (median) |
|---|---|---|---|---|
| main | 390 (281–420) | 72–113 | 200–370 | 8.3s |
| this PR | 198 (122–202) | 55–134 | ≈0 | 8.6s |
Peak open is now bounded by the cap, at about 131 including metadata connections. On main it varies with how the limiter grows. In other runs it reached 155–179.
Choosing the cap: I tried pool and cap variants through temporary env knobs, built on aubepkg/aube#2031 (now merged; this branch is rebased on it). Without #2031 some runs hang for minutes on a stalled download, which swamps the timings. With it, a stall costs about 10s and shows up as a logged retry. This made it possible to count stalls. Here are 8 interleaved runs per variant in one network window, when the CDN was stalling often:
| variant | new connections | peak open (max) | runs with stalls | stall retries | time (median) |
|---|---|---|---|---|---|
| main (cap 256, pool 64) | 420 | 155 | 8/8 | 66 | 21.8s |
| pool 256 only | 197 | 259 | 6/8 | 28 | 19.1s |
| cap 128, pool 128 | 198 | 133 | 6/8 | 16 | 16.0s |
| cap 96, pool 96 | 173 | 108 | 8/8 | 20 | 15.3s |
Real-registry timings vary a lot from run to run and from hour to hour, so treat the time column as a direction, not a measurement. A cap of 64 opened the fewest connections (138) but was clearly slower on the hermetic bench (below).
Hermetic bench (gvs-cold, 500 Mbit/s, 50 ms)
benchmarks/bench.shwith themise run benchsettings (BENCH_HERMETIC=1,BENCH_BANDWIDTH=500mbit,BENCH_LATENCY=50ms), aube only, gvs-cold scenario, 10 timed runs per bench, variants interleaved by round. Each row pools two rounds: the env-knob build and this PR's build, 60 samples each.| | median | mean | samples over 1.5s |
|---|---|---|---|
| main | 1.145s | 1.196s | 3 |
| this PR | 1.160s | 1.221s | 6 |
Without the samples over 1.5s, the means are 1.156s and 1.159s. The slow samples come in bursts within single benches, and the machine's load average was 18–22 from other work during the final round. Other variants: cap 96 had a median 2.7% above main (1.169s against 1.138s in the same round), and cap 64 was about 20% slower (fastest runs 1.29–1.31s against 1.04–1.09s).
Limitations
🤖 Generated with Claude Code
AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: unavailable.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Performance
Tarball downloads adapt from 4 up to 128 concurrent requests by default; configured network concurrency can raise the limit above 128.
Metadata requests retain their separate adaptive concurrency range, starting at 4 and reaching at least 256.
Default idle connection pools are 64 for metadata and 128 for tarballs. Higher network concurrency does not increase the tarball pool; a custom connection limit applies to both.
Documentation
Updated settings guidance to explain the separate connection-pool defaults and adaptive concurrency limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->