JGroups icon indicating copy to clipboard operation
JGroups copied to clipboard

Optimized receiving in TCP_NIO2

Open cfredri4 opened this issue 2 months ago • 7 comments

This contains several changes to improve performance of receiving messages in TCP_NIO2:

  • An optimized way of reading from the channel to minimize the number of channel.read() calls. I put this in a separate class as it is really very separate from the existing Buffers class.
  • A change to direct buffers when receiving. This also meant changing to pass a stream to Receiver instead of an array (which aligns with TCP).
  • Adding a read(byte[] b, int off, int len) to ByteBufferInputStream.
  • An unrelated fix to the CRLF handling in ByteBufferInputStream+ByteArrayDataInputStream (as suggested by ChatGPT 😅).

I can see some small performance improvements with this in my simple tests.

Please check/feedback/verify my tests. 🙂

cfredri4 avatar Oct 15 '25 14:10 cfredri4