python-language-server icon indicating copy to clipboard operation
python-language-server copied to clipboard

Library indexing performance breakdown in large library directory trees ($HOME)

Open ripoul opened this issue 6 years ago • 8 comments

Environment data

  • VS Code version: 1.40.1
  • Extension version (available under the Extensions sidebar): 2019.11.50794
  • OS and version:
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: all
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info microsoft/vscode-python#3977): languageServer.0.4.127

Expected behaviour

When I start a python file, I would like auto completion to work.

Actual behaviour

The auto completion never stop loading

Steps to reproduce:

  1. create python file (.py)
  2. start coding
  3. press ctrl+space
  4. loading shows up

gif

Logs

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

User belongs to experiment group 'AlwaysDisplayTestExplorer - experiment'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - control'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> ~/Documents/perso/Georide/env/bin/python -c "import sys;print(sys.executable)"
> conda info --json
Starting Microsoft Python language server.
> conda --version

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Info Python Extension: 2019-12-06 09:18:11: setGlobalInterpreter, Class name = f, completed in 33ms, Arg 1: {"architecture":3,"path":"/home/ripoul/Documents/perso/Georide/env/bin/python","version":{"options":{"loose":false,"includePrerelease":false},"loose":false,"raw":"3.6.9-final","major":3,"minor":6,"patch":9,"prerelease":["final"],"build":[],"version":"3.6.9-final"},"sysPrefix":"/home/ripoul/Documents/perso/Georide/env","fileHash":"551f7f6dfbd50caa3384e0ed838b3c37537b4046327536e1c53e834e9da30418c0cb986321f2d72e77879a0a70028ed331476c4a6c0e52de2012ddbf4239f472","type":"Unknown"}, Arg 2: undefined, Return Value: false
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: setGlobalInterpreter, Class name = f, completed in 28ms, Arg 1: {"architecture":3,"path":"/usr/bin/python3","version":{"options":{"loose":false,"includePrerelease":false},"loose":false,"raw":"3.6.9-final","major":3,"minor":6,"patch":9,"prerelease":["final"],"build":[],"version":"3.6.9-final"},"sysPrefix":"/usr","fileHash":"604a06f7b1a722a049f2b15568c4fed9d9d80e44ade3d3b12dccb54caf2ecbd5f789129ad92b41268b6e7078c7f2d4263fcf4c6067066b570c4d4bc16c87e45f","type":"Unknown","displayName":"Python 3.6.9 64-bit"}, Arg 2: undefined, Return Value: false
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Rule = cachedInterpreters, result = runNextRule
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Executing next rule from cachedInterpreters
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Rule = system, result = runNextRule
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Executing next rule from system
2workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: autoSelectInterpreter, Class name = f, completed in 71ms, Arg 1: undefined, Return Value: undefined
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Checking whether locactors have completed locating, Class name = p, completed in 0ms, , Return Value: true
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: Hide locator refreshing progress, Class name = p, completed in 0ms, , Return Value: undefined
workbench.desktop.main.js:sourcemap:250 [Extension Host] Info Python Extension: 2019-12-06 09:18:11: All locators have completed locating, Class name = p, completed in 0ms, , Return Value: undefined
2workbench.desktop.main.js:sourcemap:250 [Extension Host] (node:8106) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

ripoul avatar Dec 06 '19 08:12 ripoul

Could please set

"python.analysis.logLevel": "Trace",

Copy analysis log output from the output window of the language server and attach it here. Thanks.

MikhailArkhipov avatar Dec 10 '19 06:12 MikhailArkhipov

[Info - 18:16:13] Analysis cache path: /home/ripoul/snap/code/common/.cache/Microsoft/Python Language Server [Info - 18:16:13] Microsoft Python Language Server version 0.4.127.0 [Info - 18:16:13] Workspace root: /home/ripoul/Documents/perso/Georide [Info - 18:16:13] GetCurrentSearchPaths /home/ripoul/Documents/perso/Georide/env/bin/python [Info - 18:16:13] Interpreter search paths: [Info - 18:16:13] /home/ripoul/Documents/perso/Georide/env/lib/python3.6 [Info - 18:16:13] /home/ripoul/Documents/perso/Georide/env/lib/python3.6/lib-dynload [Info - 18:16:13] /home/ripoul [Info - 18:16:13] /usr/lib/python3.6 [Info - 18:16:13] /home/ripoul/Documents/perso/Georide/env/lib/python3.6/site-packages [Info - 18:16:13] User search paths:

ripoul avatar Dec 10 '19 17:12 ripoul

Your home directory is appearing as an interpreter search path. Have you set extraPaths or PYTHONPATH to set this? If you have your entire home directory as a search path, then the library indexer is going to start searching in it for python code to suggest imports (among other things).

jakebailey avatar Dec 10 '19 17:12 jakebailey

I always had my home in my PYTHONPATH for an other project. When I used an older version of vscode the autocompletion worked well.

sudo snap install vscode

The version behind this work well.

ripoul avatar Dec 10 '19 17:12 ripoul

I would recommend against doing that, since you're basically allowing any file in your home to potentially override other imports (and it's not a realistic environment...). This certainly affects library indexing (which tries and finds libraries in paths python says it will use), but may impact other parts of the code as well.

The only thing I can think of here is that we're going to have to try and limit the number of files we're indexing or the directory tree depth for setups which include search paths of giant file trees ($HOME is pretty worst-case), but I can't say for sure that the issue is limited to just indexing given the behavior you're seeing (autocomplete and indexing are distinct-ish).

jakebailey avatar Dec 10 '19 17:12 jakebailey

If you remove your home from PYTHONPATH, does the issue go away? That'd be the easy thing to test.

jakebailey avatar Dec 10 '19 17:12 jakebailey

Yeah it worked thx ! Do you have an idee why with an older version it worked as well. If no you can close this issue.

ripoul avatar Dec 10 '19 17:12 ripoul

We recently added auto-import support to offer code fixes for libraries, which would be the only thing I could think of.

jakebailey avatar Dec 10 '19 17:12 jakebailey