SzyWilliam opened a new pull request, #762:
URL: https://github.com/apache/ratis/pull/762

   ## Motivation
   Serializing a log entry to RaftLog currently requires two data copies, one 
from entry to temp heap array, one from heap array to direct byteBuffer. The 
original motivation is to reduce the former copy and directly serialize log 
entry to direct byteBuffer. This beneficial in the following two aspects:
   1. Avoid temp heap array and reduce young GC pressure.
   2. Save CPU cycles on copying data and reduce latency.
   
   However, the checksum operation on Log Entry prevents us from eliminating 
the extra copy. Performing checksum on direct memory involves copying data back 
to heap (Oops🥵), one byte at a time. To make matters worse, Unsafe operations 
involves lots of safety overheads like boundary checking, make the performance 
even slower (3x times) than original two-copy method. Therefore, we better 
leave the current two-copy method unchanged.
   
   Still, we can allocate a global `serializeBuf` and avoid allocating a temp 
heap array every write operation. 
   
   ## What changes were proposed in this pull request?
   Allocate a global serialize buffer (as large as BufferByteLimit) and use 
this buffer to hold serialization results.
   
   According to benchmark simulation results(Using Apache IoTDB workloads), 
this patch can reduce the byte array allocation in the write path and reduce 
total young GC frequency by roughly 20% .
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/RATIS-1717
   
   ## How was this patch tested?
   1. unit tests
   2. manual tests and benchmark tests.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to