-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feature: add new "lazy-wheel" config option #8815
Conversation
f474a8a
to
83706ba
Compare
Deploy preview for website ready! ✅ Preview Built with commit 48e0b57. |
7e35c2b
to
be15429
Compare
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one small nitpick left.
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. |
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 lock
of 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-wheel
basically 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
METADATA
file instead of the entire.dist-info
directory. 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 OK
instead of206 Partial content
, so you have to inspect theAccept-Ranges
header to determine if it supports range requests or not.-100
is 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.