-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8285956: (fs) Excessive default poll interval in PollingWatchService #8479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PollingWatchService.java
👋 Welcome back backwaterred! A progress list of the required criteria for merging this PR into |
@backwaterred The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
/label add core-libs |
@backwaterred |
Do you have any performance measurements to share? Note that the sensitivity can be set as shown in the SensitivityModifier test. |
/label remove core-libs |
/label add nio |
@AlanBateman |
@AlanBateman The |
Nothing terribly rigorous, but the testing I did during development went from a 11.5 sec average down to about 1.5 seconds. Which is more or less what I expected when dropping a 10 second wait ;-)
👍 Thanks for the link. I noticed it could be changed, but 10s still feels way too long for a default value. |
@AlanBateman Is there a guide to choosing which label is appropriate for a given change? I haven't been able to find one. |
I think the problem was that the Jira issue had no subcomponent listed. |
Could you perhaps test it with something a bit less aggressive than 1s, perhaps 5s? Thanks. |
src/java.base/share/classes/sun/nio/fs/PollingWatchService.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/sun/nio/fs/PollingWatchService.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/sun/nio/fs/PollingWatchService.java
Outdated
Show resolved
Hide resolved
Are you meaning to suggest a different default value? I recognize that my choice of 1s is arbitrary, and can change it if desired. Testing with initial interval of 5s yields 6.44s with my development test. |
Yes, I was thinking of a different default value. Subjectively 6.44s does seem rather slow however. I know this is hard to measure in any kind of rigorous way, and the current 10s is really bad. I think the concern would be if there were many simultaneous watch services with frequent polling causing an overall performance degradation. |
I agree it is good to consider whether or not the design makes it easy to load up so many changes that performance degrades. But I think we're well clear of that point even with 1s. I think it helps that scheduleAtFixedRate guarantees that the tasks will not run concurrently and Watchable specifies that the key should only be created if one doesn't already exist. If a user were to register enough unique Watchable objects to degrade the performance of their system, I am hopeful that the reason for the slow down would be clear to them. An alternative would be to keep the initial wait at 1s and increase the default polling interval to 2s. |
That might be better. A more ideal way to fix this would be to implement something on top of |
src/java.base/share/classes/sun/nio/fs/PollingWatchService.java
Outdated
Show resolved
Hide resolved
696e1ee
to
fc6a65d
Compare
I made this change.
Agreed. I have adding an implementation on top of AIX Event Infrastructure on my to-do list, but this easy fix that will address my current problem. |
Thanks for your comments @bplb and @AlanBateman. If you have no further comments, and are happy with the ones I've resolved, please finalize your reviews so that I may merge (I am eager to get this one in so that I can backport it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I agree the default of 2secs is fine for most scenarios. If someone wants to saturate the Watchservice, he will manage to do that, but as Tyler wrote, it is an obvious problem.
Cheers, Thomas
@backwaterred This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 72 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@tstuefe, @bplb) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better if both constants were on PollingWatchService
but this is all right.
Thanks @tstuefe! /integrate |
@backwaterred |
Testing complete. We are (again) ready to... |
@backwaterred |
/sponsor |
Going to push as commit 1bb4de2.
Your commit was automatically rebased without conflicts. |
@tstuefe @backwaterred Pushed as commit 1bb4de2. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
@@ -61,6 +61,11 @@ | |||
class PollingWatchService | |||
extends AbstractWatchService | |||
{ | |||
// Wait between polling thread creation and first poll (seconds) | |||
private static final int POLLING_INIT_DELAY = 1; | |||
// Default time between polls (seconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
PollingWatchService.java contains the WatchService and WatchKey implementation for AIX and BSD. When a Path is registered 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:
All tests in
test/jdk/java/nio/file/WatchService
passing.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8479/head:pull/8479
$ git checkout pull/8479
Update a local copy of the PR:
$ git checkout pull/8479
$ git pull https://git.openjdk.java.net/jdk pull/8479/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8479
View PR using the GUI difftool:
$ git pr show -t 8479
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8479.diff