uv: uv downloads are slow on fallback to streamed wheel downloads
Hello,
I’m trying the latest version of uv and I see that you added progress bars. 😃
uv is downloading tensorflow at less than 1 MB/s. when tensorflow is the last remaining package, the speed starts increasing to a more reasonable speed of double digits MB/s. for reference, I have pip downloading at 400+ MB/s for tensorflow/torch (with one patch pending to merge to fix the progress bar 😄 ).
There is a chance it’s not the progress bars themselves, but the addition of progress bars made the issue visible.
Looking at the output:
- I see that uv is doing 50 concurrent downloads in parallel. It’s too many to the point it’s counterproductive for performance. It will also cause issues with proxy/firewall and internal pypi servers that can’t take the load and drop connections. Can I suggest to reduce that to 20 at most? It will be faster and more stable. As a nice side effect, it will allow the output to fit in the screen (default console is around 80 x 24 lines). The default output of 50 lines never fits in the screen ^^
I do note that both the resolver and the download seem to use the same concurrency settings (50 by default). It might make sense for the settings to be separate, the resolver is doing small requests and is more affected by latency, the downloading is more about bandwidth.
-
Can you review what is the chunk size for reading from network? writing to disk?
-
The screen flashes a lot, like it’s trying to rerender all the progress bars every few kB. Do you have some sort of limits on how often the bar should be refreshed?
-
Do you have some throttling or priority where it tries to download packages at the top of the list first by any chance? The list is sorted with bigger packages to the bottom.
DEBUG RUN the download time is part of the “prepare 394 packages”
# export UV_CONCURRENT_DOWNLOADS=50 && rm -rf ./deleteme && time uv pip install --no-cache --prefix ./deleteme mypackage
...
Resolved 394 packages in 20.82s
Prepared 394 packages in 30.54s
Installed 394 packages in 4.64s
...
real 1m3.689s
user 0m38.068s
sys 0m53.199s
# export UV_CONCURRENT_DOWNLOADS=32 && rm -rf ./deleteme && time uv pip install --no-cache --prefix ./deleteme mypackage
...
Resolved 394 packages in 20.92s
Prepared 394 packages in 28.69s
Installed 394 packages in 5.03s
...
real 1m2.636s
user 0m36.721s
sys 0m51.546s
# export UV_CONCURRENT_DOWNLOADS=16 && rm -rf ./deleteme && time uv pip install --no-cache --prefix ./deleteme mypackage
...
Resolved 394 packages in 22.40s
Prepared 394 packages in 27.94s
Installed 394 packages in 4.84s
...
real 1m2.172s
user 0m36.054s
sys 0m49.306s
#export UV_CONCURRENT_DOWNLOADS=8 && rm -rf ./deleteme && time uv pip install --no-cache --prefix ./deleteme mypackage
...
Resolved 394 packages in 26.51s
Prepared 394 packages in 28.72s
Installed 394 packages in 4.59s
...
real 1m6.988s
user 0m36.651s
sys 0m50.748s
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 46 (26 by maintainers)
In case others missed it, @charliermarsh already made this change https://github.com/astral-sh/uv/pull/7226 and a new uv was released https://github.com/astral-sh/uv/releases/tag/0.4.8
apologies if the tone came wrong, I am not a native speaker :sorry:
note that we are testing with
--no-cache, that might prevent the resolution phase from caching the package, for the prepare phase.I’ve seen reported cases, on the pip side, where packages are multiple GB big and they are the cause of backtracking, so you should probably avoid prefetching whole wheels.
Unless there’s some way to reliably detect what size it is before downloading, as on the other size end I do notice with some wheels the the majority of the size is the metadata, so if it’s only small, like 50 KiB or less, you could probably make an exception there.
This is a log I generated in https://github.com/astral-sh/uv/issues/6104, Not sure if that is usefull
I see this
Thanks! I’ll respond with the verbose logs when I get a chance today
Candidly I think your diagnosis is not quite correct. We already know the versions when we request those URLs. So whatever you’re seeing is something else. I can help if you share the
--verboselogs, but otherwise I can only speculate, sorry.quick update on this ticket:
we have no clue why and not closer to a resolution or an understanding of the root cause. the only reason uv is not extremely slow due this bug, is because it’s downloading 50 packages in parallel by default.
packages are downloaded a first time to identify dependencies then a second time to do the installation. the first download is a streamlit download which stops when it finds dependency information and does not cache. the METADATA file is always at the end of the wheel so it’s counter productive. this issue was fixed the week after this ticket was opened. the fix was just reverted yesterday so it’s back to square one https://github.com/astral-sh/uv/pull/6470
Ok so for one, I believe we are downloading the wheel twice if your server doesn’t support range requests, because we stream the wheel and stop as soon as we see a
METADATAfile, which is sometimes an optimization, but means we don’t fully download (and cache) the wheel: https://github.com/astral-sh/uv/issues/5088.(As an aside, I feel like your tone assumes we will disagree with you. I’m not here to tell you that you’re wrong, and that uv is perfect! I’m just trying to get more information so we can diagnose the problem.)