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

Constant reanalysing of entire project in VSCode with diagnosticMode workspace #7001

Open
rchiodo opened this issue Feb 28, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Feb 28, 2025

Discussed in #7000

Originally posted by lukaspiatkowski February 23, 2025
I am not sure how much of this falls into Pylance vs Pyright, so sorry if this is the wrong place to ask.

I am working on migrating a relatively large monorepo (Pylance reports 5.5k source files found, with some bash I estimated it to be 1.5M lines; venv is 14.5k files and 4.4M lines) from using mypy to pyright. One important feature for me is being able to see all errors in the workspace, so that I can focus on a single module, check all the errors on it, fix them, mark module as done and go to the next one. For that I've set the "python.analysis.diagnosticMode" to "workspace". Since I also have "python.analysis.userFileIndexingLimit": 8000 (also tried with -1) I have hoped that after initial indexing if I change only one thing in a single file the analysis time won't be very horrible, but it does take noticable amount of time to update inlay hints or show description of a new symbol when hovering. It gets much worse when you want to change several things, then the editor feels like it starts getting clogged on the amount of processing it has to perform.

I've decided to make a test: set log levels to tracing, open a file that I've though wouldn't be imported in too many places, wait for the log lines to finnish logging (entire codebase was analised-parsed-binded-checked), cleared the output and added a space in a comment in that file. The logs exploded again, I've waited until they are done, saved the logs, redacted them and here they are:
https://gist.github.com/lukaspiatkowski/6098003d2c3c4f68a71995528748490e

Some pieces of my configs that might be relevant:

  "python.analysis.userFileIndexingLimit": 8000,
  "python.analysis.inlayHints.functionReturnTypes": true,
  "python.analysis.inlayHints.pytestParameters": true,
  "python.analysis.inlayHints.variableTypes": true,
  "python.analysis.autoImportCompletions": true,
  "python.analysis.nodeExecutable": "/opt/homebrew/bin/node",
  "python.analysis.autoFormatStrings": true,
  "python.analysis.diagnosticMode": "workspace",
  "python.analysis.logLevel": "Trace",

pyrightconfig.json:

{
  "include": ["b92", "ca1.py", "s0e", "uda", "../w2a"],
  "venvPath": "./",
  "venv": ".venv",
  "exclude": [
    ".venv",
    "semgrep",
    "**/__pycache__"
  ],
  "pythonVersion": "3.11",
  "executionEnvironments": [
    {
      "root": "s0e",
      "extraPaths": [
        "../w2a"
      ]
    },
    {
      "root": ".",
      "extraPaths": [
        "s0e",
        "../w2a"
      ]
    },
    {
      "root": "../w2a"
    }
  ],
  "reportPrivateUsage": false,
  "reportPrivateImportUsage": "information",
  "reportUnusedCallResult": false,
  "enableTypeIgnoreComments": true,
  "reportIgnoreCommentWithoutRule": true
}

Things to also point out:

  • There is one very bad long file (/Users/lukas/m5a/ma1/s0e/tdd.py) that often causes Long operation warnings which is a ~5k line long list of all available actions and it imports a very substantial portion of the codebase from various places.
  • I've tried running pyright -w <submodule>, but after printing Watching for file changes... it never reacts to my changes. - EDIT: I just didn't know that pyright -w outputs all the type errors on every file change and didn't notice the change
  • I am using pyright 1.1.394 from command line and pylance 2025.2.101 in VSCode 1.97.2 running M1 MacBook Pro with 16GB RAM.

So my questions are:

  • Is it expected that with workspace diagnosticMode the entire codebase is reanalysed on every change?
  • Is it better to work with diagnosticMode set to openFilesOnly and open hundreds of files at once (a single module) or some other workaround?
  • Is there something I can do to improve the performance of pyright for my repo?

P.S.
While writing this message I've tried my line of testing (opening a single file, adding a space to a comment and watching logs explode) few times and after one of the attempts I've got harrased by MacOS with message: "Your system has run out of application memory" and has asked me to force quit some apps. VSCode was reported to use 42GB, so I've killed it. I have 16GB of RAM and 39GB of Swap. After starting VSCode again I see in htop that Swap is almost completely used, but RAM is around 5GB. I've tried to bleed pyright by changing few things and I see CPU maxed, but memory is still around 5.5GB max... So not sure what was the issue with MacOS or what they mean by "application memory" exactly.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Feb 28, 2025
@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 28, 2025

@heejaechang it looks like it was part of a bug fix you made:
https://github.com/microsoft/pyrx/commit/5e2ed91374ac345e6ba484eeb715a8c900efb809

@rchiodo rchiodo assigned heejaechang and unassigned bschnurr Feb 28, 2025
@rchiodo rchiodo added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants