5

I'm using grunt to watch my coffeescript files in a towerjs project and recompile them as they change. The configuration for this is generated by towerjs and seems fairly sane. The problem is, that once I start this process I will see it pegging a cpu core (actually, just one hyperthread). If I remove a lot of the paths from being watched I can get it down to around 25% of a CPU, but that is still pretty terrible.

I've found a few references to some known issues and cross-platform inconsistence with the Node's fs API and even the fs.watch in particular. Tried grunt-simple-watch but it did not do any better.

I could setup Guard but it may be fiddlesome to get it working just right and functionally grunt seems to be just fine - I am curious though if anyone else has any other suggestions.

Jeremy
  • 1,198
  • 1
  • 9
  • 16
  • Give the new watch task a try: `npm install grunt-contrib-watch` and add `grunt.loadNpmTasks('grunt-contrib-watch');` to your gruntfile. The Grunt v0.3 watch task traverses & stats files which with a large number of files can get slow but was necessary for system compatibility. The new one will only use inotify if working properly within node. – Kyle Robinson Young Oct 17 '12 at 18:47
  • @KyleRobinsonYoung that worked, thanks! submit as answer? – Jeremy Oct 18 '12 at 02:02
  • Ha sure. If you run into any issues with it feel free to submit an issue on github. :) – Kyle Robinson Young Oct 18 '12 at 04:11

1 Answers1

4

Give the new watch task a try: npm install grunt-contrib-watch and add grunt.loadNpmTasks('grunt-contrib-watch'); to your gruntfile. The Grunt v0.3 watch task traverses & stats files which with a large number of files can get slow but was necessary for system compatibility. The new one will only use inotify if working properly within node.

Kyle Robinson Young
  • 13,732
  • 1
  • 47
  • 38