Skip to content

Use shared PubGrub incompatibility storage - #22771

Draft
charliermarsh wants to merge 1 commit into
mainfrom
charlie/resolver-rss-unified
Draft

charliermarsh wants to merge 1 commit into
mainfrom
charlie/resolver-rss-unified

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Use the shared incompatibility arena from PubGrub #90. Immutable records share 256-record chunks, while each solver state keeps its own contradiction cache. This is an alternative to #22784 and needs a PubGrub release before landing.

These historical four-run medians compare an earlier dependency update with main, before #22769 and PubGrub 0.7.0 landed, on a large project. That update also included other upstream changes, so the savings cannot be attributed solely to chunk sharing. The current rebased PR has not been benchmarked against current main.

Resolve Historical main Earlier dependency update
7,777 packages, fresh 955.7 MiB / 48.86 s 830.9 MiB / 48.91 s
7,777 packages, upgrade 1,192.5 MiB / 49.32 s 1,070.1 MiB / 49.45 s

@codspeed

codspeed Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 16.2%

3 warnings

⚠️ Unable to measure the execution of 1 benchmark

This benchmark measured no execution time, so its result is not comparable and counts as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ 6 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 116 untouched benchmarks
⏩ 54 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation imbibe_marker_no_conflicts[0] 398.5 ns 343 ns +16.2%

Tip

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


Comparing charlie/resolver-rss-unified (13f81d1) with main (384d963)

Open in CodSpeed

Footnotes

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

@charliermarsh charliermarsh changed the title Reduce retained state across resolver forks Use shared PubGrub incompatibility storage Oct 20, 2026
charliermarsh added a commit that referenced this pull request Oct 21, 2026
When a resolution forks, we currently clone the solver for every pending
sibling even though we solve them sequentially. We share one checkpoint
between pending siblings and materialize each solver state only when it
runs. The last sibling takes ownership of the checkpoint. Metadata
prefetch still visits every sibling eagerly.

On a 7,777-package project, peak RSS fell 9.4% for a fresh lock and 7.1%
for an upgrade, while median runtime rose 2.7% and 1.9%, respectively.
These are four-run medians on one Linux host.
[#22771](#22771) measures the three
resolver memory changes together.
@charliermarsh
charliermarsh force-pushed the charlie/resolver-rss-unified branch from 0b7032c to 13f81d1 Compare October 21, 2026 14:22
konsti-openai pushed a commit to astral-sh/pubgrub that referenced this pull request Oct 22, 2026
Store each incompatibility in an Arc. Cloning a solver state copies
the arena's vector of handles. Updating a shared contradiction cache
through Arc::make_mut copies only the affected record.

Compare uv main at 2b50cbc0 (PubGrub 0.6.1) with the original heads of
#90 (307ac04) and astral-sh/uv#22771 (0b7032ce),
before deferred fork cloning landed. This patch uses that same uv main.

                             PubGrub diff      uv diff
Original PRs                 +277 / -144       +166 / -169
Per-record sharing (this)      +6 /  -11       dependency pin only

The PubGrub count for #90 is against its own parent. Updating from
0.6.1 to its head also picked up earlier changes (+753/-492 total).
This patch changes 17 lines in one file and needs no uv source edits.

Times are geometric means ± one standard error (SE). Average log times,
or paired same-round log ratios, within each devbox first. Estimate the
SE across devbox means and convert it back to timing units. For a change
expressed in percent, the SE is in percentage points. RSS is median
process peak memory.

Fresh offline lock on a generated graph with a late fork

                         Baseline       Full PRs     This patch
Wall time (ms)        178.5 ± 1.0    146.0 ± 0.5    145.7 ± 1.3
Peak uv RSS (MiB)            93.5           70.8           69.5
Time vs baseline (%)            —  -18.22 ± 0.16  -18.40 ± 0.30

The root requires Python >=3.10 and the first of 160 packages in a
chain. Each package pins the same 32 leaves and, until the last, its
successor at version 1. At the end, 16 mutually exclusive
python_full_version markers select versions 1 through 16 of one package
(3.10.0 through 3.10.14, then >=3.10.15). All wheels are generated
locally.

Each build ran six fresh locks per Linux devbox on two devboxes with a
primed cache, no index and rotated order. All builds produced the same
lock on each host. This patch saved 25.7% peak RSS against baseline and
the full PRs saved 24.3%. Its paired wall-time change versus the full
PRs was -0.22 ± 0.57%.

Upstream uv resolver suite, wall time in milliseconds

Workload               Baseline      Full PRs    This patch  Patch vs full (%)
Jupyter            14.90 ± 0.15  14.94 ± 0.13  15.20 ± 0.21       +1.74 ± 1.58
Jupyter universal    66.6 ± 0.6    66.4 ± 0.6    67.1 ± 0.9       +1.12 ± 0.74
Airflow             169.9 ± 1.8   167.8 ± 2.2   172.5 ± 2.9       +2.78 ± 0.50
Airflow universal   495.9 ± 1.7   492.9 ± 1.8   498.6 ± 2.1       +1.16 ± 0.32

Peak process RSS in MiB

Workload           Baseline  Full PRs  This patch
Jupyter                32.1      32.0        32.1
Jupyter universal      44.0      43.5        43.9
Airflow               122.2     123.1       123.2
Airflow universal     145.7     144.3       144.6

Each upstream case ran 40 times per build across four devboxes,
including the universal Airflow case disabled in CI. Paired peak RSS
differed by at most 0.7% between this patch and the full PRs. The uv
binaries used Rust 1.99 and Cargo's profiling profile.

End-to-end uv, change from full PRs across 21 fixed upstream workloads

Mode         Wall time (%)  Peak RSS (%)
Warm          -1.49 ± 0.84          +0.1
Cold          +1.26 ± 1.40          +0.5
Incremental   -1.34 ± 0.69          -0.3
No-op         -0.27 ± 0.52          -0.1

Each workload has equal weight. The CLI SE propagates within-workload
paired timing variance on the log scale, treating the measurements of
different workloads as independent. Cold runs include network time. All
84 workload/mode combinations produced identical output across builds.
Three unsatisfiable inputs reached the same dependency conflicts.

The allocation per record also affects unforked solves. PubGrub's
standalone backtracking_singletons benchmark took 42.9% longer than
0.6.1 (standard error 5.7 percentage points, three paired runs).
The exposed 0.6.1 arena loses range indexing and mutable ID indexing
now requires T: Clone. Self-dependency diagnostics follow 0.6.1.

#90
astral-sh/uv#22771

This branch was previously deployed

1 inactive deployment
automations — 13f81d1f Deployed Oct 21, 2026 by charliermarsh via review / security review #52087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant