-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
High CPU usage with documentSymbols code #7022
Comments
It looks like there's some code in the particular file that is causing our document symbol code to potentially infinite loop. If you can provide some sample code that would enable us to debug/fix the issue. |
Hi Sean, thanks for opening this. This may be a bit of an edge case, as this happened after grading 50 student assignments for coding style. I've included the full issue template below, please let me know if there is anything else that would be useful. Note that I only noticed high CPU ~12 hours after closing VS Code. I've run into this issue at least once before, but I don't recall if that was also after grading. My last google search for Type: LanguageService Describe the bug
Steps to reproduce This is at least the second time I've encountered this issue, but I don't yet have exact repro steps.
Expected behavior I expect cpptools to not use high amounts of CPU while VS code is closed, especially if it has been closed for 12 hrs. Logs
Screenshots Additional context |
As for a code snippet, since this was after grading ~50 student assignments, I'm not sure if this is perhaps due to one particular I've included an image below showing the general layout of the files at the time I opened them. Would it still be helpful to see a code sample to get an idea of how the submissions look? |
The issue is most likely triggered by code in a particular file and not by rapidly opening many different files. Are you able to locate the file that is triggering the issue? You would likely see the Outline view fail to be populated. If you set C_Cpp.loggingLevel to "Debug", then the C/C++ output pane should show something like |
The code that exists at a non-local scope is the most likely to be the cause, so function definitions/bodies are unlikely to be needed for the repro. |
Here is a gist containing the debug logs: https://gist.github.com/TylerADavis/b62ec12b45bf0ee7dad652a4b61509a1 The debug logs appear to be specific to the file I have open at the moment I open the output pane, is there a way to get logs for all open files / just get logs from the instance of |
There should be one cpptools process per VS Code instance...assuming you're not seeing a dangling one from a previous instance then most likely the cpptools process belongs to the VS Code instance that is currently open. You should be able to close the VS Code instance and reopen that same file to retrigger the repro, right? I found a repro of an infinite loop using
which I reported at #7025, but I'm guessing your repro is probably different and I'm not sure yet if they share the same root cause. |
Ah, this looping one must be dangling from a previous VS Code instance then. I hadn't realized that cpptools is supposed to shut down with VS Code, and activity monitor does show two instances of cpptools. I'll reopen all files and see if that can get the properly behaving |
It's possible one of the edits you made to the code could have triggered the bug. The call stack provided shows that it's stuck processing the symbols for the currently opened file. The code operates on the database file that is obtained from parsing the files. So it's possible the database was in some bad state. Since #7025 is a regression with 1.2.2-insiders(2) and that's what you were using, it's possible they share the same root cause (although it's also possible your issue would repro with 1.2.1). I've also filed bug #7026 in regards to cpptools not shutting down (only seems to occur on Mac). |
Great, thank you for all of your help! I'll follow up on this issue if I'm able to reproduce this issue, either through regular use or when grading. If it helps, my last google search for |
We got another repro at #7012 which is more of a real world scenario that repros only on Linux/Mac for some unusual reason. Might still share the same root cause. |
@TylerADavis Should be fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.2.2 . You may notice a bugs with the Outline view with nested symbols -- we plan to fix that for 1.3: #6830 |
I noticed the fans were running on my MacBook, and I opened Activity Monitor to see that cpptools was using 98% CPU. I've had VS Code closed on my Mac since last night (when I opened approx 50 different cpp files), so I am not sure why cpptools would be running and using so much CPU right now.
Please let me know if there is a better place for me to report this bug, or if there are some logs I could collect and provide. I am running macOS Big Sur, and my C/C++ for VS Code is 1.2.2-insiders2.
Edit: I've also included photos of the stack trace, profiled using these instructions
Originally posted by @TylerADavis in #6238 (comment)
The text was updated successfully, but these errors were encountered: