syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.65k stars 4.89k forks source link

pyvenv-workon is extremely slow #13264

Closed synic closed 3 years ago

synic commented 4 years ago

Description :octocat:

pyvenv-workon takes over 30 seconds to run, even on a brand new virtualenv

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: I timed it. On my brand new Macbook Pro, i7, 32GB of ram, it takes over 30 seconds to activate.

Expected behaviour: :heart: :smile: Activation should be much faster. Especially for a brand new virtualenv with no code in it or packages installed.

System Info :computer:

smile13241324 commented 4 years ago

@synic I cannot reproduce your issue. I have opened below test file in python mode with lsp enabled:

""" Very simple test file """

def say(text: str) -> None:
    """ This prints what you tell it """
    print(text)

def add_eggs(text: str) -> str:
    """ This adds some eggs """
    return " ".join([text, "eggs"])

def do_nothing_eggs(text: str, text2: str, text3: str) -> str:
    """ This adds some eggs """
    return " ".join([text, "eggs"])

say(add_eggs("I love my spam with"))

Then I have pressed ,vw and measured how long displaying helm takes. Then I have chosen the first virtualenv and measured how long applying it took.

Basically both did take less than 3 seconds, which is pretty much ok on my old linux laptop. Can you update all your packages and spacemacs to the latest version and post whether the issue persists? Also it would be interesting if the issue also happens with the latest released emacs version 26.3.

I would especially be interested in the python version you are using. I am on 3.8.1.

My system config is here:

System Info :computer:

brandonwillard commented 4 years ago

Not sure if this is related to your problem, but I disabled spacemacs//python-setup-shell and that improved the start-up time for pyvenv-activate/pyvenv-workon. Naturally, that function does some useful stuff, so that's not exactly a "solution".

From what I could tell, the call to ipython --version can be quite slow (e.g. possibly related to this), and, because spacemacs//python-setup-shell will call that indiscriminately (itself called as advice on pyvenv-activate), simple venv changes can take a while.

Try timing ipython --version (if that's the configured Python executable, of course) at the command line.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!