Skip to content

High CPU usage and UI freezes when typing in .py files (Remote-SSH, Pylance enabled) #7931

@G-Salviati

Description

@G-Salviati

Hi everyone,

I’ve been experiencing an issue since around March 5th.

I am working on a VM via VS Code Remote-SSH. I recently resumed work on a pytest suite designed to test Crossplane resources. Although the project is still very small—just one test file with a few tests—I am hitting major performance bottlenecks.

Environment & Dependencies

The project uses the following dependencies:

dependencies = [
    "boto3>=1.37.38",
    "jinja2>=3.1.6",
    "kubernetes>=34.1.0",
    "pytest>=8.3.5",
    "pytest-dependency>=0.6.0",
    "pytest-order>=1.3.0",
    "python-dotenv>=1.0.1",
    "pyyaml>=6.0.3",
    "tenacity>=9.0.0",
]

The Issue

As soon as I start typing in a .py file, I notice in htop that the VS Code server processes begin consuming excessive CPU. On this 2-core VM, the usage spikes from 1% to roughly 140% while typing. When I stop, it settles at around 40%.

After a few minutes of typing, VS Code starts freezing constantly. It stutters roughly every 7 seconds for about 2 seconds. This isn't limited to the editor; the entire UI freezes, including the terminal, the sidebar explorer, the top menu, and scrolling. The only way to temporarily resolve this is to kill the VS Code server processes and reconnect.

Troubleshooting Steps Taken

Extension Downgrade: I noticed the current version (v26.1.1) was released about 3 weeks ago. Since I last worked on this project 1.5 months ago without issues, I tried downgrading to a version from 3 months ago, but the behavior remained the same.

Configuration Tweaks: I tried to limit indexing and watchers using the following settings, but they didn't help:

settings.json

{
  "python.analysis.indexing": false,
  "python.analysis.userFileIndexingLimit": 500,
  "python.analysis.diagnosticMode": "openFilesOnly",
  "python.analysis.useLibraryCodeForTypes": false,
  "python.analysis.diagnosticDelay": 1000,
  "files.watcherExclude": {
        "**/.venv/**": true,
        "**/node_modules/**": true,
        "**/.git/**": true,
        "**/.*/**": true,
        "/proc/**": true,
        "/sys/**": true,
        "/dev/**": true
    },
    "search.followSymlinks": false,
    "python.testing.autoTestDiscoverOnSaveEnabled": false
}

pyrightconfig.json

{
    "executionEnvironments": [
        {
            "root": "."
        }
    ],
    "exclude": [
        "**/node_modules",
        "**/__pycache__",
        "**/.venv",
        "**/.*"
    ],
    "ignore": [
        "**/.venv"
    ],
    "reportMissingImports": false,
    "reportMissingModuleSource": false
}

Observations

The only way I can work without these freezes is by disabling the Pylance extension. As soon as Pylance is off, the CPU usage returns to normal.

Since I’d really like to keep the features provided by Pylance, do you have any suggestions on what might be causing this or how to fix it?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions