Skip to content

Cache registry fetch-index enumeration across package requests - #284

Draft
zaniebot wants to merge 2 commits into
mainfrom
zb/bughuntperf/265-fetch-index-enumeration
Draft

zaniebot wants to merge 2 commits into
mainfrom
zb/bughuntperf/265-fetch-index-enumeration

Conversation

@zaniebot

@zaniebot zaniebot commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Resolving against many configured indexes repeatedly rebuilds the implicit/default-index sequence and its name and raw-URL deduplication sets for each package request without an index pin. Materialize the effective sequence when RegistryClient is built and share it across client clones. Package requests then iterate that sequence while pinned-index selection, PyTorch-specific routing, index precedence, and --no-index retain their respective behavior.

Hyperfine 2.0.0 measurements of f426bf737 → bb9747d62 used release builds of the complete CLI with rustc 1.99.0 (b940084d7 2026-09-28) on an AMD EPYC-Genoa Linux VM, pinned to four CPUs. Output went to /dev/null. The supplied interpreter was CPython 3.12.13.

Complete uv pip compile commands resolve synthetic requirements pinned to version 1.0.0 against loopback Simple indexes, with no per-package index pin. Cases vary package and index counts, index strategy, the fixture index containing the wheel catalog and repeated index URLs. Fixture positions in the table are zero-based identifiers, not lookup-order positions. The repeated case has 64 distinct URLs and 127 configured occurrences. Client construction, index handling, resolution and requirements formatting are included.

Most cases use per-revision HTTP caches with 24-hour response freshness. A cold control clears both caches before each invocation; later warmups can refill them. The loopback server has no configured delay or pacing and runs outside measured RSS; request-boundary preparation is outside timing, and OS pages are warm.

Values are means, parent → head. Changes are (head / parent - 1) with 95% confidence intervals; negative values indicate a reduction.

Workload Wall time Change, 95% CI Peak RSS Change, 95% CI
1 index / 1 package / wheel catalog at fixture index 0 of 1 (zero-based) / unsafe-best-match / warm cache 21.6 → 21.7 ms +0.26% [-1.23%, +1.63%] 28.40 → 28.35 MiB -0.18% [-0.58%, +0.21%]
8 indexes / 1 package / wheel catalog at fixture index 7 of 8 (zero-based) / unsafe-best-match / warm cache 22.8 → 22.8 ms +0.24% [-1.57%, +2.08%] 28.92 → 28.98 MiB +0.20% [-0.09%, +0.61%]
64 indexes / 1 package / wheel catalog at fixture index 63 of 64 (zero-based) / unsafe-best-match / warm cache 24.4 → 25.0 ms +2.43% [+0.62%, +4.03%] 29.15 → 29.20 MiB +0.17% [-0.23%, +0.63%]
8 indexes / 16 packages / wheel catalog at fixture index 7 of 8 (zero-based) / unsafe-best-match / warm cache 25.3 → 25.1 ms -0.87% [-3.31%, +1.72%] 31.01 → 30.89 MiB -0.38% [-0.78%, +0.03%]
64 indexes / 16 packages / wheel catalog at fixture index 63 of 64 (zero-based) / unsafe-best-match / warm cache 51.1 → 52.4 ms +2.58% [-0.67%, +6.57%] 31.74 → 31.68 MiB -0.21% [-0.52%, +0.08%]
64 indexes / 64 packages / wheel catalog at fixture index 63 of 64 (zero-based) / unsafe-best-match / warm cache 131.5 → 130.9 ms -0.50% [-1.77%, +0.97%] 39.00 → 38.92 MiB -0.21% [-0.69%, +0.19%]
256 indexes / 16 packages / wheel catalog at fixture index 255 of 256 (zero-based) / unsafe-best-match / warm cache 322.3 → 321.4 ms -0.28% [-1.02%, +0.57%] 34.65 → 34.58 MiB -0.22% [-0.50%, +0.12%]
64 indexes / 64 packages / wheel catalog at fixture index 0 of 64 (zero-based) / unsafe-best-match / warm cache 128.8 → 128.3 ms -0.41% [-1.36%, +0.56%] 39.03 → 39.04 MiB +0.02% [-0.23%, +0.26%]
64 indexes / 64 packages / wheel catalog at fixture index 0 of 64 (zero-based) / first-index / warm cache 26.8 → 27.4 ms +2.17% [+0.77%, +3.80%] 31.34 → 31.44 MiB +0.31% [-0.04%, +0.71%]
64 indexes / 16 packages / wheel catalog at fixture index 63 of 64 (zero-based) / unsafe-best-match / 127 configured URL occurrences / warm cache 52.4 → 52.9 ms +0.93% [-0.94%, +2.78%] 31.89 → 31.82 MiB -0.24% [-0.81%, +0.24%]
8 indexes / 16 packages / wheel catalog at fixture index 7 of 8 (zero-based) / unsafe-best-match / cold cache 166.4 → 157.8 ms -5.18% [-11.97%, +0.81%] 34.75 → 34.77 MiB +0.05% [-0.36%, +0.46%]
1 index / 64 packages / wheel catalog at fixture index 0 of 1 (zero-based) / first-index / warm cache 26.3 → 26.4 ms +0.51% [-0.79%, +2.32%] 31.27 → 31.11 MiB -0.49% [-0.72%, -0.26%]

