Skip to content

How to Choose a Monitor

Enrico Maria Crisostomo edited this page Aug 27, 2014 · 1 revision

fswatch already chooses the "best" monitor for your platform if you do not specify any. However, a specific monitor may be better suited to specific use cases. Please, read the Monitors page to get a description of all the available monitors and their limitations.

Usage recommendations are as follows:

  • On OS X, use only the FSEvents monitor (which is the default behaviour).
  • On Linux, use the inotify monitor (which is the default behaviour).
  • If the number of files to observe is sufficiently small, use the kqueue monitor. Beware that on some systems the maximum number of file descriptors that can be opened by a process is set to a very low value (values as low as 256 are not uncommon), even if the operating system may allow a much larger value. In this case, check your OS documentation to raise this limit on either a per process or a system-wide basis.
  • If feasible, watch directories instead of watching files. Properly crafting the receiving side of the events to deal with directories may sensibly reduce the monitor resource consumption.
  • If none of the above applies, use the poll monitor. The authors' experience indicates that fswatch requires approximately 150 MB or RAM memory to observe a hierarchy of 500.000 files with a minimum path length of 32 characters. A common bottleneck of the poll monitor is disk access, since stat()-ing a great number of files may take a huge amount of time. In this case, the latency should be set to a sufficiently large value in order to reduce the performance degradation that may result from frequent disk access.
Clone this wiki locally