Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
In current implementation, before a log entry is serialized to RaftLog, it first needs to be serialized to a byte array[1], and then be written to FileChannel using directByteBuffer[2]. It requires two data copies, one from LogEntryProto to byte array, one from byte array to direct ByteBuffer.
We can reduce the data copy by serializing LogEntry to directByteBuffer, removing the byte array:
- We need a directByteBuffer large enough to hold a single log (maxBufferSize).
- When we need to serialize a log entry to RaftLog, first we check whether there's enough space remained in directByteBuffer. If not, we flush the directByteBuffer to FileChannel. Otherwise we serialize the data directly into directByteBuffer.
- When data buffered in directByteBuffer reaches the threshold (say 64KB), we flush the directByteBuffer, the same as current implementation.
Attachments
Attachments
Issue Links
- is related to
-
RATIS-1743 Memory leak in SegmentedRaftLogWorker due to metrics
- Resolved
-
RATIS-1746 Change the shared byte array in SegmentedRaftLogWorker to be configurable.
- Resolved
- links to