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

grunt dev has high CPU usage when idle #9718

Closed
kevinansfield opened this issue Jul 5, 2018 · 3 comments · Fixed by #10650
Closed

grunt dev has high CPU usage when idle #9718

kevinansfield opened this issue Jul 5, 2018 · 3 comments · Fixed by #10650
Assignees
Labels
bug [triage] something behaving unexpectedly server / core Issues relating to the server or core of Ghost

Comments

@kevinansfield
Copy link
Member

kevinansfield commented Jul 5, 2018

Issue Summary

grunt dev consistently uses around 20% CPU (as measured by Activity Monitor) when idle without a Ghost restart or Ember rebuild happening.

This isn't particularly noticeable unless developing whilst on battery power.

To Reproduce

  1. Run grunt dev
  2. Wait for the ember build to finish and everything to settle
  3. Observe the grunt task in Activity Monitor

The same CPU usage is evident when running grunt dev --server which doesn't start a background ember process.

Commenting out the express watcher drops idle CPU usage to 0.5% or less.

Technical details:

  • Node Version: 8.10.0
  • Browser/OS: macOS
  • Database: SQLite
@kevinansfield kevinansfield added bug [triage] something behaving unexpectedly tools labels Jul 5, 2018
@kevinansfield
Copy link
Member Author

This appears to be due to how grunt-contrib-watch handles filesystem watching and the large number of server files.

watchman is a good tool for very efficiently watching files and running tasks (as used by ember-cli) but I haven't found any grunt integration (although there is a gulp integration).

Short-term a workaround may be to add a --no-server-watch flag to disable the watch process but that would only be useful when doing client-only development.

kevinansfield added a commit to kevinansfield/Ghost that referenced this issue Jul 9, 2018
refs TryGhost#9718
- running `grunt dev --no-server-watch` will skip watching server and theme files
- reduces idle CPU usage from 20% to 0%
- useful for client-only development to save battery power
kevinansfield added a commit that referenced this issue Jul 9, 2018
refs #9718
- running `grunt dev --no-server-watch` will skip watching server and theme files
- reduces idle CPU usage from 20% to 0%
- useful for client-only development to save battery power
@kirrg001 kirrg001 added the server / core Issues relating to the server or core of Ghost label Aug 19, 2018
@kirrg001 kirrg001 added the help wanted [triage] Ideal issues for contributors to help with label Jan 2, 2019
@ErisDS
Copy link
Member

ErisDS commented Jan 2, 2019

Today 26d567b was done, which is related to this.

I think this issue needs prioritising. Every time I run grunt dev my laptop cooks.

@kirrg001 kirrg001 removed the help wanted [triage] Ideal issues for contributors to help with label Jan 2, 2019
@naz naz self-assigned this Apr 1, 2019
naz added a commit to naz/Ghost that referenced this issue Apr 2, 2019
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 closed this as completed in #10650 Apr 2, 2019
@naz
Copy link
Contributor

naz commented Apr 2, 2019

In case the issue with high CPU usage resurfaces next optimization would be switching to proposed above watchman for file change tracking. Possible candidate for this - https://github.com/BuddyBuild/bb-grunt-watch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly server / core Issues relating to the server or core of Ghost
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants