nice-pillow-26422
05/16/2024, 12:30 PM2.21.0a1
).
pip_version = "24.0"
I'm seeing slow export
and generate-lockfile
times (well, slow relative to pip
anyway. I know that a number of related questions have been asked, and I promise I've been reading them in an effort to debug. Here's what I've got so far.
1. I assume that I need to re-run generate-lockfiles
and then export
when I change my root universal requirements.txt? Is that correct?
2. I'm using Lightning Studios as my Linux dev environment, and although I have a hunch they are doing some stuff that slows down the hard drives a bit (in an effort to preseve the contents of the drives), it generally is plenty fast for my needs when using previous pip-based workflows.
It takes my system 246s to generate-lockfiles
(pants --keep-sandboxes=always --pex-verbosity=9 -ldebug generate-lockfiles --resolve=python-default
)
It takes 231s to `export`(pants -ldebug --pex-verbosity=9 export --resolve=python-default
)
I wanted to first debug the slow generate-lockfiles
. This seems equivalent to pip install -r requirements.txt
after having cached everything.
Here is a gist with my requirements.txt and a filtered pip-log from my generate-lockfiles
. (I preserved the pip log file and filtered out all of the noisy "Skipping link" and "Found link" lines)
https://gist.github.com/Taytay/492c12eaedce6c7999e0028fb6a9a50a
From that log, it looks like It is spending the first 3 minutes or so just checking pypi (even though everything is cached locally), and "pretending" to download cached files.
Then, for about the next 15s 11:10:57,542
to 11:13,909
it's copying wheel files into a temp folder, some of which are quite big (2024-05-16T11:11:11,057 Saved ./.tmp/tmpjnt15mw0/system.conda.miniconda3.envs.cloudspace.bin.python3.10/nvidia_cublas_cu12-12.1.3.1-py3-none-manylinux1_x86_64.whl
Then, it wraps up pretty quick.
So my conclusion is: Even if the modules are already downloaded, it's going to take pex and pip a few minutes to copy the cached whl files around.
Qs continued:
3: Can I avoid pip and make this faster?
4: I'm hoping there are flags I can pass to this to force pip to stop checking the remote so often, and just trust its cache? I feel like I'm missing something (because it's hard for me to imagine others are waiting 500s after updating their requirements.txt).
5: I know pants is good at generating hermetic environments, and a lot of thought has been put into caching, but is there some way to speed this pex caching up further?
6: Do ramdisks help here to speed up the tmp folders?
7: How hard would it be to switch to uv ?https://astral.sh/blog/uv? 😁
Any help (on any Qs) would be super helpful! Thank you!curved-television-6568
05/16/2024, 12:58 PMuv
, there's this ticket: https://github.com/pantsbuild/pants/issues/20679
Secondly, pants does cache a lot, but when it comes to third party requirements, we're kind of out of luck, as it would be bad if there's a new version available that we didn't pick, because we had an older one in the cache.. granted, when merely adding new requirements, it would be nice to be able to say that we don't care to upgrade, only fill in what's missing, but I don't think there's an option for that.
Sometimes, long resolve times is due to having very open constraints leading to pip going through a lot of version permutations to solve the dependency graph. If you're able, narrowing down both the Python interpreter constraint as well as potentially time consuming libraries are remedies that can speed up lockfile generation.
Speeding up the export
will probably not be easy (using ramdisks could speed up the i/o, sure, but if that's more than marginal... you'd have to try I suppose 😉 🤷) (and not using pip
is also no small feat to change..)
I have some vague memories that there may be some optimizations available to tell pip
to not download entire libraries but only the metadata when doing the resolving.. not sure if this is enabled by default already or not if so.better-van-82973
05/16/2024, 1:01 PMpip install
is that pip install
will install the packages specific to your OS + architecture, but lockfiles are cross-platform and will contain links to packages for other OS/platforms as well. That’s mentioned on a comment in the linked issue here: https://github.com/pantsbuild/pants/issues/20679#issuecomment-2002692556nice-pillow-26422
05/16/2024, 3:10 PMbetter-van-82973
05/16/2024, 5:19 PMgentle-flower-25372
05/16/2024, 5:43 PMnice-pillow-26422
05/16/2024, 6:04 PMgentle-flower-25372
05/16/2024, 6:05 PMnice-pillow-26422
05/16/2024, 6:06 PMgentle-flower-25372
05/16/2024, 6:07 PMhappy-kitchen-89482
05/16/2024, 9:40 PMhappy-kitchen-89482
05/16/2024, 9:41 PMnice-pillow-26422
05/16/2024, 9:47 PMhappy-kitchen-89482
05/16/2024, 10:00 PMhappy-kitchen-89482
05/16/2024, 10:01 PMnice-pillow-26422
05/17/2024, 11:43 AMcurved-television-6568
05/17/2024, 12:24 PMhappy-kitchen-89482
05/17/2024, 10:10 PM