FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Simplify version ranges during solving by konstin · Pull Request #75 · astral-sh/pubgrub · GitHub

Simplify version ranges during solving - #75

Merged
charliermarsh merged 6 commits into
mainfrom
konsti/simplify-ranges
Jul 8, 2026
Merged

charliermarsh merged 6 commits into
mainfrom
konsti/simplify-ranges

Conversation

konstin commented Jul 4, 2026
edited by charliermarsh
Loading

Copy link
Copy Markdown
Member

Summary

When dependency resolution rejects package versions one at a time, its version sets can accumulate a hole for every rejection. This PR lets callers widen a selected version across gaps between known versions when recording its dependencies, allowing adjacent incompatibilities to merge into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior; widening is opt-in for callers with a complete, fixed version list. Ranges::narrow_versions provides the display-oriented inverse for presenting widened ranges in terms of known versions without hiding unbounded coverage.

codspeed Bot commented Jul 4, 2026
edited
Loading

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing konsti/simplify-ranges (d2a0abd) with main (1856af6)

konstin and others added 4 commits July 5, 2026 08:52
Shrinking an unbounded end to the last contained version hides that the
claim extends past the newest known version, leaving a gap in displayed
proofs that relied on the unbounded coverage.
charliermarsh changed the title Simplify version ranges as we go Simplify version ranges during solving Jul 7, 2026
charliermarsh marked this pull request as ready for review July 7, 2026 21:01
charliermarsh merged commit 070858e into main Jul 8, 2026
11 checks passed
charliermarsh pushed a commit to astral-sh/uv that referenced this pull request Aug 8, 2026
This is a partial port of a technique I am adopting in nab, I have been
following @konstin's lead in
astral-sh/pubgrub#75 and extending the approach
into more places (notatallshaw/nab#357,
notatallshaw/nab#590,
notatallshaw/nab#592,
notatallshaw/nab#604).

This speeds up `uv lock` with `requires-python >= 3.8` over boto3 +
awscli by ~20% wall time, and the largest accumulated range in the run
drops from 287 segments to 2.

`add_unavailable_version` records one singleton incompatibility per
rejected version, so consecutive rejections never coalesce and the
accumulated range grows a hole per version. This widens each singleton
to the gap between its neighbors in the known versions, the same
interval decided-version dependencies use.

The win needs long runs of rejected versions. The main source is a
Python floor below the ecosystem's support boundary: boto3 and awscli
dropped 3.8 in April 2025 and now require >= 3.10, so a 3.8 floor
rejects hundreds of releases in one run, while a 3.10 floor rejects
almost nothing (14 rounds, 2 segments either way) and the change is a
no-op.

The first commit keys the pre-release hint on the requesting requirement
instead of the derived set's bounds: widened bounds land on whatever the
registry lists next, and a pre-release neighbor used to read as a
pre-release marker nobody wrote. Rejection widening makes that routine,
so the fix leads the series. The second commit merges unavailable
versions that are causes of the same derivation, and the third is the
widening itself. The fourth keeps the subsequent-index hint, which was
suppressed whenever the set covered all versions; after widening that
also covers "the index listed versions and none of them worked", which
is the case the hint is for.

The last two commits are #20809, merged in here so the error messages
land as one change. With the widening, uv no longer asks for a version
in a gap it created, so the `no_versions` incompatibility behind "only
the following versions of X are available" is no longer created there,
and steps that cross a gap stop following from the premises next to
them. The fifth commit adds that clause back while the tree is reduced,
on whichever cause rules the package out, or on the step itself when
neither does. The sixth reports the one version a package has as that
version rather than as a range over it, so a rejected `sphinx 7.2.6`
reads `sphinx==7.2.6` and not `sphinx>=7.2.6`. Neither touches the
solver.

<details>
<summary>MRE</summary>

```toml
[project]
name = "mre"
version = "0.1.0"
requires-python = ">=3.8"
dependencies = ["boto3", "awscli"]
```

Max accumulated segments (287 on main, 2 with this PR; `uv.lock`
identical):

```console
$ uv lock --exclude-newer 2026-07-01 -v 2>&1 | grep 'Searching for a compatible version' | awk -F'|' '{print NF}' | sort -n | tail -1
```

Wall (run without `-v`, which prints the accumulated ranges and
dominates the time):

```console
$ hyperfine --warmup 3 --min-runs 20 --prepare 'rm -f uv.lock' 'uv lock --exclude-newer 2026-07-01'
```

</details>
konstin added a commit that referenced this pull request Sep 4, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 11, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 11, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 11, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 13, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 13, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 19, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 19, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 19, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
konstin added a commit that referenced this pull request Sep 19, 2026
When dependency resolution rejects package versions one at a time, its
version sets can accumulate a hole for every rejection. This PR lets
callers widen a selected version across gaps between known versions when
recording its dependencies, allowing adjacent incompatibilities to merge
into contiguous ranges and keeping subsequent range operations small.

The built-in resolver preserves the existing singleton behavior;
widening is opt-in for callers with a complete, fixed version list.
`Ranges::narrow_versions` provides the display-oriented inverse for
presenting widened ranges in terms of known versions without hiding
unbounded coverage.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL