Closed timholy closed 7 years ago
Maybe consider the approach over here: https://github.com/emcrisostomo/fswatch
It uses the macOS File System Events api, and it seems to be pretty fast. I use fswatch to trigger tests automatically when editing code.
If we could come up with a simple, cross-platform file watching API and implement it efficiently on each platform, that would be ideal. Could use the macOS File System Events api on macOS.
We have a simple, cross-platform file watching API which should be as efficient as possible on each platform (it's lower overhead than fswatch, for instance). Note that the File System Events API only supports watching directories, so anything else will use kevent instead.
Note that mtime is truncated to the nearest second (https://stackoverflow.com/questions/18403588/how-to-return-millisecond-information-for-file-access-on-mac-os-x-in-java/18404059#18404059), so you're seeing measurement error, not real timing differences. This'll be fixed by Apple's move to APFS.
Over at Revise we collected some data suggesting that
watch_file
returns with latencies on the scale of ~1s on OSX, whereas on Linux it's a few ms. I haven't found any suggestions of long-latency polling when I search for libuv, so I'm wondering where this comes from.See comment thread starting at: https://github.com/timholy/Revise.jl/pull/22#issuecomment-315534927
(I'm aware this may come from the OS or from libuv, but I thought I'd ask...)