6

Has anyone figured it out how to do Kernel bypass in Java? Any hello world somewhere or this is rocket science?

chrisapotek
  • 6,007
  • 14
  • 51
  • 85
  • 12
    The people who closed this are clueless about networking. Good job guys! – chrisapotek Aug 27 '12 at 15:11
  • 1
    There's a good reason this question exists. The kernel does not give us the same amount of packet throughput as the user API does. I honestly would appeal to @Makoto, John Palmer, Don Roby, rene, Ben about this. – Karthik Kumar Viswanathan Aug 31 '16 at 06:21

2 Answers2

5

If you are using solarflare, you can use their API to do kernel bypass (I am not using it directly, so can't provide more details). You can also use a messaging broduct like 29West LBM or IBM LLM which support rich functionality over various hardware.

As @eSniff mentioned, the JRE has transferFrom() / transferTo() API which right now is used to expose the sendfile(2) equivalent for the systems that support it. The semantics of the API is defined so it can be transparently implemented to support DMA transfers between any 2 channels.

ddimitrov
  • 3,293
  • 3
  • 31
  • 46
  • Hey, but transferFrom and transferTo have to do with FileChannel! I am talking about SocketChannel and DatagramChannel here for networking :( – chrisapotek Aug 25 '12 at 20:23
  • @chrisapotek a socketChannel is both a WritableByteChannel and a ReadableByteChannel, so .... someFileChannel.transferFrom(someSocketChannel, pos, count ) / someFileChannel.transferTo( pos, count, someSocketChannel) I've only used the Netty wrappers myself, but this should work. – eSniff Aug 25 '12 at 21:38
  • 1
    The transferXxx is the standard API for exposing DMA-style functionality. In the Oracle HotSpot JRE, as of version 7, it is implemented only for files and sockets. I don't think it would work between user-space memory buffer and socket (i.e. RDMA). That said, the code has extension points and if I am not mistaken, new channel types can be added by provider libraries by 3rd parties. – ddimitrov Aug 26 '12 at 14:58
2

Search for "Java Zero-Copy Buffers" or "Java NIO" or "Java Netty".

Here is a slide show about Netty and zero-copy : http://www.slideshare.net/danbim/zerocopy-eventdriven-servers-with-netty . Here is an example project with Netty.

Or you can go lower level and use the java.nio.channels classes, which you can read about here http://www.ibm.com/developerworks/linux/library/j-zerocopy/

eSniff
  • 5,713
  • 1
  • 27
  • 31
  • That's great info eSniff. I am using Java NIO but that does not bypass the kernel. – chrisapotek Aug 25 '12 at 16:15
  • I haven't programed in java in years so I'm not sure how relevant the answer is any more. But why the downvotes recently? – eSniff Aug 16 '16 at 18:25