Select single-index prefetch candidates in one pass - #334
Closed
charliermarsh wants to merge 1 commit into
Closed
Conversation
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Batch prefetch currently selects up to 50 candidates by repeatedly invoking the candidate selector and intersecting a singleton complement into the remaining range. On backtracking-heavy packages, those repeated traversals and increasingly fragmented ranges add meaningful resolver CPU before metadata requests are issued.
This adds a lazy, single-index candidate iterator that visits the version map once, preserves highest/lowest ordering, prerelease and cutoff handling, compatible/incompatible candidates, and the compatible-to-in-order transition, then enqueues each eligible wheel immediately. Multi-index resolution and an existing in-order phase keep the current selector path. Unlike the earlier eager prototype in astral-sh#20487, this does not collect a batch before the first request, preserving cold-cache overlap and early-abandon behavior.
Performance
Measured against current
main(1535a6767) with--profile profilingbinaries and a prewarmed PyPI cache. All runs were offlineuv pip compile, Python 3.12, fixedUV_EXCLUDE_NEWER=2024-08-08T00:00:00Z,UV_CONCURRENT_CACHE_READS=4, CPUs 8-15, 20 warmups, and 80 alternating pairs. Every generated requirements file matched byte-for-byte. Intervals are paired-bootstrap 95% confidence intervals.The meaningful win is the backtracking-heavy boto3 case; the other CPU intervals include no change. A focused selector-equivalence matrix covers highest/lowest, prerelease modes including an all-prerelease
IfNecessarymap, segmented ranges, incompatible and cutoff entries, and the compatible-to-in-order transition. All 66 resolver unit tests, 11 focused Packse/backtracking integration tests, strict clippy, formatting, and diff checks pass; the Python-3.8-only prefetch integration case was unavailable in this environment.