Feature request: OSX optimizations
e2 opened this issue · comments
Cezary Baginski commented
Basically, Listen is a huge workaround for a lack of decent file monitoring on OSX.
Poorly performing scenario: watching a large project with a frequently changing log file in the project root may cause the whole project to be scanned unnecessarily every time there's a change. And symlinks can increase the overhead exponentially (currently warnings are shown).
Reasons for poor performance:
- Listening on OSX is recursion-only
- OSX reports only directories (because AFAIK reporting file changes generates too many events - see rb-fsevent Readme), so Listen has to keep an in-memory filesystem snapshot and compare directories recursively during changes
- Listen doesn't keep full directory metadata (yet), so OSX snapshot comparing is done recursively and too often
- The HFS filesystem uses 1-second accuracy, so Listen uses MD5 hashing to accurately detect whether a change occured or not
- Case insensitivity causes certain issue on OSX (see rb-fsevent Readme)
Why this hasn't been fixed yet:
- I (@e2, the current maintainer) don't have OSX (I only use Linux), so I have no sane way of safely improving and testing changes on OSX
- Listen is quite complex, and some groundwork was necessary to allow for changes (done in Listen 3.0)
What to do to improve things:
- Research if file-changes mode in rb-fsevent is still really as bad nowadays
- Implement full directory metadata (basically just extra fstat() fields in Listen::Record)
- Implement an "invalidations" layer (translating low-level adapter events into "what needs to be refreshed" in Listen::Record)
- Then, implementing OSX specific optimizations should be much, much easier
References, details, related issues: