-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PooledSlicedByteBuf and PooledDuplicatedByteBuf #3788
Conversation
@trustin @Scottmitch please review |
writerIndex(length); | ||
maxCapacity(length); | ||
setIndex(0, length); | ||
markReaderIndex(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wait for #3789 and update this to discardMarks
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :)
Am 15.05.2015 um 19:51 schrieb Scott Mitchell notifications@github.com:
In buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java:
@@ -53,8 +61,10 @@ public SlicedByteBuf(ByteBuf buffer, int index, int length) {
adjustment = index;
}this.length = length;
writerIndex(length);
maxCapacity(length);
setIndex(0, length);
Should we wait for Reset markers when obtain PooledByteBuf. #3789 and update this to discardMarks?markReaderIndex();
—
Reply to this email directly or view it on GitHub.
Motivation: At the moment when calling slice(...) or duplicate(...) on a Pooled*ByteBuf a new SlicedByteBuf or DuplicatedByteBuf. This can create a lot of GC. Modifications: Add PooledSlicedByteBuf and PooledDuplicatedByteBuf which will be used when a PooledByteBuf is used. Result: Less GC.
LGTM |
@normanmaurer - good work! Can the branch be deleted? |
@Scottmitch done |
This change will be reverted. See #4138 |
Motivation: Currently the "derived" buffer will only ever be recycled if the release call is made on the "derived" object, and the "wrapped" buffer ends up being "fully released" (aka refcount goes to 0). From my experience this is not the common use case and thus the "derived" buffers will not be recycled. Modifications: - revert netty#3788 Result: Less complexity, and less code to create new objects in majority of cases.
Motivation: Currently the "derived" buffer will only ever be recycled if the release call is made on the "derived" object, and the "wrapped" buffer ends up being "fully released" (aka refcount goes to 0). From my experience this is not the common use case and thus the "derived" buffers will not be recycled. Modifications: - revert #3788 Result: Less complexity, and less code to create new objects in majority of cases.
Motivation: Currently the "derived" buffer will only ever be recycled if the release call is made on the "derived" object, and the "wrapped" buffer ends up being "fully released" (aka refcount goes to 0). From my experience this is not the common use case and thus the "derived" buffers will not be recycled. Modifications: - revert #3788 Result: Less complexity, and less code to create new objects in majority of cases.
Motivation: Currently the "derived" buffer will only ever be recycled if the release call is made on the "derived" object, and the "wrapped" buffer ends up being "fully released" (aka refcount goes to 0). From my experience this is not the common use case and thus the "derived" buffers will not be recycled. Modifications: - revert #3788 Result: Less complexity, and less code to create new objects in majority of cases.
Motivation: As part of the revert process in netty#4138 some index and mark updates were lost. Modifications: - Restore the index / mark updates made in netty#3788 Result: Slice and Duplicate buffers index / marks are correctly initialized.
Motivation: Currently the "derived" buffer will only ever be recycled if the release call is made on the "derived" object, and the "wrapped" buffer ends up being "fully released" (aka refcount goes to 0). From my experience this is not the common use case and thus the "derived" buffers will not be recycled. Modifications: - revert netty#3788 Result: Less complexity, and less code to create new objects in majority of cases.
Motivation: As part of the revert process in netty#4138 some index and mark updates were lost. Modifications: - Restore the index / mark updates made in netty#3788 Result: Slice and Duplicate buffers index / marks are correctly initialized.
Motivation:
At the moment when calling slice(...) or duplicate(...) on a Pooled*ByteBuf a new SlicedByteBuf or DuplicatedByteBuf. This can create a lot of GC.
Modifications:
Add PooledSlicedByteBuf and PooledDuplicatedByteBuf which will be used when a PooledByteBuf is used.
Result:
Less GC.