duongkame commented on code in PR #5497:
URL: https://github.com/apache/ozone/pull/5497#discussion_r1428647929
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChunkBuffer.java:
##########
@@ -52,6 +57,30 @@ static ChunkBuffer allocate(int capacity, int increment) {
return new ChunkBufferImplWithByteBuffer(ByteBuffer.allocate(capacity));
}
+ /** Preallocate the entire buffer. */
+ static ChunkBuffer preallocate(long capacity, int increment) {
+ Preconditions.assertTrue(increment > 0);
+ if (capacity <= increment) {
+ final CodecBuffer c =
CodecBuffer.allocateDirect(Math.toIntExact(capacity));
Review Comment:
Would be cleaner if we directly deal with `ByteBufAllocator` and `ByteBuf`
in ChunkBuffer. `CodecBuffer` logic doesn't provide much, but adds an
unnecessary dependency.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/GrpcXceiverService.java:
##########
@@ -107,9 +108,20 @@ public StreamObserver<ContainerCommandRequestProto> send(
@Override
public void onNext(ContainerCommandRequestProto request) {
+ final DispatcherContext context;
Review Comment:
I think we got to do the same in ContainerStateMachine.readStateMachineData.
Otherwise there'll be memory leak. Not sure if I should put this comment in
https://github.com/apache/ozone/pull/5805
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/IncrementalChunkBuffer.java:
##########
@@ -115,7 +128,9 @@ private ByteBuffer getAndAllocateAtIndex(int index) {
// allocate upto the given index
ByteBuffer b = null;
for (; i <= index; i++) {
- b = ByteBuffer.allocate(getBufferCapacityAtIndex(i));
+ final CodecBuffer c =
CodecBuffer.allocateDirect(getBufferCapacityAtIndex(i));
Review Comment:
I guess this particular change in IncrementalChunkBuffer is mostly for
client-side library.
This will solve the inefficient use of memory as documented per HDDS-9843,
because here we move to use `PooledByteBufAllocator` to allocate direct
buffers. And usage of pooled/reused direct buffers will completely avoid the
problem of repeating allocation in heap. cc. @kerneltime
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]