vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Microsoft.VSCode.CPP.Extension.darwin pegging CPU for hours on end

Open DevSecTim opened this issue 10 years ago • 77 comments

Any reason why this happens? My Mac fan is going all the time while using VSCode and its annoying and hot! Surely IntelliSight (or whatever) doesn't constantly need to scan code?

screen shot 2016-10-13 at 23 04 04

DevSecTim avatar Oct 13 '16 22:10 DevSecTim

@antnsi It was fixed in 0.14.6 in January. You could be hitting a new/different bug with the same symptom. I'm not aware of any other users hitting this yet. Can you create a new issue with more repro details, such as what it says when you hover over the database icon in the bottom right? If there's no database icon, does it repro after opening a particular file? Our parser could be stuck in an infinite loop when parsing a particular file or one of it's dependencies. If you could attach a debugger to that process and provide the call stack for the stuck thread (usually the one with a deep call stack with parsing-related functions) that would help.

sean-mcmanus avatar Apr 10 '18 21:04 sean-mcmanus

@sean-mcmanus I'm on macOS 10.13.4 and also have the same problem. I've also read the release notes for the version you said that resolved this issue (v0.14.6) and the only note related to this bug as I can see is:

Add C_Cpp.workspaceParsingPriority setting to enable using less than 100% CPU during parsing of workspace files.

So this sure seems like the same "bug". The issue is not only that this process takes 100% CPU, but each instance also consumes a lot of memory and there are usually 4 - 5 instances of the very same process, and also they are live for a very long time. Steps to reproduce:

  1. Open a folder containing multiple C++ files with ~2000 lines of code and cpptools extension on
  2. Add a path to include some library (cryptopp for example) in c_cpp_properties.json
  3. Quit VSCode After ~6 hours, there are still instances of the process hogging 100% CPU and ~150MB memory. I haven't set the C_Cpp.workspaceParsingPriority.

1uka avatar May 20 '18 20:05 1uka

@1uka We need more info. What version of cpptools are you using? Which process is using 100% CPU? Are you using a recursive includePath (e.g. with **)? What's the status of the database icon in the bottom right when you hover over it?

Does the bug not repro if you don't modify the c_cpp_properties.json?

sean-mcmanus avatar May 21 '18 08:05 sean-mcmanus

@sean-mcmanus I am currently on v0.17.1 (which is also the version I was when I first had the problem). The process that is using 100% CPU is Microsoft.VSCode.CPP.Extension.darwin. I am not using a recursive includePath (it is a single folder containing only headers, no subdirectories). When I hover over the database icon (which is not always present in the bottom status bar, I can only see it for a short period just after I open the project), it says: "Discovering files". If I remove the c_cpp_properties.json file, the process is still active after I quit VSCode, but it doesn't spend the same amount of resources (both CPU and memory), so I would say it is the same bug, only with mild consequences.

I would be glad to help you further, just point me to the part of the code that is responsible for the search and inclusion of headers (or whatever part of the code you suspect is relevant to this problem).

1uka avatar May 21 '18 13:05 1uka

@1uka This sounds like https://github.com/Microsoft/vscode-cpptools/issues/1960 . That issue has a vsix with a fix. We're working on getting a fixed release out.

sean-mcmanus avatar May 21 '18 18:05 sean-mcmanus

no, #1960 is a Windows-only issue. @1uka, please don't install the vsix from #1960. It won't work on Mac.

bobbrow avatar May 21 '18 18:05 bobbrow

@bobbrow @1uka Ah, okay. Can you attach a debugger to the process using lots of CPU and send us the call stack of the threads that appear to be doing work? This sounds like a new issue. Removing the c_cpp_properties.json will cause recursive includes to activate.

sean-mcmanus avatar May 21 '18 18:05 sean-mcmanus

@1uka just in case, have you seen https://github.com/Microsoft/vscode-cpptools/issues/1816?

antnsi avatar May 21 '18 19:05 antnsi

@antnsi I hadn't seen the issue you referred, but by comparing your sample of the process that is causing your issues I think that the cause is slightly different, though it might be somehow related to my problem.

@sean-mcmanus Here is a sample of the process including the call stack. I haven't got the time right now to fire up GDB, if this is not enough info let me know and as soon as I can I will debug thoroughly.

sample.txt

1uka avatar May 21 '18 21:05 1uka

@bobbrow I don't see any thread doing work in those call stacks.

sean-mcmanus avatar May 21 '18 22:05 sean-mcmanus

@sean-mcmanus I don't either.

bobbrow avatar May 21 '18 23:05 bobbrow

@1uka We have an insiders build you can try which may fix the issue (if it doesn't then it means it's a new bug): https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.17.2-insiders . The official release is planned tomorrow unless we get delayed by finding more bugs.

sean-mcmanus avatar May 22 '18 02:05 sean-mcmanus

@sean-mcmanus @bobbrow Can confirm this is back with a vengeance. It seems like a new issue, it only cropped up after having to close my VS code instance, thereby updating to 0.17.1.

Logs are attached. process-sample.txt

jamesadevine avatar May 22 '18 22:05 jamesadevine

@jamesadevine [UPDATE] We just released 0.17.3 -- does it still repro with that? We fixed some known issues which could cause this.

sean-mcmanus avatar May 22 '18 22:05 sean-mcmanus

@sean-mcmanus I still have this on 1.17.3 on MacOS 10.13.4, attaching process sample. Sample of Microsoft.VSCode.CPP.Extension.darwin.txt

danengelbrecht-king avatar May 23 '18 08:05 danengelbrecht-king

I've got the same issue i.e. CPU > 100% and never going back down with 0.17.3 running on macOS 10.13.4.

rhuanjl avatar May 23 '18 16:05 rhuanjl

@danengelbrecht-king, thanks for the sample. It looks like it is caused by our new recursive include path feature. We are looking at additional ways to improve this. How big is the folder you opened?

bobbrow avatar May 23 '18 21:05 bobbrow

I wouldn't mind so much if the process was spawned at low priority

StephenHillAtWork avatar May 24 '18 10:05 StephenHillAtWork

image I have quit it,but it also uses 99% cpu.

Lingdu0 avatar Jun 01 '18 02:06 Lingdu0

@Lingdu0 Can you try 0.17.4?

sean-mcmanus avatar Jun 01 '18 02:06 sean-mcmanus