Any interest in WatchService based on MacOS FSEvents?
Alan Bateman
Alan.Bateman at oracle.com
Tue Aug 30 07:02:33 UTC 2022
On 30/08/2022 07:50, Maxim Kartashev wrote:
> WatchService on MacOS is still implemented by the generic
> PollingWatchService, which continuously re-scans the directory
> consuming CPU, introduces large latencies to the generated
> WatchEvent's, and misses changes that occur faster than the re-scan
> interval. At the same time, there are two technologies available on
> the platform to receive the necessary information from the OS similar
> to what is available on Windows and Linux: Kernel Queues and File
> System Events, the latter being more suitable for implementing the
> WatchServie functionality.
>
> There are several stand-alone implementations out there that utilize
> one or the other (or even both), which suggests that demand exists for
> WatchService on MacOS to be more responsive and less resource-hungry.
>
> If the community is interested in getting this functionality in
> OpenJDK proper, I'd be happy to contribute code that was developed,
> tested, and used at JetBrains for around half a year. It is based on
> FSEvents, supports the FILE_TREE modifier (recursive directory watch),
> and does not do any excessive I/O except the necessary minimum.
>
There were been a number of prototypes a few years ago but they didn't
get to the point of being proposed for the main line. It's always been
on the list "to do".
So if you can develop an implementation that fits into the current
framework (AbstractWatchService etc.) and passes the tests then feel
free to propose. It would help the review if the native code is just
simple wrappers about the FSEvents as we'll likely replace a lot of the
JNI code in this area in time. In general, keeping it as consistent as
possible with the other code in this area would help too.
-Alan
More information about the nio-dev
mailing list