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

Slow "Getting code actions from ..." revisited #21485

Open
janosh opened this issue Jun 25, 2023 · 13 comments
Open

Slow "Getting code actions from ..." revisited #21485

janosh opened this issue Jun 25, 2023 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team

Comments

@janosh
Copy link

janosh commented Jun 25, 2023

Follow up to #19808 (which I can't comment on since locked).

I see the popup "Getting code actions from 'Python','Jupyter', 'Ruff'" all the time in large code bases, leading me to believe the slowness has something to do with scanning large numbers of files. The project I notice it most in has 527 Python files. It can take anywhere from 10 to 30+ seconds to save a file.

Screenshot 2023-06-24 at 6 10 24 PM

I tried disabling jupyter and black formatting and the issue persists. I was seeing it long before I started using ruff so prob not the culprit.

The Python extension logs look like mypy is running on every save. Maybe that explains the slowness? mypy scales poorly with project size in my experience.

2023-06-24 18:16:49.218 [info] > ~/.venv/py311/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/linter.py -m mypy --follow-imports=silent --ignore-missing-imports --show-column-numbers --no-pretty ./pymatgen/core/tests/test_structure.py
2023-06-24 18:16:49.219 [info] cwd: .
2023-06-24 18:16:49.442 [info] ##########Linting Output - mypy##########

2023-06-24 18:16:49.442 [info] Success: no issues found in 1 source file

2023-06-24 18:16:49.554 [info] Discover tests for workspace name: pmg - uri: /Users/janosh/dev/pmg/pymatgen/core/tests/test_structure.py
2023-06-24 18:16:49.557 [info] > ~/.venv/py311/bin/python ~/.vscode/extensions/ms-python.python-2023.10.1/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .
2023-06-24 18:16:49.557 [info] cwd: .


@janosh janosh added the feature-request Request for new features or functionality label Jun 25, 2023
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jun 25, 2023
@karthiknadig karthiknadig self-assigned this Jun 26, 2023
@karthiknadig
Copy link
Member

@janosh Does disabling mypy linting help?

Additionally, you could try mypy extension which uses dmypy and does handle this in a different way so it should not block.

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality labels Jun 26, 2023
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jun 26, 2023
@janosh
Copy link
Author

janosh commented Jun 27, 2023

I had "python.linting.mypyEnabled": true but tried setting it to false before posting here. Makes no difference, even after window reload.

I just installed the mypy extension as you suggested. I had to install the pre-release version since the regular gave me

Can't install release version of
'ms-python.mypy-type-checker'
extension because it has no release version.

Screenshot 2023-06-26 at 6 06 16 PM

But having the extension also makes no difference.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Jun 27, 2023
@udeepam
Copy link

udeepam commented Jul 3, 2023

I get this same error except it lasts indefinitely instead of 10 to 30 seconds to save a file.

@karthiknadig
Copy link
Member

Can you share your settings? Do you have Code Actions on save turned on?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jul 5, 2023
@janosh
Copy link
Author

janosh commented Jul 5, 2023

@karthiknadig Yes to both:

  "source.fixAll",
    "source.organizeImports"
  ],
  "editor.formatOnSave": true,
  "notebook.formatOnSave.enabled": true,
