Any interest in WatchService based on MacOS FSEvents?

Maxim Kartashev maxim.kartashev at jetbrains.com
Tue Aug 30 06:50:22 UTC 2022


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.

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20220830/05598437/attachment.htm>


More information about the nio-dev mailing list