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

C/C++ Intellisense slow and unresponsive (v1.19.9) #12126

Closed
AlexDai54202 opened this issue Mar 20, 2024 · 13 comments
Closed

C/C++ Intellisense slow and unresponsive (v1.19.9) #12126

AlexDai54202 opened this issue Mar 20, 2024 · 13 comments
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service performance quick fix
Projects
Milestone

Comments

@AlexDai54202
Copy link

Environment

  • OS and Version: Windows 11 Home, version 23H2
  • VS Code Version:
Version: 1.87.2 (user setup)
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Date: 2024-03-08T15:20:17.278Z
Electron: 27.3.2
ElectronBuildId: 26836302
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.22631
  • C/C++ Extension Version: v1.19.9
  • If using SSH remote, specify OS of remote machine: Linux d893f64b1111 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux

Bug Summary and Steps to Reproduce

Bug Summary:
Intellisense takes multiple seconds to autofill or hint.

Untitled.video.-.Made.with.Clipchamp.10.mp4

Steps to reproduce

  1. Open .c file in VScode.
  2. Attempt to reference a variable
  3. Variable takes multiple seconds to autocomplete/hint

Expected behavior:

  1. Open .c file in VScode
  2. Attempt to reference a variable
  3. Variable hinted during typing with minimal delay

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

Other Extensions

image

Additional context

Apologies in advance if this issue is written to be extremely informal; I'm an undergraduate student trying their best to complete their programming assignment. I can't seem to find a fix to this issue anywhere and this is genuinely driving me insane.

I don't think the issue is that there are too many active variables either; making a new .c file and writing something like int aintegervariable = 0; takes multiple seconds for intellisense to recognize and autofill and demonstrates the same issue.

demo.mp4

Additional context:
This issue has persisted for almost the entire time I've used C/C++, so I would likely have the same issue even with the last couple dozen versions of this extension.
My device has 16 GB of RAM, and the CPU utilization is <40% half the time, and my SSD has around 500 GB of unused storage space, so I don't think the issue is in the hardware.

Once again, apologies for wasting your time if the issue isn't well written or through enough to debug.

@browntarik browntarik added performance Language Service investigate: repro This issue's repro steps needs to be investigated/confirmed labels Mar 20, 2024
@Colengms
Copy link
Collaborator

Hi @AlexDai54202 . Would you be able to reproduce your captures with the Output panel open, set to the C/C++ output channel, and with the "C_Cpp.loggingLevel": "Debug" setting set? That should show us what's going on internally in the extension, simultaneously with your actions. There are various intentional delays (such as C_Cpp.intelliSenseUpdateDelay, which delays squiggle passes until you've stopped typing for 1s), and it's possible VS Code's requests for these features may not be routed to the extension immediately, or as quickly as you might expect. There are also various other settings or conditions that might be contributing, which may be apparent based on that log output.

@AlexDai54202
Copy link
Author

Gotcha! This capture is after I set the logging level to Debug.

Apologies for the video not being embedded; the file is over 10 MB and I assume clarity is important here.
https://www.youtube.com/watch?v=bMeNMm5CAQQ

Additionally, the intellisense update delay does appear to be 1000ms.
I'm unfortunately not familiar with types of delay I should be looking for, but a quick search yielded:
image

@bobbrow
Copy link
Member

bobbrow commented Mar 21, 2024

Hi @AlexDai54202, the update delay is for when we check for errors. We delay error checking so that you're not getting tons of red squiggles while you're in the middle of typing stuff that's still incomplete/uncompilable. The completion suggestions should not be impacted by this delay.

Your video is interesting and actually perfect because it shows the debug logging. What I am seeing in your logs is that the language server is restarting repeatedly. Something is shutting it down or it is crashing. That's why it's so slow. It's like it's compiling your file for every completion event and that's not expected. Can you drop a .txt file in this issue with the full debug log for this scenario? It scrolls by too fast in the video.

I tried your second scenario with the simple main function on WSL on my slow laptop and didn't run into the same problem as you though. The suggestions pop up right after I type the 'a'. This is what it's supposed to look like:

video.mp4

@AlexDai54202
Copy link
Author

Thanks for the followup!

Just in case I goofed up somewhere, here's the process I used to get the log.
https://github.com/microsoft/vscode-cpptools/assets/84922496/a04849de-67f4-420a-8142-a0f3cb0a512e

And here's the log I got!
5-CC++.log

Just in case this may end up being helpful: in Youtube, users can use , and . to move frame by frame in a video.

@Colengms
Copy link
Collaborator

Hi @AlexDai54202 . Have you set any of the following settings to values other than their defaults? C_Cpp.intelliSenseMemoryLimit, C_Cpp.maxCachedProcesses, C_Cpp.maxMemory, C_Cpp.intelliSense.maxCachedProcesses, C_Cpp.intelliSense.maxMemory

Those settings influence when we recycle IntelliSense translation units. Hypothetically, I might expect a problem like this to occur if those limits are set too low, causing IntelliSense translation units to be recycled almost immediately.

Otherwise, we're looking for some clue as to why your IntelliSense processes are only sticking around for a very short time. They appear to be getting shut down gracefully, before being immediately started again. Does this happen for you with multiple different projects, or on a different machine?

@AlexDai54202
Copy link
Author

I don't believe I have set any of those as anything other than default.
image
image
image
image
image

Not sure if this helps, but the only thing I've changed from default would be the setting "C_Cpp.default.cStandard": "gnu17".

This behavior doesn't seem to happen outside of the WSL/Docker server.

@bobbrow
Copy link
Member

bobbrow commented Mar 22, 2024

Can you share how you configured your WSL/Docker server? I'm not sure if anyone on our team has worked with that before or not.

@AlexDai54202
Copy link
Author

Unfortunately, the docker image is not configured by me, rather by the course staff, so I'm not of much help there.
With that said, my WSL configuration is as follows:

[wsl2]
memory=2GB

(Located at C:\Users\myusername.wslconfig)

And my container configuration for vscode is

{
	"workspaceFolder": "/home/student",
	"extensions": [
		"ms-vscode.cmake-tools",
		"ms-vscode.cpptools",
		"ms-vscode.cpptools-extension-pack",
		"ms-vscode.cpptools-themes",
		"ms-vscode.makefile-tools",
		"twxs.cmake"
	],
	"settings": {
		"C_Cpp.default.cStandard": "gnu17"
	}
}

Which I got from the command palate (Open attached container configuration file)

@sean-mcmanus
Copy link
Collaborator

@AlexDai54202 Yeah, 2 GB of memory is likely going to be insufficient (4-8 GB is recommended as a minimum). You could use some program like top to see the memory usage of cpptools and cpptools-srv and your free memory? It looks like we'll tear down cpptools-srv if the free memory drops below 256 MB. Is your repro with just 1 .cpp file open or are you switching between multiple source files?

@bobbrow
Copy link
Member

bobbrow commented Mar 22, 2024

@sean-mcmanus there's only one file open and we're tearing down IntelliSense while it's still in focus. I can't imagine a simple int main file using so much memory though. On my WSL instance, that file uses 52 MB.

@sean-mcmanus sean-mcmanus self-assigned this Mar 23, 2024
@sean-mcmanus sean-mcmanus added this to the 1.20.0 milestone Mar 23, 2024
@sean-mcmanus sean-mcmanus added bug and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Mar 23, 2024
@sean-mcmanus sean-mcmanus added this to Triage in 1.20 via automation Mar 23, 2024
@sean-mcmanus
Copy link
Collaborator

@bobbrow I'm seeing the memory usage by the OS, VS Code, and cpptools be > 2 GB. I think it can be fixed by ensuring 2 clients are kept active (and adding logging for when the IntelliSense processes are shutdown due to resource limits).

@sean-mcmanus sean-mcmanus moved this from Triage to Pull Request in 1.20 Mar 23, 2024
@sean-mcmanus sean-mcmanus added quick fix fixed Check the Milestone for the release in which the fix is or will be available. labels Mar 23, 2024
@sean-mcmanus sean-mcmanus moved this from Pull Request to Done in 1.20 Mar 25, 2024
@sean-mcmanus
Copy link
Collaborator

@AlexDai54202 Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.20.0, although let us know if you're still seeing other issues in your scenario with the 2 GB docker container.

@AlexDai54202
Copy link
Author

AlexDai54202 commented Mar 27, 2024

Horribly sorry for not keeping up - this project was absolutely killing me.
Configuring the WSL2 to be greater than 2 GBs fixed the issue. I cannot express how much gratitude I have for all of you for walking me through this. Once again, thank you all so much!

@github-actions github-actions bot locked and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service performance quick fix
Projects
No open projects
1.20
Done
Development

No branches or pull requests

5 participants