discourse/config/environments
David Taylor 59c239d85c
DEV: Speed up requests in development mode (#12890)
On every request, Rails checks to see whether any ruby code has been changed on the filesystem. The default FileUpdateChecker does this by iterating over every file on the autoload_paths and comparing its modified-time.

In Discourse, our autoload path of `/app` includes the `/app/assets` directory, and therefore thousands of non-ruby files (e.g. node_modules). This makes the `Dir["/app"]` call very slow (>100ms in my case). On my machine, every Rails-handled request spends around 150-200ms in the FileUpdateChecker. This commit introduces a couple of changes to completely eliminate this wasted time:

- The `/app/assets` directory is excluded from the file watchers. For me, this cut the time spent in the file_watcher to around 50-100ms

- Switches our development config to use the `EventedFileUpdateChecker`, which makes use of the `listen` gem to subscribe to os-specific notifications of changes. This completely removes the `FileUpdateChecker` from the critical path

On my machine, topic_list requests now return in around 80ms (previously >200ms). Live code reload still works as it did before
2021-04-29 15:40:55 +01:00
..
development.rb DEV: Speed up requests in development mode (#12890) 2021-04-29 15:40:55 +01:00
production.rb FIX: Do not dump schema during production database migrations (#12785) 2021-04-21 16:26:20 +01:00
profile.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
test.rb REFACTOR: Move javascript tests inside discourse app 2020-10-02 11:29:36 -04:00