-
Notifications
You must be signed in to change notification settings - Fork 321
V07 unpacker #100
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
V07 unpacker #100
Conversation
…dd property based tests
…npackNil return null for convenience
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.
Can you explain why you use the value bb.position() - bb.remaining()?
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.
It's my mistake. This should be bb.limit() - bb.remaining(). Thanks.
|
👍 |
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 check whether obj is null or not?
if (other == null) {
return false;
} else if(obj instanceof ExtendedTypeHeader) {
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.
null instanceof xxx returns false, so we do not need null check here:
http://stackoverflow.com/questions/2950319/is-null-check-needed-before-calling-instanceof
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.
Thank you for the explanation! 👍
…fferBE.slice() to return big-endian buffer
Optimize unpackBinary
|
Now closes this ticket. Thanks for the review! |
|
Epic 100th issue! 👍 |
|
Thanks for your great work, @xerial! |
|
Good job 👍 @xerial |
Implemented MessageUnpacker whose performance is faster than v06. You can run benchmark tests that compare the performance of v06 and v07:
benchmark code: https://github.com/msgpack/msgpack-java/blob/v07-unpacker/msgpack-core/src/test/scala/org/msgpack/core/MessageUnpackerTest.scala
When reading 10,000 message-packed records (including arrays, maps, strings, etc.), skipping records is 4 times faster than v6, and reading values is about 2 times faster:

Summary of the changes:
MessageUnpacker.unpackXXXmethods block until the next input buffer is available. Supporting event-driven I/O Supporting event-driven I/O in unpackXXX #92 is not included in this change.MessageBuffers, the unpacker copies the contents of the current buffer and the next buffers into an extra buffer so that readXXX can read its required length. (seeensure(n)inMessageUnpacker)skipValue()uses switch-case statements instead of polymorphic function calls inMessageFormatbecause using switch statement is slightly faster. The skip length table Using skip length table in MessageUnpacker #94 is not yet implemented because this part is already fast enough.packStringandunpackStringthat use pre-allocated buffers to encode/decode UTF-8 strings.MessagePackTest.scala)./sbt jacoco:coverhttp://www.eclemma.org/jacoco/./sbt findbugshttp://findbugs.sourceforge.net/TODO