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
dev-mode file change watching is CPU-intensive #2135
Comments
One more observation:
|
→ node -v |
FWIW, this came up recently. MeteorDG is aware of it. Discussion: https://groups.google.com/forum/#!searchin/meteor-core/cpu$20usage/meteor-core/z4by8audkVw/AX_IPgC_ms4J |
thanks @timhaines, useful context. before closing i'd like to have someone on meteor confirm it's only in dev env? |
@bdefore In that thread, David Glasser who works for Meteor says 'This only affects dev mode, since of course meteor run is not designed for production use.' |
This is a known issue. The Node built-in file watching APIs are buggy (we used to use them but then they started crashing) and we'd like to do something better. The Atom editor folks have a new file watching package but it doesn't quite work for us; if atom/node-pathwatcher#24 is addressed I'll look into switching to it. |
@glasser Do you already know https://github.com/shama/gaze? It looks very promising and is used by grunt and gulp. |
@sanjo I hadn't seen that, thanks. I'm not going to have time to look into this before 0.9.0 but hopefully once that's out I can look into it... my laptop battery would appreciate it :) |
I have done a basic integration of gaze. I replaced the watcher that watches for file changes to restart the app. It reduced the idle CPU usage of my medium size Meteor app from 25.5% to 0.8% on a Intel Core 2 Duo with 2.4 GHz with Mac OS X 10.9.4. devel: https://github.com/Sanjo/meteor/tree/gaze |
That looks like a good start! I would want it to only watch the files in our WatchSet data structure, though, instead of every file in the tree. It also looks like there's no way to tell Gaze "hey, this is the expected hashes of these files, you should fire immediately if they've already changed". We've learned the hard way that there are race conditions if you don't do that; many of the watching methods fail to detect changes that are very soon after the watch started, or between the use of the file by the compiler and the beginning of the watch. (And we can't start the watch before the build, because we won't know ahead of time which files to watch: eg, we need to watch package source that isn't physically inside the app too.) |
I also tried to integrate gaze into the existing Watcher first, to make it behave exactly the same. But it doesn't work correctly yet. I did the other approach to save time, because I only wanted to see the impact of the switch. Here is the branch: https://github.com/Sanjo/meteor/tree/gaze-full. |
Looks like pathwatcher did drop their stderr spamming today. |
Awesome. Thanks for fixing this. :-) |
This activity log has taught me not to mention an issue in a commit message until I'm ready to push it. Sorry for the noise! |
I noticed a significant performance hit when I dropped ~800 image files into the public folder of a Meteor 0.8.1.1 test project. On my dev machine (a 2011 Macbook Air), running 'mrt' or 'meteor' would cause CPU pegging, regardless of having any clients open. Activity monitor reported in the range of 20-40%.
Reproduction steps:
Some further observations:
For now, this means I'll have to host my images outside of the Meteor project.
The text was updated successfully, but these errors were encountered: