RFR: 8285956: (fs) Excessive default poll interval in PollingWatchService [v8]

Alan Bateman alanb at openjdk.java.net
Thu May 5 05:36:26 UTC 2022


On Wed, 4 May 2022 17:13:33 GMT, Tyler Steele <duke at openjdk.java.net> wrote:

>> PollingWatchService.java contains the WatchService and WatchKey implementation for AIX and BSD. When a Path is [register](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Path.html#register(java.nio.file.WatchService,java.nio.file.WatchEvent.Kind...))ed this implementation creates a  polling thread to monitor for file system changes. Currently, this thread waits 10 seconds before it's first poll, and then waits 10 seconds between subsequent polls. This interval leads to sluggish performance.
>> 
>> This PR makes the following changes:
>> - Sets the initial interval to 1 second regardless of the period.
>> - Change the default period to 1 second.
>> 
>> All tests in `test/jdk/java/nio/file/WatchService` passing.
>
> Tyler Steele has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Move polling initial delay to top of WatchService class

src/java.base/share/classes/sun/nio/fs/PollingWatchService.java line 66:

> 64:     // Wait between polling thread creation and first poll (seconds)
> 65:     private static final int POLLING_INIT_DELAY = 1;
> 66:     // Default time between polls (seconds)

Thanks for more the constant. You can insert a blank line between them to make it easier to distinguish and also to keep it consistent with the existing code.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8479


More information about the nio-dev mailing list