DatagramChannel performance issue (original) (raw)

Martin Thompson mjpt777 at gmail.com
Sat Aug 25 16:42:23 UTC 2018


We've been diagnosing a performance issue and isolated it to receiving on a datagram socket where we are seeing a significant step down in performance, and increase in allocation, when more than one source is sending.

https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/native/sun/nio/ch/DatagramChannelImpl.c#L138

When receiving from two or more sources we get InetAddress and InetSocketAddress objects allocated and they are set via multiple up calls from the JNI code into Java.

A much more efficient implementation would be one that passes down two ByteBuffers. One to be filled in for the payload and one for the header. Allocation on a per packet receive is not a useful design for a network API.

A read operation is not a valid alternative as we need the sender address.

Regards, Martin...



More information about the core-libs-dev mailing list