-
Notifications
You must be signed in to change notification settings - Fork 36
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
IPROTO-265 Remove additional byte[] allocations for nested writers #192
IPROTO-265 Remove additional byte[] allocations for nested writers #192
Conversation
Performance for writers, where I was able to completely remove all additional byte[] instances NEW
6.4.3-SNAPSHOT
6.4.2.Final
Unfortunately, reading a stream is not as beneficial as there is no easy way to skip ahead with marks that doesn't conflict with the isAtEnd method. I will post the perf numbers for reads later today, but I expect byte array based TagReaderImpl to have faster performance. |
Read perf isn't quite as good as I would hope yet, going to look at it some more tomorrow. The one that was actually affected is the array based read that allows for no copy, unfortunately the InputStream variant requires a copy that I am not sure I can get rid of, so I will probably just try to get it the same performance as it is currently in that case. NEW
4.6.3-SNAPSHOT
|
Not finding any way to speed up the InputStream version more than it is. Our final usage though will be using ByteBuf which can more easily take advantage of the read changes similar to the ByteBuffer since it can use a slice instead. |
7afea21
to
b3074e5
Compare
I have some more changes after this is integrated that will test ByteBuf perf. A preview of what state they are currently is the following:
So the write perf is amazing as it uses a pooled ByteBuf instance, reads for User is a bit odd though, going to be looking closer. |
I have added a new commit that allows for custom Encoder/Decoder instances to be used which is how I was able to do the test for ByteBuf based encoder and decoders. |
infinispan/infinispan-benchmarks#18 is the benchmark PR testing that requires these changes and found those results. |
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.
LGTM, just minor suggestions 👍
core/src/main/java/org/infinispan/protostream/annotations/impl/GeneratedMarshallerBase.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/infinispan/protostream/ProtobufUtilTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/infinispan/protostream/impl/TagWriterImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/infinispan/protostream/impl/TagWriterImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/infinispan/protostream/impl/TagWriterImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/infinispan/protostream/impl/TagWriterImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/infinispan/protostream/impl/TagWriterImpl.java
Outdated
Show resolved
Hide resolved
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.
LGTM, just minor suggestions 👍
I pushed review comments. Let me know if it is okay and I can squash the commit. |
763bd1e
to
12490a3
Compare
@@ -58,6 +57,7 @@ public void testComputeMessageSize() throws Exception { | |||
|
|||
messageSize = ProtobufUtil.computeWrappedMessageSize(ctx, user); | |||
|
|||
// Actual array is 4 bigger because of fixed Varint |
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.
outdated
if (nestedWriter instanceof Closeable) { | ||
((Closeable) nestedWriter).close(); | ||
} |
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.
forgot to ask, don't you have to close every time?
if (nestedWriter instanceof Closeable) { | |
((Closeable) nestedWriter).close(); | |
} | |
nestedWriter.getWriter().close(); |
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.
Technically it is always true afaik, but this is cleaner.
…iters * Add new subWriter method to implement to allow reusing encoder instances * Add some common default methods to the TagWriter/TagReader interfaces * Add common way to write a fixed varint of 5 bytes
12490a3
to
ca65721
Compare
Updated |
merged! thanks @wburns ! |
https://issues.redhat.com/browse/IPROTO-265
https://issues.redhat.com/browse/IPROTO-266
Also added changes to allow for custom Decoder/Encoder instances to be used instead of the supplied ones.