WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#44241 closed defect (bug) (fixed)

Increase the interval used by grunt watch to reduce CPU usage

Reported by: jeremyfelt Owned by: jeremyfelt
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description (last modified by jeremyfelt)

grunt watch appears to use around 40% of my CPU when sitting idle. By default, grunt-contrib-watch uses a 100ms interval. Several of the groups in our _watch config specify an interval of 2 seconds, but others defer to the default.

In my local environment (non-VM), if I add options: { interval: 2000 } to the config, colors, test, and phpunit groups, grunt watch CPU usage stays consistently within 2 to 5% at idle.

See this related discussion on the grunt-contrib-watch project

If I change all configurations to 1 second, grunt watch CPU usage stays at around 9%.

I'm attaching a patch that applies only the interval addition to each of the other groups.

Attachments (2)

44241.diff (879 bytes) - added by jeremyfelt 4 years ago.
44241.2.diff (1.1 KB) - added by netweb 4 years ago.

Download all attachments as: .zip

Change History (6)

@jeremyfelt
4 years ago

#1 @jeremyfelt
4 years ago

  • Description modified (diff)

@netweb
4 years ago

#2 @netweb
4 years ago

  • Milestone changed from Awaiting Review to 5.0

In 44241.2.diff I've moved options: { interval: 2000 } to the top-level option that applies to all the _watch sub-tasks rather than adding it to each sub-task, all watch tasks will default to this 2s value.

Locally my mid-2014 MacBook Pro sees CPU usage from grunt watch sit at ~4%

#3 @jeremyfelt
4 years ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 43324:

Built/Test Tools: Increase grunt watch interval on all files.

Significantly reduces Grunt's CPU usage when grunt watch is in an idle/watching state.

Props netweb.
Fixes #44241.

#4 @jorbin
3 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.