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
Optimistic caching increases CPU load on idle a lot in huge codebases #9726
Comments
What version of Meteor are you using? In Meteor 1.5.1, we made a change to avoid using native file watchers unless a file had been changed at least once, and instead use only If you're not on Meteor 1.5.1 (at least) yet, then this issue is a good reason to consider running If you're using a more recent version of Meteor, my guess is that the polling is happening too frequently given the number of files being watched, even though it's only happening once every five seconds for each file. That lines up with your observation of high CPU usage, since polling is CPU-intensive, whereas native file watching is only file-descriptor-intensive. To help diagnose the problem, you can set METEOR_WATCH_POLLING_INTERVAL_MS=10000 (or even higher) to poll less frequently, while leaving |
I'm using v1.6.1 but the issue exists since about v1.4 |
Ah yeah, we were doing the polling in 1.4.x as well, so that behavior would be the same before and after Meteor 1.5.1. Thanks for the update. What were the env variables you used for the 8sec rebuild times? |
|
I've created a reproduction in this repository: https://github.com/maxnowack/meteor-file-watching-performance If you run |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed it has not had recent activity. |
At TeamGrid, we have a huge codebase with a lot of npm dependencies. The build process takes long, but I think that is pretty normal for an application of that size.
When the build is done and the application is idling, the CPU load is still very high (~100%).
This only occurs in a dev environment and not in production. So it's a minor issue for us.
The downsides only were a hot macbook and a short battery life 😉
We have this strange behavior for a long time and I didn't had the time for debugging what exactly is going on after the build.
I've analyzed the issue a few days ago and posted my result in another issue.
Today I've dived a little bit deeper and figured out that Meteor watches a lot of files with strange paths which aren't exist. For example:
/ … /client/views/analytics/node_modules/babel-plugin-styled-components.html
It seems that meteor is watching files for every npm module, with every registered file extensions in every folder and sub folder of our application. Regardless wether the file exists or not.
In huge codebases like ours, this results in a high cpu utilization, since every file is polled with a specific interval.
If I set
METEOR_DISABLE_OPTIMISTIC_CACHING=1
, Meteor doesn't watch these files and the cpu load stays normal. But I'm not sure what exactly the environment variable disables and what the downside are.What exactly is the intent of the optimistic caching?
I've seen this behavior on macOS . I haven't tested, if the issue also exists in other environments.
The text was updated successfully, but these errors were encountered: