Skip to content

Inline singleton installed-package index lists - #2435

Draft
zaniebot wants to merge 2 commits into
mainfrom
zb/opportunity-09-06-inline-installed-indices
Draft

zaniebot wants to merge 2 commits into
mainfrom
zb/opportunity-09-06-inline-installed-indices

Conversation

@zaniebot

@zaniebot zaniebot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

SitePackages allocates a separate index vector for each package name and direct-source URL, even when it contains only one distribution. Store that first index inline and reserve a small heap buffer when duplicates require spilling, retaining insertion order, tombstone filtering, and the owned query results.

Hyperfine 2.0.0 measurements of 301799d97 → 07cefeb10 used release builds with Rust 1.99.0 and CPython 3.12.13 on an AMD EPYC-Genoa Linux VM, pinned to four CPUs. The command was uv pip list --format json --target FIXTURE --python PYTHON --offline --no-config --color never --cache-dir CACHE, with warm OS page caches and interpreter-discovery metadata. Output went to /dev/null.

Singleton fixtures contain generated .dist-info directories with one distribution per name; direct-source fixtures also have one editable file: URL per name in direct_url.json. The duplicate fixture has 12,500 names and URLs with four versions each, exercising heap spill in both indexes. These are synthetic metadata fixtures; the 50,000-distribution cases are stress workloads.

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
Empty target 15.5 → 15.6 ms +0.29% [-1.45%, +2.05%] 20.76 → 20.61 MiB -0.72% [-1.28%, -0.08%]
100 registry distributions 17.8 → 17.4 ms -1.92% [-3.11%, -0.83%] 21.26 → 21.12 MiB -0.67% [-1.02%, -0.33%]
1,000 registry distributions 35.2 → 34.8 ms -1.16% [-4.77%, +1.23%] 22.30 → 22.04 MiB -1.16% [-1.83%, -0.52%]
10,000 registry distributions 204.9 → 203.0 ms -0.90% [-2.01%, +0.32%] 33.45 → 33.54 MiB +0.27% [-0.33%, +0.89%]
50,000 registry distributions 979.9 → 964.2 ms -1.60% [-2.47%, -0.85%] 69.59 → 68.15 MiB -2.07% [-2.24%, -1.89%]
1,000 direct-source distributions 50.6 → 50.0 ms -1.26% [-2.32%, -0.23%] 22.98 → 22.70 MiB -1.23% [-1.60%, -0.87%]
10,000 direct-source distributions 372.2 → 363.7 ms -2.28% [-7.51%, +1.49%] 38.68 → 38.26 MiB -1.09% [-2.39%, +0.19%]
50,000 direct-source distributions 1,820.5 → 1,796.3 ms -1.33% [-3.48%, +0.43%] 97.16 → 95.29 MiB -1.92% [-2.45%, -1.44%]
50,000 direct-source distributions, four versions per name/URL 1,765.8 → 1,755.5 ms -0.58% [-2.77%, +0.86%] 93.54 → 94.22 MiB +0.73% [-0.85%, +2.22%]

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 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 or separate runs.

The largest singleton fixtures reduce mean peak RSS by about 1.4–1.9 MiB. Most runtime intervals include zero; the 50,000-distribution registry case shows a small reduction. Neither metric establishes an improvement in the duplicate fixture. The empty-target control also shifts RSS by about 0.15 MiB, so the small-environment RSS differences should not be attributed entirely to index allocation. These whole-command measurements include startup, directory traversal, distribution filename and direct-source JSON parsing, sorting, and serialization. RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

@zaniebot
zaniebot deployed to automations October 8, 2026 09:26 — with GitHub Actions Active
@astral-automations-bot astral-automations-bot Bot added internal A refactor or improvement that is not user-facing performance labels Oct 8, 2026
@codspeed

codspeed Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 10.22%

⚠️ 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

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

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ ⚠️ Simulation discover_workspace_from_all_members_with_excludes 164.1 ms 148.9 ms +10.22%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing zb/opportunity-09-06-inline-installed-indices (708b2f9) with main (a03d0cd)

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

by_url: FxHashMap<DisplaySafeUrl, SmallVec<[usize; 1]>>,
}

/// Keep single installations inline and reserve a small run when duplicate records spill.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this comment documenting this function clearly?

@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/opportunity-09-06-inline-installed-indices branch from 07cefeb to 708b2f9 Compare October 16, 2026 16:06

This branch was successfully deployed

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

Labels

internal A refactor or improvement that is not user-facing performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants