-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Version 0.10.9 (0.10.9) using 90% cpu. #3222
Comments
Seeing the same thing. |
Mine runs at 120%+ (not sure about that math, but that's what it says). Fan starts spinning constantly until I kill the VSCode window. Interestingly it seems to happen on one project in particular (a large Node project with lots of files and |
Every core is 100% |
In my tasks.json, "isWatching" was set to true. When I changed this to true, cpu usage has gone down. |
@dbaeumer any ideas? |
@bpasero watching tasks (expecially tsc) are not executed in the Electron Helper. They are executed in a separate node environment (e.g. what is specified in the tsc shell script). What could have an impact is if a tasks produces a lot of output which will cause constant scanning of that output. But the described issues doesn't sound like this. |
Can people here open the output window to see if we spam the output when this happens? |
Closing as duplicate of #774 which seems to be caused on Mac when having a large folder in the workspace. |
Since i cannot reproduce the high CPU use for a large folder this must be something else. |
@ransanjeev @fhelje @bmoeskau is one of you able to do a little experiment? I am speculating that maybe our library for file watching is failing. The steps would be:
For me (since fsevents works ok), I get this: If something goes wrong, I would expect fsevents to print as undefined. In that case, can you put another console.log inside the try/catch block of line 7 to see what the error is loading that native module? Thanks! |
@bpasero Looks like your guess is correct in my case. Anything else you want me to check? |
This is the error that got swallowed by the require: Error: Module version mismatch. Expected 47, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:440:18)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/Brian/Projects/vscode/node_modules/chokidar/node_modules/fsevents/fsevents.js:9:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32) |
@bmoeskau wow, this error is weird though, if I understand it correctly it means the native library A couple of further thoughts:
Thanks for taking the time! |
Oh, interesting. I did not consider mentioning that I'm actually running Node 5.6.0 locally. I Moe in ~/Projects/vscode
± |master ✓| → ./scripts/code.sh
fsevents:
{ [Function: watch]
getInfo: [Function: getInfo],
FSEvents: [Function: FSEvents],
Constants:
{ kFSEventStreamEventFlagNone: 0,
.... However, that said, there appears to be no difference in CPU usage either way. Even with Again note that for me this only happens for one very large Node project folder that contains a bunch of repos, each with its own |
I was suspicious and tried to open a very large folder (all of chrome sources actually) with Code on Mac and did not notice any CPU spikes like that. Is there any chance I could setup a folder like yours if you share the (open source?) repositories? |
Unfortunately the main codebase is private, but what I can do is try replicating only the dependency tree by creating a new folder structure and copying in the package.json files we use and |
Great! |
This still seems to me to be a simple issue of file count. The total file count for everything under the root folder is something like 500k files (well over 2Gb). I have one repo in particular that contains 28 sub-projects, each with its own I didn't have time to identify the threshold between "normal" startup vs when the CPU hit becomes noticeable. I'm also not sure if the performance issue is linear, or if it simply drops off a cliff from which it can't recover at some point. My original project folder with all files never seemed to recover the CPU, even after 30+ minutes. I admit that this is a lot of files, but it's the new reality with npm if you have a large project. Also I've been loading the exact same project into Sublime, Textmate etc. with no issues. In fact I downloaded Atom today just to see and it also loads just fine with barely a blip in CPU on startup. So this definitely seems specific to VS Code. |
@bmoeskau I am still puzzled why the size of a folder could cause this. to verify, can you remove the if-statement in https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/files/electron-browser/fileService.ts#L48 and then recompile vs code locally and run it out of the sources on this large folder? it would be interesting to know if this issue can be solved by adding "node_modules" to the list of ignored folders by the watcher. Meanwhile I have opened paulmillr/chokidar#447 to see if chokidar has an idea. |
@bmoeskau very sorry, I realized my instructions were not good and I have updated them. the output we see on the console is coming from a different use of chokidar, not the one from VS Code. the new instructions are slightly different but not much and we can see if chokidar is running by looking at the developer console within Code. Can you retry please? Meanwhile I have talked to the chokidar developers and got confirmation that chokidar does 1 full scan of the directory on startup. I can reproduce this, however my CPU goes down after a while. Are you saying that CPU stays high forever and never calms down? |
Based on the updated instructions I still see " fsevents: true" in the bash command line output, but in the UI developer console I don't see anything after the "listening on port 5870" message. I've tried console logging from within various instance methods of As I mentioned previously, depending on the total number of files, I do see the CPU go down after a while too, but the more files there are, the longer this takes. I measured a very clear increase in CPU thrashing time each time I added a batch of 5k files to the project root. As an additional data point I also added the "real memory" column to the activity monitor output and (maybe as expected) memory use also climbs dramatically along with CPU use while this occurs, and then also drops to normal when it recovers. |
@bmoeskau could it be that after your change you did not recompile? we typically first run |
I must have missed that step. Yes I do see the "fsevents: true" now. I also verified that this line is running many, many times on startup:
|
@bmoeskau thanks for checking, I also got confirmation from another user that the native library indeed is not the issue. He saw an interesting pattern though: the process that runs the watcher (the one with high CPU/MEM use) climbs to ~1 GB and then quits and restarts. This is because the process runs out of memory, crashes and VS Code decides to just start it again because Code without watcher is pretty bad. Can you check if this also happens for you here? This would explain why the process never recovers. Btw two things pushed to master so far, maybe you want to give it a try running "out of the sources":
|
Ah! I had reduced my project file count such that the CPU would recover after a couple of minutes while testing things out, but after your last comment I added a huge folder back into the project. Now that I'm logging from the code I am seeing the same pattern you mentioned -- memory climbs to around 1.5Gb, hovers there for a minute, then drops down to a few hundred Mb. Each time that happens I get the "fsevents: true" logged again, so obviously that process is restarting as you mentioned. That definitely explains why the CPU never recovers beyond a certain file count. I downloaded the latest from master, and first ran it as-is just to make sure it didn't get fixed somehow. The CPU problem continued unchanged. Then I added this to my user settings file: // Place your settings in this file to overwrite the default settings
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true
}
} Voila, now the CPU spikes just for a second or two on load and then immediately drops to 0. Seems like probably a good default setting... :) |
We found out about the issue and here is what happens:
We also verified that chokidar was not falling back to polling. The fixes for March are:
For the future, we are looking into #3998 |
On Mac 10.11.3 (15D21), one of the electron helper is constantly running at 90% cpu.
The text was updated successfully, but these errors were encountered: