From: Robert Varga Date: Sat, 9 Mar 2024 14:29:56 +0000 (+0100) Subject: Reduce position changes during read X-Git-Tag: v9.0.1~52 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=fe1081dadbe4aa27600ef4454bbad5357f50e331;ds=sidebyside Reduce position changes during read Rather than using a read() which updates the position, requiring us to set the position again, set it only once and use read with offset -- eliminating one syscall. JIRA: CONTROLLER-2095 Change-Id: I478ba1cbb1f5737a751b43cb6ed0d018e49e6485 Signed-off-by: Robert Varga --- diff --git a/atomix-storage/src/main/java/io/atomix/storage/journal/FileChannelJournalSegmentWriter.java b/atomix-storage/src/main/java/io/atomix/storage/journal/FileChannelJournalSegmentWriter.java index d40d42ade5..62e0002a38 100644 --- a/atomix-storage/src/main/java/io/atomix/storage/journal/FileChannelJournalSegmentWriter.java +++ b/atomix-storage/src/main/java/io/atomix/storage/journal/FileChannelJournalSegmentWriter.java @@ -118,10 +118,9 @@ class FileChannelJournalSegmentWriter implements JournalWriter { // Read more bytes from the segment if necessary. if (memory.remaining() < maxEntrySize) { - channel.position(position); memory.clear(); - channel.read(memory); channel.position(position); + channel.read(memory, position); memory.flip(); }