Select resolver prefetch candidates in one pass - #20487
Closed
charliermarsh wants to merge 1 commit into
Closed
Conversation
charliermarsh
temporarily deployed
to
automations
July 16, 2026 21:45 — with
GitHub Actions
Inactive
uv test inventory changesThis PR changes the tests when compared with the
|
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 full 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 the metadata requests are even issued.
This adds a batched selector that visits each version map once, preserves highest/lowest ordering, prerelease and cutoff handling, index strategy and duplicate-index precedence, compatible/incompatible candidates, and the compatible-to-in-order phase transition, then enqueues the same eligible wheel metadata requests. This is distinct from #20465: it does not suppress later prefetch opportunities; it only makes selection within each batch linear.
This is deliberately a draft because collecting a batch before enqueueing its first request can trade away some cold-network overlap. The target benchmark is warm/offline.
Performance
Measured directly against latest
main(bedddb53a) with profiling binaries 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.boto3 is the meaningful win, which matches its roughly 94 large prefetch batches. A focused selector-equivalence matrix covers highest/lowest, all three index strategies, prerelease modes, duplicate versions, compatible/incompatible/cutoff entries, and segmented ranges; it also matched 300,000 randomized cases against repeated selection. The full resolver unit suite (65 tests), strict clippy including tests, formatting, and diff checks pass.