Skip to content
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

Microsoft.Python.LanguageServer.exe eating all RAM and lots of CPU. #2838

Closed
carlfarrington opened this issue Oct 10, 2018 · 26 comments
Closed
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@carlfarrington
Copy link

carlfarrington commented Oct 10, 2018

Hi.

The Microsoft.Python.LanguageServer.exe is eating up all my memory. It goes all the way to 12 gigs, then drops down to 1gb, then climbs again, constantly.

I had this problem a week or two ago and it was cured by installing an ms-python-insiders.vsix manually. I think it's updated itself and broken again.

I have tried python insiders extension, as well as the 2018.9 that is available from the side bar. I've also tried both with VSCode stable, as well as VSCode insiders.

Also "python.analysis.watchSearchPaths" : "false" has made no difference

My PC is going very slow and it's swapping all over my SSD.

Any ideas?

Environment data

  • VS Code version: 1.29.0-insider
  • Extension version (available under the Extensions sidebar): 2018.9.0 and 2018.10-alpha
  • OS and version: Windows 10 Pro 1803
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.0 x64
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: Django 2.1@master branch

Actual behavior

Computer runs slowly.

Expected behavior

Computer works at a reasonable speed and doesn't get hot and slow and waste away my SSD.

Steps to reproduce:

  1. Open up VSCode and open up a .py file from the django project

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
Microsoft Python Language Server version 0.1.42.0
Initializing for C:\Users\CarlFarrington\envs\hrr\Scripts\python.exe
##########Linting Output - pylint##########
************* Module riskreg.serializers
21,0,convention,C0304:Final newline missing
1,0,convention,C0111:Missing module docstring
5,0,convention,C0111:Missing class docstring
16,0,convention,C0111:Missing class docstring
3,0,warning,W0611:Unused Agent imported from models
3,0,warning,W0611:Unused Owner imported from models
3,0,warning,W0611:Unused Ownergroup imported from models

------------------------------------------------------------------

Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

/C:/Program Files/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:1410  INFO no standard startup: not just one text editor
/C:/Program Files/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:280 [Extension Host] Python Extension: Get language server folder name, , Return Value: "languageServer.0.1.42" (at Logger.logInformation (C:\Users\CarlFarrington\.vscode-insiders\extensions\ms-python.python-2018.9.0\out\client\common\logger.js:35:21))

image

@carlfarrington
Copy link
Author

OK, the Jedi thing was User Error. I forgot to alter it in workspace settings too.

So I have been able to disable the python language server, but it would be nice if I could use it.

@d3r3kk d3r3kk added area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs verification labels Oct 10, 2018
@MikhailArkhipov
Copy link

May be related to
#2613
microsoft/python-language-server#181

@bob-white
Copy link

bob-white commented Oct 16, 2018

I am also seeing this on version 2018.9.0
image

After a bit of work pruning some paths from my workspace I'm able to keep the language server from gobbling up all my available RAM.

The culprits seem to be a bunch of python2.7 compiled extensions that we've got in the tree for supporting some older environments. All these libraries actually exist already compiled for python 3.5, so it might be the fact that they are duplicates that is causing the server to go a bit nuts.

@ghost
Copy link

ghost commented Oct 21, 2018

Having the same issue here on build 1.28.2 64bit on Win10.
microsoft python memleak

@apollo13
Copy link

I also have it eating all the memory and then swapping (roughly 18GB) on linux. Apparently I can reproduce with a checkout of Django and browsing around.

@jakebailey
Copy link
Member

jakebailey commented Oct 22, 2018

This should be fixed via microsoft/python-language-server#280 (reported microsoft/python-language-server#278).

It's not in the stable release channel yet, but you can pull our latest language server daily build by setting "python.analysis.downloadChannel": "daily" in your settings JSON and reloading. Note that this is undocumented and for testing only. There may be other bugs in our daily builds which don't appear in stable. You may need to delete the languageServer directories in the Python extension folder to return to the stable build after trying it out, as the extension will always select the newest downloaded version to start.

@apollo13
Copy link

@jakebailey Oh sorry; I assumed that parts of it shipped out to stable already. My mistake!

@fchevitarese

This comment has been minimized.

@Ronkiro

This comment has been minimized.

@brettcannon
Copy link
Member

At this point please do not leave a comment about having the same issue unless you have tried the following and you are still having issues:

  1. Set "python.analysis.downloadChannel": "daily"
  2. Quit VS Code
  3. Deleted any languageServer directories in the extension
  4. Restarted VS Code and had it download and extract a new copy of the language server

At this point we need validation from someone that the believed fix available in the daily build actually fixed this specific problem, not confirmation that the stable version is still buggy.

@jakebailey
Copy link
Member

The stable build that the extension downloads has been updated to a more recent revision with a fix. At this point, you should be able to restart the editor and see 0.1.48 download and start up and no longer have this memory usage issue.

@carlfarrington
Copy link
Author

carlfarrington commented Oct 23, 2018

Hi Jake, Brett. I have disabled jedi again, and I did get an update today, and I have confirmed that the language server is now 0.1.48, and, while it takes much longer, I'm afriaid the CPU is running 1 thread at max capacity i.e. ~16% CPU usage on a 4 core 8 thread machine, or 100% when cpu affinity set to a single core, and memory usage, very gradually, creeps up to ~100%.

I will link to a youtube video in a moment. Put the kettle on, it doesn't get interesting ( ;-) ) until 7 minutes in.

@carlfarrington
Copy link
Author

Turn your speakers off. I didn't realise the windows 10 screen recorder was capturing my microphone :)

https://www.youtube.com/watch?v=0rIJxcpQl7Y&feature=youtu.be

@jakebailey
Copy link
Member

@carlfarrington Looking at your video, you seem to have your project code actually inside of your virtualenv directory, as opposed to storing it in its own subdirectory (for example, when I start a project in, say, my_project, I run virtualenv venv from inside that directory, such that my Python environment ends up in my_project/venv, then I activate it/select it in VS Code). You may want to try moving your project code outside of the Python environment's directory and see if the issue persists.

If it's still happening, add "python.analysis.logLevel": "Trace" to your settings to make the language server output more information to the Output pane. It might be the case that some analysis is repeating over and over again, which should be more easy to see in that view.

Since your issue has more to do with the language server than the extension itself, I'd appreciate it if you opened an issue over at Microsoft/python-language-server with your info (including new stuff), instead of using this issue tracker. 🙂

@carlfarrington
Copy link
Author

carlfarrington commented Oct 23, 2018

Thanks Jake. I probably haven't done my virtual-env stuff properly, it was the first time I'd done it and the concept was new to me.

It's a bit late here now and this is a bad week but if I still have trouble I will do as you've said over at the other issue tracker.

Thanks for your help.

@apollo13
Copy link

I have updated to the latest stable release and opened a git clone of Django. The good news is that memory usage stays constant now. The bad news is that one CPU is at 100% since minutes. Is analysis still ongoing? This is what the trace said so far:

<long list of all django files>
Waiting for parsing to complete.
Parsing complete. Waiting for analysis entries to enqueue.
Enqueue complete. Waiting for analysis to complete.
Received new analysis for file:///home/florian/sources/django.git/setup.py
Analysis complete for file:///home/florian/sources/django.git/setup.py at version -1

@apollo13
Copy link

Minutes later still the same things, now with jumps in memory. Language Server uses around 6 GB. I've disabled language server again. It should be easy to reproduce with a checkout of https://github.com/django/django/

@fchevitarese
Copy link

At this point please do not leave a comment about having the same issue unless you have tried the following and you are still having issues:

  1. Set "python.analysis.downloadChannel": "daily"
  2. Quit VS Code
  3. Deleted any languageServer directories in the extension
  4. Restarted VS Code and had it download and extract a new copy of the language server

At this point we need validation from someone that the believed fix available in the daily build actually fixed this specific problem, not confirmation that the stable version is still buggy.

Well, i've done all the steps with some observations:
1 - The first step tells me that this config is unknow.
2 - I've removed all directories from languageServer.
3 - Restarted VSCode.

Than VSCode downloaded the last version of the languageServer.
The problem keeps going. I dont know why and how to get the latest version of languageServer because the config is not recognized by Vscode

selecao_011

After some time, it consumes all the memory.

@brettcannon
Copy link
Member

@fchevitarese the config is recognized, it just isn't defined by default as it's considered a hidden, private configuration we only tell people about when we ask for help in debugging.

@fchevitarese
Copy link

@fchevitarese the config is recognized, it just isn't defined by default as it's considered a hidden, private configuration we only tell people about when we ask for help in debugging.

Well, i've done all steps, and still got the same problem.

@brettcannon
Copy link
Member

As @jakebailey said in his comment, at this point the best way to help is to open/reply to the appropriate issue over at https://github.com/microsoft/python-language-server with log level turned up to help diagnose where things are going wrong.

@jarshwah
Copy link

I've followed debugging tips for getting the latest language server:

Language Server Version: 0.1.62

I'm still seeing 1 CPU pegged at 100%, and RAM constantly climbing. After looking at AnalysisLog.txt in the language server directory of the extension, I'm seeing thousands of lines like this:

[00:01:43.3652700] ImportNotFound: k3.orders.tests.k3
[00:01:43.3652910] ImportNotFound: k3.orders.tests.tests
[00:01:43.3674490] ImportNotFound: images.tests.mock
[00:01:43.3675020] ImportNotFound: images.tests.django
[00:01:43.3675220] ImportNotFound: images.tests.images
[00:01:43.3675490] ImportNotFound: images.tests.tests
[00:01:43.3680130] ImportNotFound: ge.tests.copy
[00:01:43.3680260] ImportNotFound: ge.tests.django
[00:01:43.3680440] ImportNotFound: ge.tests.ge
[00:01:43.3680620] ImportNotFound: ge.tests.tests
[00:01:43.3683680] ImportNotFound: k3.products.tests.models.datetime
[00:01:43.3684220] ImportNotFound: k3.products.tests.models.django
[00:01:43.3684660] ImportNotFound: k3.products.tests.models.django

I thought this might have something to do with the root paths (because the final component of the import path above was missing in previous language server version logs - (after) ge.tests.ge -> ge.tests (before)).

My project is workspace/kogan3/ with my workspace/kogan3/apps directory added as a top level import by inserting it into sys.path from manage.py. I tell vscode-python about this like so:

"python.autoComplete.extraPaths": [
        "${workspaceRoot}/kogan3/apps/",
        "${workspaceRoot}/kogan3/",
    ],

I should note this is a python2.7 project, and I'm guessing the weird imports are due to absolute import differences, but I'm just guessing at this stage.

Since AnalysisLog was constantly being written to, I figured this might be the cause for my 100% cpu, but I didn't know whether it was the use of the language server from the extension, or the server itself. Happy to repost over on the language server repo.

In fact, my cpu usage has just dropped down to a reasonable level (near 0 while I'm not actively using the editor) after the update to the latest server. It was pegged at 100% for over 10 minutes though.

@mmospanenko
Copy link

mmospanenko commented Nov 22, 2018

On my MacBook Pro 2017, this process uses more than 100% CPU constantly.
I run Python 2.7 inside Docker container and use Virtualenv (in host os) for VSCode.

Also, I use python.autoComplete.extraPaths property (Django apps inside /apps/ directory) and I use cached property for sharing FS with Docker.

And yes - I removed directory ~/.vscode/extensions/ms-python.python-2018.10.1/languageServer.0.1.60/ and VSCode downloaded new daily version.

image

Is it possible to deactivate this process (turn off IntelliSense and others "cool" features)?

@brettcannon
Copy link
Member

@mmospanenko Set "python.jediEnabled": true and then restart VS Code. That will put you back to using Jedi.

@brettcannon
Copy link
Member

I have opened a sibling issue on the language server at microsoft/python-language-server#431 . Please leave details there going forward (I'm going to lock this issue to help make sure details make it to the language server team and don't get lost over here).

If people run into other CPU/memory issues, please open them over at https://github.com/Microsoft/python-language-server and then reference this issue by pasting in Microsoft/vscode-python#2838 as the first line of the issue.

@microsoft microsoft locked and limited conversation to collaborators Nov 22, 2018
@brettcannon brettcannon added the bug Issue identified by VS Code Team member as probable bug label Jun 3, 2019
@luabud
Copy link
Member

luabud commented Sep 11, 2019

Closing in favour of microsoft/python-language-server#431.

@luabud luabud closed this as completed Sep 11, 2019
@ghost ghost removed the needs upstream fix label Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests