-
Notifications
You must be signed in to change notification settings - Fork 12k
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
ng serve uses a lot of CPU % #2748
Comments
I experienced the same thing here. Sitting idle, with nothing changing, approximately one CPU core burns 100% in |
|
Not working on Windows. |
installing fsevents solves this issue on mac. Thanks @mseemann |
I don't think this issue should be closed. Manually installing fsevents can not be the longterm solution. |
Does it make sense to add fsevents to the dependencies of @angular/cli? |
@mseemann Thanks a lot! |
fsevents only work for mac, but what about windows and linux, in my case what is literally eating is my ram, ng process consumes 1.2GB which i consider a lot for a process like that one |
Jose, please keep in mind that node is GC'd so it will happily use
available memory and won't collect aggressively until pressured by the OS
which doesn't happen if you have a lot of RAM ;-)
So unless ng is eating all your memory and your OS starts paging other
stuff you should be fine.
…On Wed, Jun 7, 2017 at 5:38 PM, Jose Berrocal ***@***.***> wrote:
fsevents only work for mac, but what about windows and linux, in my case
what is literally eating is my ram, ng process consumes 1.2GB which i
consider a lot for a process like that one
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2748 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAH8N0Lg5SAAoyQVRdvVPBVsaZNKX8wiks5sBrX2gaJpZM4KYq8B>
.
|
have you tried using task manager to lower the affinity / priority of the process? |
@Almenon 's solution to lower the affinity/priority of the process has been working for me. However, it is kinda tedious to do every time I run If I don't manually lower the affinity/priority of the process, my CPU usage is at 99%. Running on windows 8 |
@rryter also, if I add it to my package.json every build not happening under Mac OS will fail:
|
I ended up adding the following little script to my const isMac = /^darwin/.test(process.platform);
if (isMac === true) {
const process = require('child_process');
process.execSync('npm install fsevents --no-save');
} |
Running under debian, using the |
this is very useful |
Can somebody explain why |
What is solution on linux ? |
@alanchavez88 fsevents allows the process to subscribe to File System EVENTS. I can only assume angular-cli has logic built in that makes use of this if it's available. This means that angular-cli no longer has to poll the actual files to see if changes occurred, it simply waits for OSX to notify it of a file change. EDIT: Just to confirm, fsevents calmed down my CPU as well. No more hand-warmer. |
@alanchavez88 further to @PyroSA reply: it might have to do with chokidar, which is used by karma and the @angular/compiler-cli for watching files for changes. Chokidar is a wrapper around different ways to watch for files and fsevents is one of those. Chokidar has fsevents as an optional dependency - if it's present it will use it otherwise it has fallbacks. So if nothing else installs fsevents, chokidar goes with one of the alternatives and that eats up CPU because of polling. https://www.npmjs.com/package/chokidar#performance You can add "fsevents" to "optionalDependencies" in package.json to persist this change. |
For anyone running on Linux, I've been running my You can try: This should also work on other *NIX OS's |
Increasing the polling interval is enough to calm down the watching and will work even on non *nix. I helped our Windows guys with their overeager virus scanners in the past. |
same issue here
|
Still seems to be an issue with CLI v 5.0.0. Fixed with fsevents. |
This is still definitely an issue on linux in CLI 6.2.2
This is a major issue when running within a Vagrant machine for example. When I run this on my host machine (OSX) everything if fine with fsevents, but using poll in linux on the VM, both cores will steadily be at 80-90%+ usage. |
@filipesilva Any chance at getting this issue re-opened? It still seems to be an issue. I had experienced it a few months ago on an older version of CLI and Angular but just finished doing a complete upgrade in the hopes this issue would be resolved in later versions. Sadly it is not. |
In my other custom Webpack configs for other watchers, I normally have
and that works great within Vagrant, without much CPU usage. Based on what I'm seeing in this repo when searching for |
With some local exploration, I've found that adding the following to the watchOptions in the common webpack config resolved CPU usage issues in a Vagrant setup and allowed or 1 second polling without high CPU usage.
With that, instead of adding more flags for what to put into watchOptions, it'd be great to be able to specify the whole watch options block instead of just the poll option. Just in case this causes issues for other setups. I can look into setting up a PR but it may take a while as I familiarize myself with the process for this project. |
Hopefully the |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Mac OSX El Capitan
Versions.
angular-cli: 1.0.0-beta.17
node: 5.7.1
os: darwin x64
angular-cli uses about 85% CPU when I only use ng serve during development, also when I'n not changing code but just use the webapp in a browser.
The text was updated successfully, but these errors were encountered: