Skip to content

Share incompatibility arena chunks across solver states - #90

Draft
charliermarsh wants to merge 3 commits into
mainfrom
charlie/shared-incompatibility-arena-pr
Draft

charliermarsh wants to merge 3 commits into
mainfrom
charlie/shared-incompatibility-arena-pr

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

When we clone a solver state, we copy every incompatibility and its version sets. Move the mutable contradiction cache into PartialSolution so we can share incompatibilities across forks.

Store immutable records in shared chunks of 256. Cloning an arena copies its chunk handles; appending to a shared partial chunk copies at most 255 existing records. Completed chunks remain shared, and propagation does not copy them. Each fork keeps its own assignments and contradiction cache. We also preserve the original self-dependency ranges for diagnostics.

In a controlled experiment against published PubGrub 0.6.1, this reduced peak RSS by 11.3% on a large project's fresh resolve and 9.0% on its upgrade. Both variants used the same uv source with deferred forks and incremental result merging. These are medians of three runs per variant, measured with the earlier 0.6.1 prototype.

This is an alternative to checkpoint/rewind in #91.

@codspeed

codspeed Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing charlie/shared-incompatibility-arena-pr (3a849ba) with main (c930bd7)

Open in CodSpeed

@charliermarsh
charliermarsh force-pushed the charlie/shared-incompatibility-arena-pr branch from 307ac04 to 3a849ba Compare October 21, 2026 14:15
konsti-openai pushed a commit 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 has not been deployed

No deployments
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