JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.43k stars 5.45k forks source link

Polling appears to have long latency on OSX #22822

Closed timholy closed 7 years ago

timholy commented 7 years ago

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...)

rsrock commented 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.

StefanKarpinski commented 7 years ago

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.

vtjnash commented 7 years ago

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.

vtjnash commented 7 years ago

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.