Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private ByteBuf decodeNext() throws Exception {
}

// Otherwise, create a composite buffer.
CompositeByteBuf frame = buffers.getFirst().alloc().compositeBuffer();
CompositeByteBuf frame = buffers.getFirst().alloc().compositeBuffer(Integer.MAX_VALUE);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we can set the maxNumComponents for compositeBuffer to avoid consolidate underlying, such as CompositeByteBuf frame = buffers.getFirst().alloc().compositeBuffer(Integer.MAX_VALUE);, but this might be not a good choice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not a good choice? With your change, you're replacing "maybe copy multiple times" with "always copy once". If there's a way to avoid the copy altogether, why not do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanzin , I'm not sure why Netty underlying set a maximum number components (max size is Integer.MAX_VALUE), and the default value is only 16, this seems very small for consolidation. Will it occurs other problem when there are too many small buffers under compositeBuffer? Is that why it will consolidate when the small buffer number reaches the maxNumCompnent?

while (remaining > 0) {
ByteBuf next = nextBufferForFrame(remaining);
remaining -= next.readableBytes();
Expand Down