Full settings
{
  "workbench.colorCustomizations": {
    "editorRuler.foreground": "#9c9c9c13"
  },
  "[javascript][html][typescript][css][markdown][yaml]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "[latex]": {
    "editor.defaultFormatter": "James-Yu.latex-workshop",
    "editor.detectIndentation": false,
    "editor.suggestSelection": "recentlyUsedByPrefix",
    "editor.tabSize": 2
  },
  "[python]": {
    "editor.rulers": [88, 100, 120],
    "editor.tabSize": 4,
    "rewrap.reformat": true,
    "rewrap.wrappingColumn": 88,
    "editor.defaultFormatter": "ms-python.black-formatter",
    "editor.formatOnType": true
    // "editor.formatOnType": true
    // if pylance fails to resolve local editable install of a package, try installing it with
    // pip install -e . --config-settings editable_mode=compat
    // https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior
  },
  "[svelte]": {
    "editor.defaultFormatter": "svelte.svelte-vscode"
  },
  "[markdown]": {
    "editor.defaultFormatter": "yzhang.markdown-all-in-one",
    "editor.quickSuggestions": {
      "comments": "on",
      "strings": "on",
      "other": "on"
    }
  },
  "emmet.excludeLanguages": [],
  "emmet.includeLanguages": {
    "markdown": "html"
  },
  "emmet.triggerExpansionOnTab": true,
  "cSpell.customDictionaries": {
    "cSpell_dict": {
      "addWords": true,
      "name": "cSpell_dict",
      "path": "~/dev/macos-setup/dotfiles/cSpell_dict.txt"
    }
  },
  "cSpell.enableFiletypes": [
    "css",
    "git-commit",
    "git-rebase",
    "html",
    "json",
    "latex",
    "markdown",
    "plaintext",
    "yaml",
    "yml"
  ],
  "cSpell.blockCheckingWhenLineLengthGreaterThan": 10000,
  "cSpell.blockCheckingWhenTextChunkSizeGreaterThan": 2000,
  "cSpell.checkLimit": 5000,
  "cSpell.language": "de,en",
  "debug.console.fontSize": 14,
  "debug.toolBarLocation": "docked",
  "diffEditor.wordWrap": "on",
  "editor.codeActionsOnSave": [
    "source.fixAll",
    "source.organizeImports"
  ],
  "editor.fontSize": 14,
  "editor.formatOnSave": true,
  "editor.minimap.enabled": false,
  "editor.scrollBeyondLastLine": false,
  "editor.suggestSelection": "first",
  "editor.tabSize": 2,
  // "eslint.validate": ["javascript", "svelte", "html", "typescript"],
  "editor.wordWrap": "on",
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  "explorer.incrementalNaming": "smart",
  "files.associations": {
    "*.bib": "latex",
    "*.cls": "latex",
    "*.pyx": "python",
    "*.mdx": "markdown",
    "*.svx": "markdown"
  },
  "files.defaultLanguage": "{activeEditorLanguage}",
  "files.exclude": {
    "**/.git": true,
    "**/.ipynb_checkpoints": true,
    "**/.pytest_cache": true,
    "**/.vscode": true,
    "**/__pycache__": true,
    "**/.coverage": true, // pytest coverage
    "**/.mypy_cache": true,
    "**/.ruff_cache": true
  },
  "files.trimTrailingWhitespace": true,
  "git.autofetch": true,
  "gitlens.codeLens.enabled": false,
  "gitlens.currentLine.enabled": false,
  "gitlens.hovers.currentLine.over": "line",
  "gitlens.hovers.enabled": false,
  "gitlens.views.commits.pullRequests.enabled": false,
  "gitlens.views.commits.pullRequests.showForBranches": false,
  "gitlens.views.commits.showBranchComparison": false,
  "gitlens.views.repositories.files.layout": "tree",
  "html.hover.references": false,
  "javascript.updateImportsOnFileMove.enabled": "never",
  "jupyter.askForKernelRestart": false,
  "jupyter.runStartupCommands": ["%load_ext autoreload", "%autoreload 2"],
  "notebook.cellToolbarVisibility": "hover",
  "liveshare.featureSet": "insiders",
  "markdown.extension.toc.levels": "2..6",
  "markdown.extension.toc.orderedList": true,
  "markdown.extension.toc.updateOnSave": false,
  "markdownlint.config": {
    "MD029": false,
    "MD033": false,
    "MD041": false,
    "MD053": false
  },
  "markdown.extension.orderedList.marker": "one",
  "problems.showCurrentInStatus": true,
  "python.formatting.provider": "none",
  "python.languageServer": "Pylance",
  "python.terminal.activateEnvironment": false,
  "python.defaultInterpreterPath": "~/.venv/py311/bin/python",
  "python.analysis.autoImportCompletions": true,
  "python.linting.mypyEnabled": false,
  "terminal.external.osxExec": "iTerm.app",
  "terminal.integrated.fontSize": 14,
  "terminal.integrated.lineHeight": 1.3,
  "window.newWindowDimensions": "fullscreen",
  "window.restoreFullscreen": true,
  "workbench.editor.highlightModifiedTabs": true,
  "workbench.iconTheme": "material-icon-theme",
  "workbench.settings.editor": "json",
  "workbench.settings.openDefaultKeybindings": true,
  "workbench.settings.useSplitJSON": true,
  "workbench.startupEditor": "none",
  "workbench.editorAssociations": {
    "*.ipynb": "jupyter-notebook",
    "git-rebase-todo": "default"
  },
  "debug.javascript.autoAttachFilter": "disabled",
  "security.workspace.trust.untrustedFiles": "open",
  "notebook.cellToolbarLocation": {
    "default": "right",
    "jupyter-notebook": "left"
  },
  "security.workspace.trust.enabled": false,
  "files.insertFinalNewline": true,
  "svelte.enable-ts-plugin": true,
  "svgPreview.autoOpen": false,
  "git.confirmSync": false,
  "editor.inlineSuggest.enabled": true,
  "terminal.explorerKind": "external",
  "redhat.telemetry.enabled": false,
  "extensions.ignoreRecommendations": true,
  "git.suggestSmartCommit": false,
  "diffEditor.maxComputationTime": 3000,
  "diffEditor.maxFileSize": 20,
  "jupyter.widgetScriptSources": ["jsdelivr.com", "unpkg.com"],
  "github.copilot.enable": {
    "*": true,
    "yaml": true,
    "plaintext": false,
    "markdown": true,
    "python": true
  },
  "css.lint.duplicateProperties": "error",
  "css.hover.references": false,
  "css.lint.boxModel": "warning",
  "css.lint.propertyIgnoredDueToDisplay": "error",
  "css.lint.universalSelector": "warning",
  "css.lint.zeroUnits": "error",
  "notebook.lineNumbers": "on",
  "liveshare.notebooks.allowGuestExecuteCells": true,
  "editor.guides.bracketPairsHorizontal": true,
  "jupyter.debugJustMyCode": false,
  "terminal.integrated.enableMultiLinePasteWarning": false,
  "git.autoRepositoryDetection": "subFolders",
  "editor.unicodeHighlight.invisibleCharacters": false,
  "editor.unicodeHighlight.ambiguousCharacters": false,
  "jupyter.logging.level": "verbose",
  "markdown.validate.enabled": true,
  "css.lint.validProperties": [
    "dominant-baseline",
    "cx",
    "cy",
    "r",
    "container-type"
  ],
  "svelte.ask-to-enable-ts-plugin": false,
  "editor.accessibilitySupport": "off",
  "ruff.showNotifications": "onWarning",
  "jupyter.interactiveWindow.creationMode": "perFile",
  "jupyter.interactiveWindow.textEditor.executeSelection": true,
  "jupyter.interactiveWindow.textEditor.magicCommandsAsComments": true,
  "jupyter.interactiveWindow.textEditor.autoMoveToNextCell": false,
  "jupyter.interactiveWindow.textEditor.autoAddNewCell": false,
  "jupyter.interactiveWindow.codeLens.commands": "jupyter.runcell, jupyter.runallcellsabove, jupyter.runcellandallbelow, jupyter.debugcell",
  "githubPullRequests.pullBranch": "never",
  "notebook.formatOnSave.enabled": true,
  "githubPullRequests.terminalLinksHandler": "github",
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  // "evenBetterToml.formatter.reorderKeys": true,
  "evenBetterToml.formatter.reorderArrays": true,
  "grammarly.files.include": ["**/*.{md,tx,tex,rst,svx,html}"],
  "gitlens.gitCommands.skipConfirmations": [
    "fetch:command",
    "switch:command",
    "stash-push:command"
  ],
  "diffEditor.ignoreTrimWhitespace": false,
  "window.zoomLevel": 1
}

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Jul 5, 2023
@karthiknadig
Copy link
Member

