Skip to content

Index dependency endpoints within each resolver fork - #2453

Draft
zaniebot wants to merge 1 commit into
mainfrom
zb/opportunity-09-02-index-fork-edges
Draft

zaniebot wants to merge 1 commit into
mainfrom
zb/opportunity-09-02-index-fork-edges

Conversation

@zaniebot

@zaniebot zaniebot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Intermediate resolver edges retain complete package identities for their endpoints while the fork already owns the selected nodes. Store indices into each fork's node vector and translate them into output graph positions before deduplicating edges. Borrow package identities during lookup and release each fork's buffers as it is merged. The merge distinguishes package sources, versions, and virtual extra/group nodes, choosing selected artifacts from the first fork that supplies a matching node.

Hyperfine 2.0.0 measurements of 301799d97 → 3665d8fe2 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 lock --no-index --python PYTHON --directory FIXTURE --offline --no-config --color never --cache-dir CACHE, with warm OS page caches and output sent to /dev/null.

The root and its dependencies are local virtual projects with static metadata. The root depends on all listed packages; each package depends on up to the indicated number of later packages, forming an acyclic graph with shared targets. Ordinary source paths are 63 characters relative to the root. The forked case adds two versions of another local package, selected by mutually exclusive Linux and non-Linux markers. Hyperfine's --prepare removes uv.lock and restores the root project before each invocation; restoration is excluded from time and peak RSS. Every invocation performs fresh universal resolution and writes its lockfile, without a build backend, wheel download, or installation.

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
100 packages, up to 1 outgoing dependency each 62.6 → 61.5 ms -1.70% [-3.30%, -0.08%] 37.82 → 37.54 MiB -0.74% [-1.30%, -0.15%]
1,000 packages, up to 1 outgoing dependency each 1,192.5 → 1,186.8 ms -0.48% [-1.35%, +0.21%] 104.12 → 100.19 MiB -3.78% [-4.64%, -2.79%]
1,000 packages, up to 10 outgoing dependencies each 1,767.7 → 1,736.7 ms -1.75% [-2.16%, -1.26%] 149.75 → 136.90 MiB -8.58% [-9.37%, -7.84%]
2,000 packages, up to 20 outgoing dependencies each 7,152.9 → 6,982.0 ms -2.39% [-2.89%, -1.83%] 398.77 → 343.88 MiB -13.76% [-14.46%, -13.05%]
1,000 packages, up to 10 outgoing dependencies each, 2 platform forks 1,942.0 → 1,862.7 ms -4.08% [-5.08%, -3.19%] 181.86 → 148.79 MiB -18.19% [-18.87%, -17.41%]

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, independent builds, or separate benchmark campaigns.

The largest graph uses about 54.9 MiB less peak RSS (13.8%) and takes 2.4% less time. The forked graph uses about 33.1 MiB less peak RSS (18.2%) and takes 4.1% less time. For 1,000 packages with at most one outgoing dependency each, the runtime interval includes zero while peak RSS falls by about 3.9 MiB. These synthetic local-source graphs measure the whole command, including metadata reading, universal resolution, intermediate and final graph construction, and lockfile serialization. They do not isolate endpoint storage or establish the effect on registry-index workloads. 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 10:42 — 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 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
⏩ 35 skipped benchmarks1


Comparing zb/opportunity-09-02-index-fork-edges (cc8775d) with main (2858dbc)

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 deployed to automations October 14, 2026 18:17 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 14, 2026 18:22 — with GitHub Actions Active
Comment on lines +3134 to +3135
.collect();
let nodes: Vec<_> = nodes.into_iter().collect();

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] Collect fork nodes directly into the vector

The intermediate FxHashMap is consumed without any lookups, and node_indices immediately hashes the identities again. Filtering to Package nodes with MarkerTree::TRUE already leaves one selected version per interned (name, kind) in a fork, so this map does not provide necessary deduplication. Now that Resolution::nodes is a vector, collect directly into Vec<_> and build node_indices from it, removing a transient allocation and redundant hashing pass for each fork.

@zaniebot
zaniebot deployed to automations October 14, 2026 18:45 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/opportunity-09-02-index-fork-edges branch from 3665d8f to cc8775d Compare October 15, 2026 14:57
charliermarsh added a commit to astral-sh/uv that referenced this pull request Oct 16, 2026
## Summary

We currently clone the full package identity and version for both
endpoints of every dependency edge. On large graphs, this duplicates the
same information many times, especially across resolver forks.

This stores each fork's nodes in a vector and represents dependency
edges using indices into that vector. When merging forks, we translate
those indices into output graph nodes before deduplicating edges.
Package source, version, extras, and dependency groups remain part of
the node identity.

Port of [uv-dev#2453](astral-sh#2453).

## Benchmarks

On a Linux AMD EPYC devbox, we measured fresh, offline `uv lock` runs
for synthetic local projects with warm caches. The results are means
from 30 runs per revision:

| Project | Peak RSS, before → after | Wall time, before → after |
| ----------------------------------------------------- |
-------------------------: | ------------------------: |
| 1,000 packages, up to 1 dependency each | 96.0 → 93.5 MiB (-2.6%) |
1.451 → 1.453 s (+0.1%) |
| 1,000 packages, up to 10 dependencies each | 126.1 → 114.0 MiB (-9.6%)
| 2.112 → 2.086 s (-1.2%) |
| 2,000 packages, up to 20 dependencies each | 315.5 → 276.8 MiB
(-12.3%) | 8.683 → 8.519 s (-1.9%) |
| 1,000 packages, up to 10 dependencies each, two forks | 147.2 → 117.6
MiB (-20.1%) | 2.264 → 2.206 s (-2.6%) |

Jupyter and Trio showed no clear change. The wall-time differences are
small: identical-binary controls varied by around 1%.

The comparison used release builds of `c8e4086` and `93a96e9`. The
latter predates removal of two explicit drops; a separate comparison
found no significant difference from removing them.

---------

Co-authored-by: zaniebot <[email protected]>

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