lhotari commented on code in PR #4259:
URL: https://github.com/apache/bookkeeper/pull/4259#discussion_r1572219468
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessorV3.java:
##########
@@ -170,25 +169,21 @@ protected ReadResponse readEntry(ReadResponse.Builder
readResponseBuilder,
boolean readLACPiggyBack,
Stopwatch startTimeSw)
throws IOException, BookieException {
- ByteBuf entryBody = requestProcessor.getBookie().readEntry(ledgerId,
entryId);
+ entryBody = requestProcessor.getBookie().readEntry(ledgerId, entryId);
if (null != fenceResult) {
- handleReadResultForFenceRead(entryBody, readResponseBuilder,
entryId, startTimeSw);
+ handleReadResultForFenceRead(readResponseBuilder, entryId,
startTimeSw);
return null;
} else {
- try {
-
readResponseBuilder.setBody(ByteString.copyFrom(entryBody.nioBuffer()));
- if (readLACPiggyBack) {
- readResponseBuilder.setEntryId(entryId);
- } else {
- long knownLAC =
requestProcessor.getBookie().readLastAddConfirmed(ledgerId);
- readResponseBuilder.setMaxLAC(knownLAC);
- }
- registerSuccessfulEvent(readStats, startTimeSw);
- readResponseBuilder.setStatus(StatusCode.EOK);
- return readResponseBuilder.build();
- } finally {
- ReferenceCountUtil.release(entryBody);
+
readResponseBuilder.setBody(UnsafeByteOperations.unsafeWrap(entryBody.nioBuffer()));
Review Comment:
Calling `.nioBuffer()` might result in memory copies when the buffer is a
composite buffer.
Something in this direction would result in zero copies:
https://github.com/apache/bookkeeper/pull/4293/files#diff-7c7c625da2136a47ce06a1753046baa3e3aeea006ef537b3fb6efd34d25000ddR851-R872
--
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]