Each workload used ten comparison blocks with alternating revision order, one warmup followed by three measured runs per revision in each block (30 measurements per revision). The pointwise 95% percentile-bootstrap intervals use 20,000 resamples of paired block means and retain all samples. They estimate within-run uncertainty, not variation across machines, independent builds, or separate benchmark campaigns.

Runtime increased by 2.43% for the 64-index, one-package unsafe-best-match case and 2.17% for the 64-index, 64-package first-index case. The other ten runtime intervals include zero. Peak RSS fell by 0.49% for the one-index, 64-package control; the other eleven RSS intervals include zero. These complete-command results do not isolate index enumeration.

RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

Earlier measurements

Earlier benchmark study:

The fetch_index_enumeration benchmark compares the production IndexLocations::fetch_indexes operation with iteration over a prebuilt sequence. It uses 64, 256, and 1,024 synthetic named indexes, the implicit PyPI fallback, and the same number of complete sequence traversals. Fixture and cached-sequence construction are outside the clock; no network request or complete resolver command is timed.

An earlier working tree based on 3ddafbf3fd8a154fd875dbb63d12dcb4058b4820 used a Vec<IndexMetadata> before the final shared Arc representation. Its benchmark blob was a4d097186dd16232858cda44636cd0f9b9318acd. A Rust 1.97.0 profiling build ran two CPU-pinned Criterion sweeps with 30 samples, one second warmup, and three seconds requested measurement time. The following are the retained 95% absolute typical-estimate intervals (slope when present, otherwise mean). The last column is the second run's arithmetic mean divided by its saved first-run mean, minus one; it describes repeat variation for the same endpoint, not a cached-versus-rebuild effect interval.

Endpoint First run Second run Second / first mean − 1
rebuild/64 [173.46 µs, 174.78 µs, 176.08 µs] [169.57 µs, 170.56 µs, 171.84 µs] [-2.7651%, -1.8824%, -0.8456%]
cached/64 [976.97 ns, 977.83 ns, 978.88 ns] [985.49 ns, 994.66 ns, 1.0068 µs] [+0.5870%, +1.3711%, +2.6796%]
rebuild/256 [2.5183 ms, 2.5256 ms, 2.5333 ms] [2.5209 ms, 2.5352 ms, 2.5562 ms] [+0.3505%, +1.1171%, +2.0164%]
cached/256 [15.785 µs, 15.898 µs, 16.049 µs] [15.745 µs, 15.896 µs, 16.068 µs] [-0.8225%, +0.0798%, +1.3037%]
rebuild/1024 [39.829 ms, 39.984 ms, 40.165 ms] [40.595 ms, 41.019 ms, 41.475 ms] [+1.4377%, +2.5899%, +3.6662%]
cached/1024 [423.31 µs, 424.84 µs, 426.43 µs] [431.35 µs, 432.63 µs, 434.23 µs] [+1.6147%, +2.4865%, +3.4700%]

The measured source diff is retained, but the full historical build archive, executable digest, and raw Criterion samples are not. These runs did not measure the final Arc implementation or a whole-command comparison, so the component intervals do not establish a whole-command speedup.

@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from ed77ba3 to 365a81a Compare July 17, 2026 21:43
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 365a81a to cd72569 Compare August 11, 2026 17:07
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from cd72569 to 3c07b2d Compare August 27, 2026 19:17
@zaniebot zaniebot added priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect. performance labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 3c07b2d to 57771e1 Compare September 9, 2026 23:43
@zaniebot zaniebot added the risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. label Sep 11, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 57771e1 to 4986469 Compare October 1, 2026 22:42
@codspeed

codspeed Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 69 untouched benchmarks
🆕 6 new benchmarks
⏩ 35 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation cached[1024] N/A 20.7 ms N/A
🆕 Simulation cached[256] N/A 1.3 ms N/A
🆕 Simulation cached[64] N/A 39.4 µs N/A
🆕 Simulation rebuild[1024] N/A 664.8 ms N/A
🆕 Simulation rebuild[256] N/A 37.2 ms N/A
🆕 Simulation rebuild[64] N/A 2.1 ms N/A

Comparing zb/bughuntperf/265-fetch-index-enumeration (bb9747d) with main (f426bf7)

Open in CodSpeed

Footnotes

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

@zaniebot zaniebot added the build:skip-release Disable building release binaries for a pull request label Oct 7, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 4986469 to 5029f65 Compare October 7, 2026 23:24
Comment on lines +1 to +3
use std::hint::black_box;
use std::str::FromStr;
use std::sync::Arc;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Use uv's allocator in the enumeration benchmark

This benchmark does not link uv_performance_memory_allocator, so it uses the system allocator instead of uv's jemalloc on the Linux benchmark runners. That matters here: rebuild repeatedly allocates and frees hash sets, while cached performs no timed allocations, making the comparison sensitive to allocator choice. Add the same extern crate uv_performance_memory_allocator; prelude used by uv_pypi_types.rs and workspace_discovery.rs so the benchmark measures allocation costs under uv's runtime configuration.

@zaniebot
zaniebot deployed to automations October 8, 2026 23:04 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 5fae614 to bb9747d Compare October 15, 2026 08:30
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from bb9747d to 473e21a Compare October 18, 2026 04:02
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/265-fetch-index-enumeration branch from 473e21a to b8bb721 Compare October 23, 2026 19:17

This branch was successfully deployed

1 active (outdated) deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:skip-release Disable building release binaries for a pull request performance priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants