guard / listen

The Listen gem listens to file modifications and notifies you about the changes.

Home Page:https://rubygems.org/gems/listen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: OSX optimizations

e2 opened this issue · comments

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:

  1. Listening on OSX is recursion-only
  2. 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
  3. Listen doesn't keep full directory metadata (yet), so OSX snapshot comparing is done recursively and too often
  4. The HFS filesystem uses 1-second accuracy, so Listen uses MD5 hashing to accurately detect whether a change occured or not
  5. Case insensitivity causes certain issue on OSX (see rb-fsevent Readme)

Why this hasn't been fixed yet:

  1. 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
  2. Listen is quite complex, and some groundwork was necessary to allow for changes (done in Listen 3.0)

What to do to improve things:

  1. Research if file-changes mode in rb-fsevent is still really as bad nowadays
  2. Implement full directory metadata (basically just extra fstat() fields in Listen::Record)
  3. Implement an "invalidations" layer (translating low-level adapter events into "what needs to be refreshed" in Listen::Record)
  4. Then, implementing OSX specific optimizations should be much, much easier

References, details, related issues: