Vscode: can't go to definition due to large workspace (python)

Question:

as my project grows bigger, I can’t use ctrl + left click(or F12) to go to definition in Vscode.

I have tested with a new workspace and a single python file. The go to definition feature works well. (I.e. Python and Pylance are functional for small project.)

def pp():
    print('test')

pp()

Also, I have tested the feature by connecting to a remote server via Vscode. It works well on the server, which has much larger memory/ capacity.

On my local machine, I have 15.6 GB memory in total. With the bigger project opened, there is still 9 GB memory free.

Maybe it’s not directly related to memory but the experiments shows that go to definition kinds of depending on the project size:

small project @ local machine:                ok
big   project @ local machine:                failed
big   project @ remote server(larger memory): ok

I’m using pylance, which is set in setting.json:

    "python.languageServer": "Pylance",
    "python.jediEnabled": false,

I have excluded all the uncessary folder in setting.json to reduce the project size:

"files.watcherExclude": {
    "**/build/**": true,
    "**/data/**": true,
    "**/output/**": true,
    "**/pcdet.egg-info/**": true,
    },

But still, when I click with ctrl, vscode is loading forever.

How can I get the go to definition feature work?

Asked By: zheyuanWang

||

Answers:

Man shall avoid storing too much data in the project folder.

The problem sticks even when I added all the folder containing massive files to "files.watcherExclude" and "files.exclude" in setting.json

I finally solved it by move the corresponding folder out of the project. Instead I create soft links to them at their original places.

It seems that 20GB files are way too large, even the folder is excluded. And 0.6GB files can’t be handled properly either.

Answered By: zheyuanWang

I’ve had the same issue. Besides the Watcher Eclude, there is a Python Analysis:Exclude setting.

Preferences->Settings, search for "Exclude"

Modify Workspace settings for Python->Analysis:Exclude to exclude the large folders.

My .vscode settings.json entry example:

"python.analysis.exclude": [
    "**/data/**",
    "**/experiments/**",
    "**/wandb/**"
]
Answered By: meferne