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

Improved grunt express watcher #10650

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

naz
Copy link
Contributor

@naz naz commented Apr 1, 2019

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.

@naz naz requested a review from kevinansfield April 1, 2019 11:06
Gruntfile.js Outdated
@@ -70,7 +70,8 @@ const configureGrunt = function (grunt) {
'content/themes/casper/assets/js/*.js'
],
options: {
livereload: true
livereload: true,
interval: 5007
Copy link
Contributor

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?

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

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.

@naz naz force-pushed the improved-grunt-express-watcher branch 2 times, most recently from 6c050e6 to 4a392e0 Compare April 2, 2019 06:14
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
@naz naz force-pushed the improved-grunt-express-watcher branch from 4a392e0 to cea6b6c Compare April 2, 2019 06:18
@naz naz merged commit cea6b6c into TryGhost:master Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

grunt dev has high CPU usage when idle
3 participants