-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locking is slow (and performs redundant downloads) #2284
Comments
@colllin Have you checked to see whether pip commands that contact the server - like I see similar behavior, but it's kind of a known issue and network dependent. For some reason, access to pypi.org from my work network is incredibly slow but it is normally fast from my home network. I think locking does a lot of pip transactions under the hood, so slow access to the server slows the operation a lot. EDIT: It may also be that you just have a lot of sub-dependencies to resolve - how big is the environment once created (e.g. how many top-level packages in your pipfile, and how many packages returned by |
Thank you for the thoughtful response.
Forgive me for my lack of domain knowledge: Does it really need to pip search? Didn't it just install everything? Doesn't it just need to write down what is already installed? Or... since it ensures the existence of the lock file anyway, could it do this as it installs the packages, or before? I'm guessing... pipenv uses pip under the hood? so the installation process is a black box, and it can't know the dependency graph of what was/will be installed without doing EDIT: There is 1 top-level package, and ~65 packages returned by |
I'm not a contributor to the project and at the moment I don't know all the specifics, but my understanding is that the locking phase is where all of the dependencies get resolved and pinned. So if you have one top-level package with ~65 dependencies, it's during the locking phase that all of the dependencies of that first package are (recursively) discovered, and then the dependency tree is used to resolve which packages need to be installed and (probably) in what rough order they should be installed in. Not as sure about the last part. If you pip install from a Pipfile without a lockfile present, you'll notice that it does the locking phase before installing the packages into the venv. Similarly if you have a lockfile but it's out of date. I suspect having a lockfile and installing using the Whether or not pipenv uses pip under the hood - I think it does - it still needs to get the information from the pypi server(s) about package dependencies and the like, so my question about pip search was more a proxy for how fast or slow your path to the pypi server is than a direct implication about the mechanism by which pipenv does its thing. An interesting experiment might be to compare the time required for locking the dependency tree in pipenv, and installing requirements into a new venv using |
Have we established somewhere that there are redundant downloads happening btw? I suspect that is the case but proving it would be really helpful FYI comparing
This turns out to be pretty quick because pip doesn't really care if the dependencies of package 1 conflicted with the dependencies of package 3, it just installed the ones in package 3 last so that's what you get. Pipenv follows a different process -- we compute a resolution graph that attempts to satisfy all of the dependencies you specify, before we build your environment. That means we have to start downloading, comparing, and often times even building packages to determine what your environment should ultimately look like, all before we've even begun the actual process of installing it (there are a lot of blog posts on why this is the case in python so I won't go into it more here). Each step of that resolution process is made more computationally expensive by requiring hashes, which is a best practice. We hash incoming packages after we receive them, then we compare them to the hashes that PyPI told us we should expect, and we store those hashes in the lockfile so that in the future, people who want to build an identical environment can do so with the contractual guarantee that the packages they build from are the same ones you originally used. Pip search is a poor benchmark for any of this, in fact any of pip's tooling is a poor benchmark for doing this work -- we use pip for each piece of it, but putting it together in concert and across many dependencies to form and manage environments and graphs is where the value of pipenv is added. One point of clarification -- once you resolve the full dependency graph, installation order shouldn't matter anymore. Under the hood we actually pass As a small side-note, pip search is currently the only piece of pip's tooling that relies on the now deprecated XMLRPC interface, which is uncacheable and very slow. It will always be slower than any other operation. |
Locking numpy (and nothing else) takes 220 s on my machine (see below). Most of the time seems to be spent downloading more than 200MB of data, which is quite puzzling given that the whole numpy source has 4 MB. Though clearly even if that was instant, there's still 25 s of actual processing, and even that seems excessive to calculate a few hashes. Subsequent locking, even after deleting Pipenv.lock, takes 5 s.
|
Numpy should be substantially faster now (I have been using your example as a test case in fact!). As of my most recent test, I had it at ~30s on a cold cache on a vm. Can you confirm any improvements with the latest release? |
It has improved substantially for me as well. I'm now sitting on a very fast connection, and got as low as 14 s, but that was when the downloading went at 30 MB/s. What is being downloaded besides a single copy of the source code of numpy? |
I think we’re downloading redundant wheels (not sure). We’re already evaluating the situation. |
I changed my Pipfile.lock drastically by uninstalling a fe changes and now deploying that on a different machine is freezing. Any particular fix for this? |
It’s not recommended that you manually edit your lockfile. Without more information it’s not possible to help. Please open a separate issue. |
If you want to benchmark the performance of pipenv lock, you should try to add pytmx to your dependencies... |
It doesn’t take one hour for me
|
Also PyTMX is less than 20kb on PyPI, and only has one dependency to six (which is super small), so networking shouldn’t be an issue. There is likely something else going on in your environment. |
you're right it's smaller than I thought it does not depend explicitly on pygame and such, not sure why it was taking so long then ! |
@techalchemy I didn't edit the file manually. I uninstalled a lot of dependencies using |
I am not interested in spending energy on this discussion with random shots in the dark. Please provide a reproducible test case. |
Here's what I hope is a reproducible test case Attempting to do Will give up in a bit and rerun with |
Sadly due to several issues with Pipfile.lock, it seems to either hang or take forever as seen here pypa/pipenv#2284 here pypa/pipenv#1816 and here pypa/pipenv#356 making it extremely unusuable For that reason instead of switching to an alternative solution, I have decided to pin all the dependencies so that this project doesn't start failing with breaking changes in the future I will probably come back here and generate lock and use semver minors/patches only once pipenv have matured enough, good luck to its developers!
Sadly due to several issues with Pipfile.lock, it seems to either hang or take forever as seen here pypa/pipenv#2284 here pypa/pipenv#1816 and here pypa/pipenv#356 making it extremely unusuable For that reason instead of switching to an alternative solution, I have decided to pin all the dependencies so that this project doesn't start failing with breaking changes in the future I will probably come back here and generate lock and use semver minors/patches only once pipenv have matured enough, good luck to its developers!
Sadly due to several issues with Pipfile.lock, it seems to either hang or take forever as seen here pypa/pipenv#2284 here pypa/pipenv#1816 and here pypa/pipenv#356 making it extremely unusuable For that reason instead of switching to an alternative solution, I have decided to pin all the dependencies so that this project doesn't start failing with breaking changes in the future I will probably come back here and generate lock and use semver minors/patches only once pipenv have matured enough, good luck to its developers!
I noticed that So I sniffed the requests made to For example, same version My setup:
|
are additional Pipfiles helpful for debugging here? |
Most likely @AlJohri, also any info about running processes / locks / io would help |
Finally finished after about 6 - 7 minutes. Pretty new to Python and Pipenv, so a little help about where to find the necessary files for debugging would be great! :) |
this is pretty bad to the point I am afraid to install new python libs or upgrade existing ones. |
After watching one of the talks from the creator, I decided to use |
Agreed. I started looking into poetry and even though of adding another user to my OS per project instead of using pipenv again. If it's not working fine for casual use cases with the default settings it's broken imho. |
Sure, it is annoying waiting for a lock when having to do multiple installs mid dev session, but this can be managed. The important thing is that a lock file is generated before pushing local changes to repo. I make judicious use of the |
Thanks for the project. But, |
|
@Jamim , thanks for suggesting Poetry. Personally, for some reason I did not come across it. After reading its readme it seems worth trying. It lists some benefits over Pipenv as well (https://github.com/sdispater/poetry/#what-about-pipenv). Having said that, the project being dead is a gross overstatement, and if I were in pipenv authors' shoes, I would find it disrespectful. The author replied in the issues section just yesterday. It's just this locking issue being overlooked, probably because it is hard to fix. |
For the record, Poetry suffers from performance issues as well: |
I have the same problem in all of my projects. Minimal working exampledjbrown@DESKTOP-65P6D75:~$ mkdir test
djbrown@DESKTOP-65P6D75:~$ cd test
djbrown@DESKTOP-65P6D75:~/test$ pipenv install --dev pylint --verbose
Creating a virtualenv for this project…
Pipfile: /home/djbrown/test/Pipfile
Using /usr/bin/python3 (3.6.9) to create virtualenv…
⠸ Creating virtual environment...Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/djbrown/.local/share/virtualenvs/test-PW-auWy_/bin/python3
Also creating executable in /home/djbrown/.local/share/virtualenvs/test-PW-auWy_/bin/python
Installing setuptools, pip, wheel...done.
✔ Successfully created virtual environment!
Virtualenv location: /home/djbrown/.local/share/virtualenvs/test-PW-auWy_
Creating a Pipfile for this project…
Installing pylint…
⠋ Installing...Installing 'pylint'
$ ['/home/djbrown/.local/share/virtualenvs/test-PW-auWy_/bin/pip', 'install', '--verbose', '--upgrade', 'pylint', '-i', 'https://pypi.org/simple']
Adding pylint to Pipfile's [dev-packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
⠇ Locking... |
I heard about pipenv alot and tried it today, |
I want to draw attention to this excellent comment from #1914 on the same topic #1914 (comment) which suggests that downloading and executing each dependency is not necessary any longer. I wonder if any devs could comment on the feasibility of this approach. |
I've noticed that it's actually faster to remove the environment and recreate it from scratch to update the lockfile. |
I really like
Wish the developers best of luck... |
@ravexina thanks for the suggestion, I'll try for sure |
I would just like to note that this was never a problem when I was in a major city with awesome internet (it took like 3 seconds) and now I'm in a rural area and locking the EXACTLY SAME PROJECT takes at least 4 minutes. |
I tried installing
Tried that as metioned, Its still wasting time.. Please guide me. |
Try out py-poetry - more features and faster locking. |
In reply to the last comment, poetry might be faster, but still depressingly slow. How much time do you think it takes to install a dummy package like https://pypi.org/project/insecure-package/ ? Here is the answer:
(Disclaimer: installation time depends on the size of your project, but I wouldn't call ours big). The results above are obtained with
which has "improved build speed" as per these issues:
So don't expect Poetry to solve all of your problems. Package management in Python is still a PITA, at least in comparison with NodeJS / npm / yarn. |
But it's still slower, and my pipenv doesnt ever stop locking, unlike others :( |
My comment from another related pipenv issue:
This was generated on a poor vpn network connection. most of the time is spent in SSL.py read() |
I wonder which version of Pipenv are you using, generating hashes no longer downloads the artifacts, as long as SHA256 hash is included in the URL(True for most packages on pypi.org). So what package index are you using? |
@frostming |
It's sad to see all the bashing on this issue, constructive ideas make progress! |
I don't believe this exact issue is still relevant to latest versions of pipenv, such as the one released yesterday |
Just to understand, was this issue resolved by another PR or simply closed? |
I believe it was closed because there were many conflicting reports that could have been separate issues. Some of the issues may be resolved by time of the latest release, but others may still be relevant - in which case we should open new issues to track those issues. |
@JoshuaPoddoku This issue it was determined that the current design uses hashes from the API and so there should not be redundant downloads in performing locking, much has changed since the original report was opened. When looking for PRs that seemed relevant I performed this search: https://github.com/pypa/pipenv/pulls?q=is%3Apr+is%3Amerged+hash However I don't have a link to an exact PR, but frostming above had said:
Basically @meichthys has it correct that any thing still relevant to the latest version of |
Is this an issue with my installation? It happens on all of my machines... Is there anything I/we can do to speed it up?
I install one package and the locking seems to take minutes.
$ python -m pipenv.help output
Pipenv version:
'2018.05.18'
Pipenv location:
'/Users/colllin/miniconda3/lib/python3.6/site-packages/pipenv'
Python location:
'/Users/colllin/miniconda3/bin/python'
Other Python installations in
PATH
:2.7
:/usr/bin/python2.7
2.7
:/usr/bin/python2.7
3.6
:/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
3.6
:/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
3.6
:/Users/colllin/miniconda3/bin/python3.6
3.6
:/Users/colllin/.pyenv/shims/python3.6
3.6
:/usr/local/bin/python3.6
3.6.3
:/Users/colllin/miniconda3/bin/python
3.6.3
:/Users/colllin/.pyenv/shims/python
2.7.10
:/usr/bin/python
3.6.4
:/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
3.6.3
:/Users/colllin/miniconda3/bin/python3
3.6.4
:/Users/colllin/.pyenv/shims/python3
3.6.4
:/usr/local/bin/python3
PEP 508 Information:
System environment variables:
TERM_PROGRAM
NVM_CD_FLAGS
TERM
SHELL
TMPDIR
Apple_PubSub_Socket_Render
TERM_PROGRAM_VERSION
TERM_SESSION_ID
NVM_DIR
USER
SSH_AUTH_SOCK
PYENV_VIRTUALENV_INIT
PATH
PWD
LANG
XPC_FLAGS
PS1
XPC_SERVICE_NAME
PYENV_SHELL
HOME
SHLVL
DRAM_ROOT
LOGNAME
NVM_BIN
SECURITYSESSIONID
_
__CF_USER_TEXT_ENCODING
PYTHONDONTWRITEBYTECODE
PIP_PYTHON_PATH
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/colllin/miniconda3/bin:/Users/colllin/.pyenv/plugins/pyenv-virtualenv/shims:/Users/colllin/.pyenv/shims:/Users/colllin/.pyenv/bin:/Users/colllin/.nvm/versions/node/v8.1.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
SHELL
:/bin/bash
LANG
:en_US.UTF-8
PWD
:/Users/.../folder
Contents of
Pipfile
('/Users/.../Pipfile'):The text was updated successfully, but these errors were encountered: