-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
100% CPU usage when there's a symlink to a different disk drive on Linux #7218
Comments
@dimitry-boersma Which process is using CPU? cpptools or cpptools-srv? |
The |
Do you see "tag parsing" messages in the C/C++ output pane when you set C_Cpp.loggingLevel to "Debug"? If so, that would be normal CPU usage. Or is there a database icon in the status bar? |
It will print these messages until it has finished parsing some files, then it will print I am not sure I understand what you mean with a "database icon in the status bar", could you explain that please? |
Hmm, it sounds like it might be stuck in some infinite loop. Can you attach a debugger to cpptools to get a call stack (https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv)? You can ignore the threads that appear to have small call stacks that are blocked waiting for work. |
There are quite a few threads, and I'm not quite sure what I am looking for. I did find this thread, which mentions parsing a file. I've pasted the call stack below:
All of the other threads seem to be in a waiting state, as you mentioned. These threads all end on a I indeed see that database icon in the status bar |
That call stack appears to be normal parsing (from an open file...if you don't open a file you shouldn't get that call stack...i.e. is the CPU usage issue only after you open a file?). If the database icon is there what does it show when you hover over it? It looks like it's still trying to parse stuff in the workspace. |
When I hover over the database icon I see the popup "Parsing open files". I've tried pausing/playing the debugger a little and I do seem to get a different call stack for the thread I mentioned, so it might not necessarily be stuck on a single statement. Are you aware if it is possible to find the Process ID for the threads found in the call stack so I can make sure I am looking at the right one? I am able to identify the Process ID of the 100% CPU thread in |
Perhaps interesting to note is that the following subset of the call stack seems to be persistent:
The calls below this level update every time I play/pause the debugger |
Yeah, it seems like it's parsing the include dependencies from the open file...I would assume you would see "tag parsing" messages for those? |
I'm not sure how to answer your question, where should I look for these "tag parsing" messages? |
The "C/C++" pane in the Output window is expected to show those (with C_Cpp.loggingLevel set to "Debug"). |
I don't see those, the only related thing I could find was: Edit: for clarification, I have set |
Hmm, that code hasn't changed in a long time and is not known to have any infinite loop issues. One thing you could try is to remove all the recursive includes "**" from your includePath to see if that fixes your issue, since that'll cause the parse_file to execute a different code path that might not have the bug. You could also try temporarily setting the C_Cpp.loggingLevel to the hidden value of "7" and see if it gives more info on what it is trying to parse, e.g. "resolving include" messages. It's possible that something is unusual with your database. You may want to try using the C/C++: Reset IntelliSense Database command. Or if this issue only repros when opening a particular file there could be something special in that file that is causing our code to loop incorrectly as it tries to parse the dependent include files. Are you able to provide any sample repro code that exhibits the bug? If there's no "tag parsing" messages, that implies that the files are already parsed, in which case, it's expected that it shouldn't take that long to finish, since it's basically just checking the database for the include files it needs to parse for dependencies. |
If I put the logging level to 7, I do see some "tag parsing file: " messages passing by. Though most of them are followed by thousands of lines (nearly 10 thousand in fact) containing "update_file_if_needed:", not sure if that is intended? |
10k update_file_if_needed messages would mean those header files were potentially being used by the opened file or its dependencies so it checked if needed to be tag parsed, but determined that it did not. Do the update_file_if_needed files appear to be valid headers? It's not processing the same files repeatedly or it hasn't been searching in some invalid place, right? |
It doesn't appear to repeatedly be processing the same files, nor do the paths look incorrect to me. I don't think it is trying to parse invalid headers either |
Do you have any guess why it's taking so long to finish? |
Perhaps it is the sheer volume of files that it is trying to weed through? Combine that with the fact that it will check for updates on all of the dependencies for each edit or context (window) change, I think it would have a lot of processing to do. I have noticed that sometimes it will actually finish its processing, though I'm not sure how to reproduce that scenario |
I'm having a similar issue when loading the mediapipe project. After I build it once in a VSCode terminal (e.g. Hope this helps somehow. |
@plafer When you set C_Cpp.loggingLevel to "Debug" what does it show in the "C/C++" output? You may want to add a folder to files.exclude or C_Cpp.files.exclude if it's showing tag parsing messages for files that don't need to be parsed. Otherwise, are you able to get a call stack (https://github.com/microsoft/vscode-cpptools/wiki/Attaching-debugger-to-cpptools-or-cpptools%E2%80%90srv) or perf logs (https://github.com/microsoft/vscode-cpptools/wiki/Troubleshooting-Performance-Issues). |
I was not able to make gdb attach work from inside VS Code, so I did it in a terminal. The call stack I got was:
I ran it a couple of times, and it's always stuck in the same place. I also noticed that there were 2 copies of |
That call stack is just the main loop waiting for input. Can you look for a call stack in other threads? The call stack would probably be deeper than all the others and not blocked by a mutex or read operation (at least not usually). |
I inspected the call stack a few times for a different thread. Hopefully that gives you enough information. First time
Second time
Third time
Fourth time
|
@plafer That looks like normal behavior. It appears to searching the |
You're right! I was getting was a bunch of tag parsing messages of the many protobuf generated files that MediaPipe generates. I reset my Intellisense cache, it reparsed everything, and eventually stopped. Maybe my database was corrupted before the reset? Thanks for the help! EDIT: Actually I get the same problem again when opening files that their dependencies were not compiled. C/C++ output shows no new output. I built those dependencies, which made the include errors disappear. However there's still one last issue which Intellisense returns as an error (A line similar to |
I have also seen this high CPU usage in |
After a recent update I also got this high cpu usage every time vscode start. |
I'm also seeing a whole core being used by the c/c++ extension. I've had this problem for a long time. Sometimes it stops but then it seems to come back. My .vscode\c_cpp_properties.json is:
With:
my symbol lookup nearly always works. This is a very large project folder. |
@BillDenton Have you tried adding folders to files.exclude or C_Cpp.files.exclude? We fixed directory iteration so that subdirectories of excluded folders won't be iterated over, which I assumed would fix your issue. |
One thing that appears to cause 100% cpu usage forever with cpptools is graph cycles by means of soft links. This is the setup that reproduces the issue for me:
Now, open vscode, select It almost looks like cpptools follows soft links in loops with no cycle detection. To address the problem on my setup, I undid part (1) above. i.e. I just moved |
@sean-mcmanus I've added a few (4) top-level folders to the exclude in "C_Cpp.files.exclude". As soon as a added one or two folders (which didn't contain that many files) the CPU load dropped to negligible. So it seems that there is an upper limit after which it falls over. I'll give it a few days until I believe this has resolved it. Update: Next day. After resuming from hibernating all was OK. Then updating files (git merge of latest code into my development branch) and build, the C/C++ extension went back to using a whole core. Not sure exactly when it started. It seems that there is something that triggers it other than just the number of files/directories. The developer reload window makes no difference. I guess that doesn't affect the extensions. Restarting VS Code gives a high load (one core) for a short while followed by 0% of the extension (note: I haven't started editing, building, reference searching etc since the restart). Second update: After a few edits the extension was back to using a core. Restarting VS Code fixed it. After the restart, a few edits and another build was OK. ~~Then a bit later after another edit and build it was back to using a whole core. ~~ (Update: It went quickly back to 0%. I didn't notice because the laptop fans were noisy, which is usually the first sign that is using a core all the time.) All our header files are stored in directories ending in one of two names. Is there any way I can restrict the header include search to any directory path ending in one of those two words? Probably an unrelated problem: query_goto_def: looking for symbol '' |
@jeannekamikaze Are you using 1.4.1 or 1.5.0-insiders2? I'm not reproing that issue using the symlink structure described, but I'm only using 1 disk. Does it repro for you if you use only 1 disk? If it requires 2 disks, it could have the same root cause as #7701 . Our directory iteration code has cycle detection in regards to symlinks, but there might be some special case that isn't handled correctly. @Colengms Are you able to repro the issue? @BillDenton Using one core might be expected if it's responding to workspace updates, but it should eventually go to 0 CPU. Are you able to tell what processing is occurring from the logging or call stacks? It sounds like it might be iterating through the workspace to look for files to reparse. Our includePath and browse.path settings don't support wildcards yet -- it's being tracked by #723 . The log message "query_goto_def: looking for symbol" should only appear with the hidden logging level of 7 or higher (which should only be used temporarily since it could impact performance), but the output of |
@sean-mcmanus I did put the debug level 7 after seeing earlier in the issue. I'll put it back to debug. I'm not sure what loading has been like today, but I think it has been better. I don't usually notice until the laptop fans go made. I sounds like it will get a lot better once #723 is done. Sorry, it wasn't a symbol ''. I had removed the symbol and put < removed or something similar >. That didn't come out in the issue report. |
@sean-mcmanus I have 1.5.0-insiders2. I don't see any issues with soft links within the save physical drive, so it must be the 2-disk setup. I also don't have LVM or anything that hides the physical disks from applications. |
@jeannekamikaze Thanks for the info. @Colengms This sounds like it might have the same root cause as the 2 disk issue you're investigating. |
No problem @sean-mcmanus. Also, not to digress too much here, but my original quest was to get the extension to run on vscodium, which appears to be impossible as described here due to 1) A licensing issue and 2) A technical issue with the telemetry refusing to run outside of vscode. Is there any chance you guys can address the above as well? Thank you. |
@jeannekamikaze We don't intend to address running in vscodium...we had an issue tracking that, but I believe it got Won't Fixed. |
@jeannekamikaze Sounds like you may be hitting #7701 with /D or /I paths. |
Is anyone still hitting this issue with https://github.com/microsoft/vscode-cpptools/releases/tag/1.5.1 ? |
I experience it with 1.5.1. Had a workspace with one of the projects symlinked to another disk, and cpptoolls memory usage went through the roof (like, 25G), up to a point when processes started getting killed. Removed it, and memory usage dropped. |
2 discoveries here:
|
I am experiencing this exact same issue.
What I have also noticed is that when I run
htop
, I see a single thread of the C/C++ extension constantly at 100% cpu usage. This happens anytime I compile the code and lasts until I close VSCode.SW Versions:
The output window only has a single 'instance' for the C/C++ extension: "C/C++ Configuration Warnings". In this window it seems to be switching between IntelliSense modes willy-nilly. A small excerpt of the logs (in reality it is quite lengthy, but a lot of them are duplicate entries):
If I manually specify for it to use any of these compilerPaths, it will warn about changing to clang (effectively printing the same, but reversed). This doesn't fix the issue however.
Originally posted by @dimitry-boersma in #7197 (comment)
The text was updated successfully, but these errors were encountered: