Patch for adding SO_REUSEPORT socket option
Lu, Yingqi
yingqi.lu at intel.com
Mon Dec 21 17:53:21 UTC 2015
Hi All,
Sorry for the late reply. Here is the link to the most recent reversion of the patch (version #6). http://cr.openjdk.java.net/~mcberg/jdk/6432031/webrev.06/
In this version, we have done following modifications based on the feedback we received. Please review and let us know if there is anything missing. Thank you very much!
1. setReusePort and getReusePort methods are removed from Socket/ServerSocket/DatagramSocket.
2. Minor wording changes to StandardSocketOptions regarding to SO_REUSEPORT. This include adding "usually" to the sentences and also including @since 9 at the end.
3. inside sun.nio.ch.Net,
3.1 Change Net.reuseportSupported to Net.isReusePortAvailable and make it as private.
3.2 The native implantation isReusePortAvailable0 is done inside Net.c which points to a newly added native function named reuseport_available(). reuseport_available() is added in ./jdk/src/java.base/share/native/libnet/net_util.c.
4. inside java.net,
4.1 Add a function called isReusePortAvailable in ./jdk/src/java.base/share/classes/java/net/SocketImpl.java. Create SocketImpl.c file for both UNIX and Windows to add the native implementation named as isReusePortAvailable0.
4.2 The native implementation points to the same reuseport_available() described in 3.2
5. Similarly, inside jdk.net, add isReusePortAvailable and its native implementation.
6. Inside ./jdk/src/java.base/unix/native/libnet/net_util_md.c, add a new function called reuseport_supported(). This is the function that calls setsockopt and check for SO_REUSEPORT. reuseport_available() points to reuseport_supported().
7. reuseport_supported() is called during JNI_OnLoad function and the result is also the return value of reuseport_available(). This makes SO_REUSEPORT check is done once at the beginning and the results will be cached for later use.
8. #3-#7 follows the example of the IPv6 check. Please let me know if there is anything I missed.
9. Removed setting SO_REUSEPORT for debugger agent
10. For all the tests, instead of calling Net.reuseportSupport method, use supportedOptions to check for SO_REUSEPORT.
11. Remove test/java/net/Socket/setReusePort/Basic.java since the setReusePort and getReusePort methods are removed.
12. Setting SO_REUSEPORT value to platform dependent instead of using 15 for everyone.
13. Make SO_REUSEPORT to be disabled by default for both ServerSocketChannelImpl and SocketChannelImpl. Leave the feature enablement to the users.
14. Updated the copyright date.
Thanks,
Lucy
-----Original Message-----
From: Lu, Yingqi
Sent: Tuesday, December 08, 2015 10:25 PM
To: Lu, Yingqi <yingqi.lu at intel.com>; Alan Bateman <Alan.Bateman at oracle.com>; Michael McMahon <michael.x.mcmahon at oracle.com>; Volker Simonis <volker.simonis at gmail.com>
Cc: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; net-dev at openjdk.java.net; Kharbas, Kishor <kishor.kharbas at intel.com>; Aundhe, Shirish <shirish.aundhe at intel.com>; Kaczmarek, Eric <eric.kaczmarek at intel.com>
Subject: RE: Patch for adding SO_REUSEPORT socket option
Hi All,
Here is an update on the progress. Based on the comments and feedback we received, we modified following items in the upcoming version of the patch (will be version #6). We are in the process of testing. I will be on vacation from Dec. 9th and will be back to office on Dec. 17th. We will hopefully be able to send out version #6 of the patch on Dec. 18th.
1. setReusePort and getReusePort methods are removed from Socket/ServerSocket/DatagramSocket.
2. Minor wording changes to StandardSocketOptions regarding to SO_REUSEPORT. This include adding "usually" to the sentences and also including @since 9 at the end.
3. inside sun.nio.ch.Net,
3.1 Change Net.reuseportSupported to Net.isReusePortAvailable and make it as private.
3.2 The native implantation isReusePortAvailable0 is done inside Net.c which points to a newly added native function named reuseport_available(). reuseport_available() is added in ./jdk/src/java.base/share/native/libnet/net_util.c.
4. inside java.net,
4.1 Add a function called isReusePortAvailable in ./jdk/src/java.base/share/classes/java/net/SocketImpl.java. Create SocketImpl.c file for both UNIX and Windows to add the native implementation named as isReusePortAvailable0.
4.2 The native implementation points to the same reuseport_available() described in 3.2
5. Similarly, inside jdk.net, add isReusePortAvailable and its native implementation.
6. Inside ./jdk/src/java.base/unix/native/libnet/net_util_md.c, add a new function called reuseport_supported(). This is the function that calls setsockopt and check for SO_REUSEPORT. reuseport_available() points to reuseport_supported().
7. reuseport_supported() is called during JNI_OnLoad function and the result is also the return value of reuseport_available(). This makes SO_REUSEPORT check is done once at the beginning and the results will be cached for later use.
8. #3-#7 follows the example of the IPv6 check. Please let me know if there is anything I missed.
9. Removed setting SO_REUSEPORT for debugger agent
10. For all the tests, instead of calling Net.reuseportSupport method, use supportedOptions to check for SO_REUSEPORT.
11. Remove test/java/net/Socket/setReusePort/Basic.java since the setReusePort and getReusePort methods are removed.
12. Setting SO_REUSEPORT value to platform dependent instead of using 15 for everyone.
13. Make SO_REUSEPORT to be disabled by default for both ServerSocketChannelImpl and SocketChannelImpl. Leave the feature enablement to the users.
14. Updated the copyright date.
Thanks,
Lucy
-----Original Message-----
From: net-dev [mailto:net-dev-bounces at openjdk.java.net] On Behalf Of Lu, Yingqi
Sent: Tuesday, December 08, 2015 9:11 AM
To: Alan Bateman <Alan.Bateman at oracle.com>; Michael McMahon <michael.x.mcmahon at oracle.com>; Volker Simonis <volker.simonis at gmail.com>
Cc: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; net-dev at openjdk.java.net; Kharbas, Kishor <kishor.kharbas at intel.com>; Aundhe, Shirish <shirish.aundhe at intel.com>; Kaczmarek, Eric <eric.kaczmarek at intel.com>
Subject: RE: Patch for adding SO_REUSEPORT socket option
Thank you very much for your help, Alan!
Thanks,
Lucy
-----Original Message-----
From: Alan Bateman [mailto:Alan.Bateman at oracle.com]
Sent: Tuesday, December 08, 2015 8:46 AM
To: Lu, Yingqi <yingqi.lu at intel.com>; Michael McMahon <michael.x.mcmahon at oracle.com>; Volker Simonis <volker.simonis at gmail.com>
Cc: Kaczmarek, Eric <eric.kaczmarek at intel.com>; net-dev at openjdk.java.net; Kharbas, Kishor <kishor.kharbas at intel.com>; Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; Aundhe, Shirish <shirish.aundhe at intel.com>
Subject: Re: Patch for adding SO_REUSEPORT socket option
On 08/12/2015 00:53, Lu, Yingqi wrote:
> Hi Alan,
>
> I heard that the feature freeze for OpenJDK9 is approaching. Given the significant performance impact (up to 1.93x with Hadoop Distributed File System) this feature provides and the status of the existing work, we would be really interested in see this feature to be approved for OpenJDK9. We will surely continue working with the community to address opens/issues until it is completely ready to be merged into the source code tree.
There is a proposal to move out JDK 9 by 6 months [1]. In any case, I think we are close to agreement on this socket option and I will reply to your others mail the implementation.
-Alan.
[1]
http://mail.openjdk.java.net/pipermail/jdk9-dev/2015-December/003149.html
More information about the net-dev
mailing list