feature: add new "lazy-wheel" config option#8815
Merged
radoering merged 9 commits intopython-poetry:masterfrom Jan 20, 2024
Merged
feature: add new "lazy-wheel" config option#8815radoering merged 9 commits intopython-poetry:masterfrom
radoering merged 9 commits intopython-poetry:masterfrom
Conversation
f474a8a to
83706ba
Compare
This was referenced Dec 21, 2023
Closed
Secrus
reviewed
Dec 22, 2023
|
Deploy preview for website ready! Built with commit 48e0b57. |
trag1c
suggested changes
Jan 7, 2024
trag1c
approved these changes
Jan 10, 2024
7e35c2b to
be15429
Compare
Secrus
reviewed
Jan 20, 2024
If active and a server supports range requests, we do not have to download entire wheels to fetch metadata but can just download the METADATA file from the remote wheel with a couple of range requests.
… `from_wheel_metadata` to `from_metadata`
…zeLazyResource to LazyRemoteFile
…e to LazyFileOverHTTP
Secrus
approved these changes
Jan 20, 2024
1 task
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull Request Check List
With #5509, this is only relevant for indexes that do not support PEP 658 - thus, probably for most indexes except for PyPI - or old wheels without PEP 658 metadata.
This PR adds a config option
solver.lazy-wheel. If active and a server supports HTTP range requests, we do not have to download entire wheels to fetch metadata but can just download the METADATA file from the remote wheels with a couple of range requests. Especially with slow network connections this setting can speed up dependency resolution significantly. (If the cache has already been filled or the server does not support HTTP range requests, this setting makes no difference.)This PR is based on pypa/pip#12208, which I learned about at PackagingCon, so all credits to the authors of this pip PR. 👏 I just had to make the interface fit for Poetry, write some tests and fix some special cases I encountered.
I measured the time of
poetry lockof a largish project, once from a machine with a slow network connection (1.5 MB/s, 40 ms ping) and once from a machine with a fast network connection (95 MB/s, 1 ms ping) to the package index.What
lazy-wheelbasically does is:In order to not try range requests again and again in vain, we keep track if a domain supports range requests at all and especially with negative offsets.
In contrast to the pip PR, we only fetch the
METADATAfile instead of the entire.dist-infodirectory. On the machine with a slow network connection this made a difference of 190 s to 330 s.Further, I added some handling for special cases I encountered while trying range requests with different servers:
1 "Devpi server 1" hosts several indexes including a PyPI mirror. I noticed that range requests were supported for wheels that have been downloaded before, but were not supported for wheels that have not been downloaded before. In other words, a server might supports range requests for some but not all wheels. (This is handled in
HTTPRepository.)The behavior of the different servers can be interpreted as follows:
200 OKinstead of206 Partial content, so you have to inspect theAccept-Rangesheader to determine if it supports range requests or not.-100is handled as0-100.In case you were wondering at the beginning why we should introduce a config option and not just always use range requests if possible, it's probably clearer now: Although various servers were tested and special cases were implemented, it's not unlikely that there are still servers with unexpected behavior that is not handled well.