Skip to content
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

Gulp 4.0 - gulp.watch high CPU usage after some time #2245

Closed
sryze opened this issue Oct 20, 2018 · 8 comments
Closed

Gulp 4.0 - gulp.watch high CPU usage after some time #2245

sryze opened this issue Oct 20, 2018 · 8 comments

Comments

@sryze
Copy link

sryze commented Oct 20, 2018

What were you expecting to happen?

I expect gulp.watch to not use a lot of CPU while watching files.

What actually happened?

CPU usage is normal (low) after starting a watch task, but after some time passes it becomes very high, I don't know why. I have to kill the node.js process and start gulp again.

I only noticed this on Windows. I haven't had such issue yet on Linux.

Please post a sample of your gulpfile (preferably reduced to just the bit that's not working)

gulp.task('watch-default', () => {
    gulp.watch(handlebarsUserTemplates, gulp.parallel('handlebars-user'));
    gulp.watch(handlebarsAdminTemplates, gulp.parallel('handlebars-admin'));
    gulp.watch(jsFilesToMinify, {cwd: srcRoot}, gulp.parallel('minify-js'));
    gulp.watch(cssFilesToMinify, {cwd: srcRoot}, gulp.parallel('minify-css'));
    gulp.watch(webRoot + '/somepathhere/*.css', {cwd: srcRoot}, gulp.parallel('minify-other-css'));
});

gulp.task('watch', gulp.series('default', 'watch-default'));

What version of gulp are you using?

4.0.0

What versions of npm and node are you using?

npm 6.4.0
node 8.11.1

@phated
Copy link
Member

phated commented Oct 20, 2018

Windows uses polling, that's always going to be the case for every watcher.

@phated phated closed this as completed Oct 20, 2018
@sryze
Copy link
Author

sryze commented Oct 21, 2018

Why? Windows has an API for watching files, why not use it?

@sryze
Copy link
Author

sryze commented Oct 21, 2018

What about the sudden jump in CPU usage over time? That looks like a bug to me.

@yocontra
Copy link
Member

We use this library for file watching https://github.com/paulmillr/chokidar - if you think there is a bug with it you can open a ticket there (or check if one has already been opened). gulp.watch is a simple wrapper around that library.

@sryze
Copy link
Author

sryze commented Oct 31, 2018

OK, thanks.

@sryze
Copy link
Author

sryze commented Nov 13, 2018

I noticed the same issue today on macOS (so it's not Windows specific), at some point gulp just goes crazy, I'm not sure if something triggers it or gulp just eats slightly more CPU over time leading to this state:

gulp-cpu-problem

@appideasDOTcom
Copy link

appideasDOTcom commented Feb 7, 2020

This is also true on macOS (as noted by sryze), and the issue is not imagined.. I left a gulp-watch process running for a couple of days, noticed that my fans were spinning when the computer should have been idle, and saw that gulp was consuming > 300% CPU. After killing and restarting gulp and a cautionary reboot, after only a couple hours, CPU usage by gulp has climbed to 90%.

I looked at the issues on the chokidar github page, but don't see anything related to CPU overutilization. Is this most definitely an issue with that library and it needs to be reported there? This is definitely a problem.

I don't know if this was an issue before I "upgraded" to Catalina. I've been using gulp-watch for quite a long time and have never had any issues that caused me to feel compelled to check its CPU usage, and I've left gulp-watch running for weeks at a time. If this isn't a reasonably new issue, the symptoms certainly weren't apparent until recently.

The issue is over a year old, and clearly has no resolution.

@yocontra
Copy link
Member

yocontra commented Feb 7, 2020

@appideasDOTcom If you have issues with the file watcher you can file them here: https://github.com/paulmillr/chokidar. Make sure you are on the latest of all sub-dependencies first, chokidar has published some CPU fixes as of October.

I'm going to lock this thread since this is not the right spot for these reports.

@gulpjs gulpjs locked as off-topic and limited conversation to collaborators Feb 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants