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
8266369: (se) Add wepoll based Selector #3816
Conversation
👋 Welcome back alanb! A progress list of the required criteria for merging this PR into |
@AlanBateman 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. |
/issue JDK-8266369 |
@AlanBateman This issue is referenced in the PR title - it will now be updated. |
Webrevs
|
src/java.base/windows/classes/sun/nio/ch/WEPollSelectorImpl.java
Outdated
Show resolved
Hide resolved
* Returns event[i]; | ||
*/ | ||
static long getEvent(long address, int i) { | ||
return address + (SIZEOF_EPOLLEVENT*i); |
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.
space issue (SIZEOF_EPOLLEVENT*i);
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.
Overall, this looks like a very nice addition.
@AlanBateman 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 16 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. ➡️ To integrate this PR with the above commit message to the |
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.
LGTM
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.
A good improvement. Approved.
/integrate |
@AlanBateman Since your change was applied there have been 18 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit be4f25b. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR proposes a new Selector implementation for the Windows platform based on the Bert Belder's "wepoll" library. The wepoll library provides a scalable polling interface to the Ancillary Function Driver for Winsock. The interface that it exposes is close to the Linux epoll interface. The main benefit is that the cost of selection operations are a function of the number of sockets that are ready for I/O rather than the number of channels registered with the Selector. The existing Selector on Windows uses the legacy "select" which scales horribly, partly because it's O(N) on the number of registered channels and partly because it is limited to 1024 sockets and so requires a thread per 1024 sockets.
The patch brings the wepoll sources into the repo, adds a small shim, and the Selector implementation itself. The new implementation needs to handle OOB data in the same way as the old implementation so the method to discard OOB moves to Net.
I've added a microbenchmark to demonstrate the scaling when there is 1, 10, ... 10k connections and one socket ready for I/O. Windows Server 2019 was used for the data here. I've seen improvements with almost everything that I've tried. The only exception is a select after a wakeup where the old implementation skips the selection operation (arguably a long standing bug in the old implementation).
Existing select based Selector where the selection operation is almost 1ms when there are 10,000 channels registered.
New wepoll based Selector:
Replacing the Selector implementation after 19 years of service is a big step. The proposal is to leave the existing implementation until there is confidence with the new implementation. It also serves as a backup in case Windows were to significantly change the AFD interface. The old Selector can be used by running with -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.WindowsSelectorProvider. A selection of existing tests have been updated to run a second time with the old Selector so that it is continues to be tested.
CSR and Release Note planned.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3816/head:pull/3816
$ git checkout pull/3816
Update a local copy of the PR:
$ git checkout pull/3816
$ git pull https://git.openjdk.java.net/jdk pull/3816/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3816
View PR using the GUI difftool:
$ git pr show -t 3816
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3816.diff