Any interest in WatchService based on MacOS FSEvents?
Laurence Cable
larry.cable at oracle.com
Mon Sep 5 19:39:17 UTC 2022
On 8/29/22 11:50 PM, 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.
>
totally!
> References
> * WatchService interface
> -
> https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/nio/file/WatchService.html
> * PollingWatchService source code
> -
> https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java
> * File System Events
> -
> https://developer.apple.com/documentation/coreservices/file_system_events?language=objc
> * Kernel Queues
> -
> https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/KernelQueues/KernelQueues.html
More information about the discuss
mailing list