-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
Improved grunt express watcher #10650
Conversation
Gruntfile.js
Outdated
@@ -70,7 +70,8 @@ const configureGrunt = function (grunt) { | |||
'content/themes/casper/assets/js/*.js' | |||
], | |||
options: { | |||
livereload: true | |||
livereload: true, | |||
interval: 5007 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest, is there something special about 5007
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allouis it's the example value given in the docs https://github.com/gruntjs/grunt-contrib-watch#why-is-the-watch-devouring-all-my-memorycpu
@gargol I would suggest something smaller than 5secs? Seems like it could make development a bit annoying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find any reference in the 'old node pooling default' for this 5007 magic number. Will dig around, but agree on 5s being a bit too long. Maybe 500ms would be better? Just enough to not notice it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
500ms sounds more sane as long as we still see the CPU usage benefits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Experimented with a 500ms interval, the CPU usage for my machine was under 1%. Think it's good enough result. The delay is barely affecting the dev flow because restart for express server or rebuild of the client still takes a couple of seconds.
6c050e6
to
4a392e0
Compare
closes TryGhost#9718 - fs.fileWatch that is used internally by 'gase' in 'grunt-contrib-watch', is having 100ms pooling default (https://github.com/shama/gaze/blob/07828a684566b6d4844f12b747e74e376fa31744/lib/gaze.js#L36). This is causing hight CPU usage for large amount of files. - As suggested in https://github.com/gruntjs/grunt-contrib-watch#why-is-the-watch-devouring-all-my-memorycpu the watch interval was set to higher 500ms because the recommended default of 5s (gruntjs/grunt-contrib-watch#145 (comment)) was visible in the development flow
4a392e0
to
cea6b6c
Compare
closes #9718
@kevinansfield after starting to consider to move to suggested https://github.com/BuddyBuild/bb-grunt-watch that substitutes Gaze watcher with Watchman. Found the interval option that looks like a good enough solution without having to worry about other bugs that could happen in the new package (it wasn't too active, so had some doubts about it). Would love to hear what you think and check how's the performance on non-Linux environment. For me, it dropped from 7% of CPU load to almost nothing after this change.