karthiknadig commented Jul 6, 2023

I would try this first, here will ensure only ruff is used for Organize Import action:
image

Another thing I would try is see if disabling fixall stops the issue.
image

If the second thing improves the scenario then the issue might be in pylance server and we can move it there.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jul 6, 2023
@janosh
Copy link
Author

janosh commented Jul 6, 2023

I tried both. Quit and restarted VS Code after each change. Didn't notice any difference in the time to save. In case it helps, the repo with the longest delay is https://github.com/materialsproject/pymatgen. It's also the largest one I work on.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Jul 6, 2023
@udeepam
Copy link

udeepam commented Jul 11, 2023

Not yet sure if this fixes the problem completely but when I ran Developer: Show Running Extensions in the command palette, I found that the extension Todo Tree was not loading and blocking. Uninstalled it and haven't had this problem since.

@PromethiumL
Copy link

For me I notice that this problem is triggered if I modify and save a __init__.py file. The log from isort then became very different. I have to restart vscode and avoid modifying __init__.py to avoid it from happening again.

image

isort is the only extension on the list. I disabled Jupyter and other extensions as mentioned by others above.

image

Why does the __init__.py cause such problem?

@loftusa
Copy link

loftusa commented Oct 4, 2023

I am having this issue as well. It keeps going indefinitely. Extremely annoying.
Screenshot 2023-10-04 at 3 44 47 PM

@sliedes
Copy link

sliedes commented Oct 16, 2023

I see this all the time too. In the Extension Host output window, there's this when it happens:

2023-10-16 09:56:38.126 [error] [ms-python.isort] provider FAILED
2023-10-16 09:56:38.127 [error] Error: AttributeError: 'NoneType' object has no attribute 'stdout'
    at /home/sami/.vscode-insiders/extensions/ms-python.isort-2023.11.12711013/dist/extension.js:1:92177
    at ie (/home/sami/.vscode-insiders/extensions/ms-python.isort-2023.11.12711013/dist/extension.js:1:92471)
    at /home/sami/.vscode-insiders/extensions/ms-python.isort-2023.11.12711013/dist/extension.js:1:87255
    at Immediate.<anonymous> (/home/sami/.vscode-insiders/extensions/ms-python.isort-2023.11.12711013/dist/extension.js:1:87275)
    at processImmediate (node:internal/timers:476:21)

So without knowing anything about the code, there's a timer that runs and that fails with a Python error, and then that saving thing just fails because it waits for that timer to complete? (Perhaps there would be some way to propagate the failure?)

@karthiknadig
Copy link
Member

@sliedes Thanks for sharing the stack that helps with diagnosing this one.

@hunter1303
Copy link

it looks like some package installation failure can also cause errors like this, when i uninstalled the notebook everyting back to normal. hope this can be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

7 participants