[ 
https://issues.apache.org/jira/browse/RATIS-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Duong updated RATIS-2027:
-------------------------
    Description: 
In ratis streaming, the write to RemoteStream uses ByteBuf#nioBuffer() which 
copies the ByteBuf content to a HeapByteBuffer.
{code:java}
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)));
} {code}
And this action implies 2 points of inefficiencies:
 # The created and discarded HeapBuffer creates the O(N) cost to GC, with N is 
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. 

!allocation.png|width=722,height=251!

!cpu.png|width=718,height=261!

See:  [^dn_write_streaming_allocation.htm] and [^dn_write_streaming.htm]

  was:
In ratis streaming, the write to RemoteStream uses ByteBuf#nioBuffer() which 
copies the ByteBuf content to a HeapByteBuffer.
{code:java}
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)));
} {code}
And this action implies 2 points of inefficiencies:
 # The created and discarded HeapBuffer creates the O(N) cost to GC, which N is 
the data amount flowing through ratis server.
 # When the HeapBuffer is written to the network, it needs to be copied again 
to a DriectBuffer by NIO.

!allocation.png|width=722,height=251!

!cpu.png|width=718,height=261!

See:  [^dn_write_streaming_allocation.htm] and [^dn_write_streaming.htm]


> Ratis Streaming: Remote Stream copy data to heap
> ------------------------------------------------
>
>                 Key: RATIS-2027
>                 URL: https://issues.apache.org/jira/browse/RATIS-2027
>             Project: Ratis
>          Issue Type: Improvement
>          Components: Streaming
>            Reporter: Duong
>            Priority: Major
>              Labels: performance
>         Attachments: allocation.png, cpu.png, dn_write_streaming.htm, 
> dn_write_streaming_allocation.htm
>
>
> In ratis streaming, the write to RemoteStream uses ByteBuf#nioBuffer() which 
> copies the ByteBuf content to a HeapByteBuffer.
> {code:java}
> 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)));
> } {code}
> And this action implies 2 points of inefficiencies:
>  # The created and discarded HeapBuffer creates the O(N) cost to GC, with N 
> is 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. 
> !allocation.png|width=722,height=251!
> !cpu.png|width=718,height=261!
> See:  [^dn_write_streaming_allocation.htm] and [^dn_write_streaming.htm]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to