invesdwin / invesdwin-context-integration

invesdwin-context modules that provide integration features
GNU Lesser General Public License v3.0
1 stars 0 forks source link

improve zero copy with an array based bytebuffer #37

Closed subes closed 1 year ago

subes commented 1 year ago

Should use arraylist an expose the list for manipulation

All operations work on the internal buffers in list transparently similar to how netty can do it

Writers where size is prefixed to a message then don't need a copy anymore, instead data is directly concatenated through the array

AsByteArray is no problem because it can create a new array, though asNioByteBuffer will also require a new copy sadly, since I guess we can not implement something for that.

Needs to br checked if the amout of reduced copy will result in zero copy during writes (or maybe reduced to one copy instead of one per channel wrapper). Also need to check if performance actually improves, because system.memcopy might be faster than iterating though multiple buffers in an array multiple times.

subes commented 1 year ago

Implemented. Will use it somewhere as soon as a spot is identified where it can improve zero-copy in a critical path. Most places already work fine due to IByteBufferProcvder. In encryption the copy is still required. But did not check all channels fully, so there might be spots where this could be used. Will look into it when reviewin the channels used by the platform.