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

File watching optimization #1269

Closed
matuszeman opened this issue Oct 15, 2019 · 3 comments · Fixed by #1320
Closed

File watching optimization #1269

matuszeman opened this issue Oct 15, 2019 · 3 comments · Fixed by #1320

Comments

@matuszeman
Copy link

Garden seems to watch all files under project folder (ref: garden.ts#L287) which are then filtered out depending on e.g. module settings (ref: watch.ts#L172). This causes an issue with larger projects and the process runs out of memory after a while.

Could we discuss best way how this could be optimized please?

@matuszeman
Copy link
Author

Here are some options which came to my mind:

@edvald
Copy link
Collaborator

edvald commented Oct 16, 2019

Thanks a lot for filing the issue @matuszeman. I've done a little bit of exploration on the matter.

We can technically introduce an optimization when modules.include is specified in the project config, and includes only specific directories (i.e. some/directory/**/*). But unfortunately any more open-ended pattern in that list (e.g. *.js or anything else without a specific directory path) would require us to look at the whole project and post-filter, like we currently do. So users would need to be quite specific for us to be able to avoid watching the whole project root, and I'm not sure that's reasonable in terms of user experience.

If you specify exclude filters, there's still really no way for us to avoid watching the whole project root, because the list of directories to watch can always change, so we couldn't be aware of new directories if they're not already under the watched directories when we start the Garden process.

So I think your first suggested option is the only viable one to solve your issue (unless I'm missing a better idea, which I won't rule out :P). By default I resist adding config options, but I don't really see a way around it here, since the include/exclude filters can't sufficiently inform us what to watch except in very specific cases.

@matuszeman would you like to have a go at implementing a watchPaths option, or would you like to wait until we find time to add it? We'd love to help you contribute if you're up for it :)

@matuszeman
Copy link
Author

matuszeman commented Oct 17, 2019

@edvald I played with it yesterday a bit, it's not tested at all, I don't even know if this approach helps the problem. I'd need to run it on the project I had a issue with before. Have a look.

I wanted to stay consistent with other include / exclude configuration options garden already has and I think it makes sense to leverage chodikar ignored option for exclude here.

edvald added a commit that referenced this issue Nov 6, 2019
This basically relies on optimizations already implemented in chokidar,
the library we use for file watching. Hopefully this can solve the
excessive CPU/RAM usage some users have reported.

Closes #1269
edvald added a commit that referenced this issue Nov 7, 2019
This basically relies on optimizations already implemented in chokidar,
the library we use for file watching. Hopefully this can solve the
excessive CPU/RAM usage some users have reported.

Closes #1269
edvald added a commit that referenced this issue Nov 8, 2019
* fix(watcher): use exclude options to optimize file watching

This basically relies on optimizations already implemented in chokidar,
the library we use for file watching. Hopefully this can solve the
excessive CPU/RAM usage some users have reported.

Closes #1269
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants