Improve entry crc32 computation 71/110571/3
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 9 Mar 2024 15:03:10 +0000 (16:03 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 11 Mar 2024 12:51:11 +0000 (12:51 +0000)
commitb8dfbae75d8e13b78d3a7d5db48de2f5e262cd87
treee42705bd8e330ee4241f5ddaed85122c8b8e072c
parentb004038a282786fc29b4ba7fc9f8874debe21afd
Improve entry crc32 computation

We have a codepath difference here, where we use either a ByteBuffer or
a raw array to compute CRC32.

MappedJournalSegmentWriter does not make it immediately clear we use
this buffer twice -- once for CRC32 and once for deserialization.

Move acquisition of slice just after we have read the expected CRC32, so
it is clear it is something we would be doing even if there were no
checksum involved.

Mirror the same in FileChannelJournalSegmentWriter, as this will allow
us to further consolidate the code and stop mucking with memory.limit(),
which is causing us to invalidate our previously-set mark.

JIRA: CONTROLLER-2095
Change-Id: I355bd97cd8acb4f5d9d91310de97ecb2cbd70282
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
atomix-storage/src/main/java/io/atomix/storage/journal/FileChannelJournalSegmentWriter.java
atomix-storage/src/main/java/io/atomix/storage/journal/MappedJournalSegmentWriter.java