Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
Description
In ratis streaming, the write to RemoteStream uses ByteBuf#nioBuffer() which copies the ByteBuf content to a HeapByteBuffer.
CompletableFuture<DataStreamReply> write(DataStreamRequestByteBuf request, Executor executor) { final Timekeeper.Context context = metrics.start(); return composeAsync(sendFuture, executor, n -> out.writeAsync(request.slice().nioBuffer(), addFlush(request.getWriteOptionList())) .whenComplete((l, e) -> metrics.stop(context, e == null))); }
And this action implies 2 points of inefficiency:
- The created and discarded HeapBuffer creates the O(N) cost to GC, with N as the data amount flowing through the ratis server.
- When the HeapBuffer is written to the network, it needs to be copied again to a DriectBuffer by NIO. So, in total, 2 copies.
See: dn_write_streaming_allocation.htm and dn_write_streaming.htm
Attachments
Attachments
Issue Links
- links to