Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce file watching overhead from Rails (#555)
I noticed that we were spending a lot of time doing file IO operations coming from the listen gem. After some investigation, these appear to be coming from Rails' own file watching mechanisms, which spawn threads that will check if views are being modified to trigger rendering or reloading in the background. We currently don't have any functionality that depends on views being rendered. Additionally, the LSP already watches files, so even if we wanted to trigger view rendering, the language server would be in a better position to dictate which views to reload. This PR shuts down view file watching, which eliminates a good chunk of overhead that we were seeing in the Tapioca add-on. ### Approach I initially tried setting `config.file_watcher` to a no-op implementation, but that doesn't work. The reason is because, by the time we start running `server.rb`, Rails has already registered the file watchers and its callbacks, so changing the config won't have any real effect. The approach I took is to clear the file system hooks array from the Action View path registry. Those hooks are the ones that build the file watchers, spawning listen threads. By clearing that array, I can see the overhead disappear in my profiles.
- Loading branch information