-
Notifications
You must be signed in to change notification settings - Fork 133
python language server uses too much memory #1157
Comments
@lisnb, please provide version of the LS (it is displayed at startup) and the list of libraries/packages you are importing. |
@CMLL - I can see in the log that modules are getting reloaded. This means LS decided that packages changed. LS needs to distinguish libraries from user code. @jakebailey worked in this. Do you happen to have search paths pointing to your code so perhaps LS is confusing file save with package installation? |
Yeah, I do.
It points to the app that I am working on currently. For other reasons that path is also part of my local PYTHONPATH so the apps I'm running can detect inner model requirements, but this is separate from all the library dependencies which live in a |
That's outside of the folder you have open, correct? We currently only treat code inside the workspace (that isn't an interpreter file, for users who put their venvs in the workspace) as user code, so if it's outside, it'll be treated as library code, which I believe will also mean that it will cause a reload when it changes. |
Do you see your log spammed with the "reloading modules" message, or just the two times shown in the screenshot? Are you also setting PYTHONPATH somewhere? As an aside, you can provide paths relative to the workspace root in that option, so you can specify |
Configuration search paths are those given by PYTHONPATH and extraPaths, merged together into a single list (by the python extension before we start). After that logging, we go and classify what's in the workspace and what isn't to see what's user code (and I've been planning on moving those prints somewhere later to get a real picture). |
They are not being spammed constantly, however the background analysis still doesn't complete, or at least the message does not go away. If configuration search path work that way, then I don't really need to set the extraPaths variables, but I've been trying to have the LS start without those 2 paths to discard something there and no luck. I must have a PYTHONPATH set somewhere. Update: |
With your setup (a src directory below the workspace root), you'll have to specify |
Sadly no, is a private project for the company I work for. Removing the configuration search paths doesn't to fix the issue so it leads me to believe it's not a inner workspace code issue, but it could be a virtualenv issue with one of the installed libraries, which is pretty big list. Which makes sense, other projects with different virtualenvs don't seem affected by the same issue, at least in some preliminary testing I did. |
Although that has lead me to another weird situation with the completion. Since I changed the python environment for the workspace the installed modules don't show as available and don't show autocomplete options, as expected. But standard library options and modules in |
Since that's different, I'd appreciate it if you could file that separately with a screenshot. Note that completion works by us providing a big list, which the editor then filters based on the context, so if you're completing on "nothing", then the list will look pretty big. If possible, could you reload and copy out the trace log, and provide a |
Sure thing. Here is a copy of a trace log that stopped at that place I mentioned above along with a list of all the thirdparty libraries present in the virtualenv. I'll create a new issue with the second issue I'm running into. Thanks for all your help, really appreciate it. 😄 |
One extra piece of information. To be thorough I tried analyzing the same workspace with version 0.2.96.0 of the LS, the one not currently in the beta channel, and the analysis doesn't get stuck in that version. Memory usage seems stable in there too. |
I think it has to do with this library https://pypi.org/project/docutils/ Was able to reproduce the freezing of the analysis by creating a virtualenv with only that library installed and putting that as the python interpreter. Also noticed that after the analysis stops, changing the environment doesn't seem to move it along, only changing the environment and reloading the window allowed me to get past the message of analyzing. |
I've tried reproducing this in a Python 2.7 virtualenv with docutils installed, in a file which imports every docutils module listed in your logs, but no luck. The analysis completes and sits at about 100MB, not changing if the file is changed. Are you importing docutils directly in your project? (If you aren't, then we shouldn't find it when you're using an environment with only that package, since it wouldn't be analyzed at all.) |
If you aren't already, you may want to try the daily build: "python.analysis.downloadChannel": "daily" 0.3.0+ contain some large memory-impacting changes, though I can't say if they'd help in this specific scenario. |
I've been working with daily all day and it has been pretty good regarding memory management, but I haven't tried reinstalling that module in the virtualenv that I'm. Weirdly, I search for that module in my project and I don't see it directly so it could be that the module is a requirement from another one that is also installed. I'm going to run another tests see if the behaviour persists with that module. Thanks for trying to reproduce this. |
The trouble is that if you were able to reproduce it in a virtualenv with just docutils, but your code doesn't actually import it, then docutils shouldn't have been able to be loaded at all, since there wouldn't even be any indirect imports. That's the confusing bit. |
Since daily appears to be better, closing. @jakebailey is working on improving our search paths handling, he can suggest which issue in that space may be related. |
@lisnb commented on Fri May 31 2019
Issue Type: Bug
I'm using this amazing
Remote-SSH
extension, but the python language server on the remote uses a lot of memory up to 120G+, I try to unistall this extension or kill -9 the process, but it's not working. It seems this process starts itself once killed.Extension version: 2019.5.17517
VS Code version: Code - Insiders 1.35.0-insider (e9c50663154c369a06355ce752b447af5b580dc3, 2019-05-30T05:18:06.502Z)
OS version: Darwin x64 18.2.0
Remote OS version: Linux x64 4.4.0-33.bm.1-amd64
Remote OS version: Linux x64 4.4.0-33.bm.1-amd64
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
@lisnb commented on Fri May 31 2019
I noticed that this process was located in ~/.vscode-remote directory but as the remote-ssh extension keeps updating, the vscode is now under ~/.vscode-server-insider directory
The text was updated successfully, but these errors were encountered: