Skip to content

Improve unpackBinary performance #103

Closed

Description

@xerial

@frsyuki measured the performance of unpackBinary, and it was slower than v06. We should improve them:
#100 (comment)

Activity

  1. changed the title [-]Improving unpackBinary performance[/-] [+]Improve unpackBinary and unpackString performance[/+] on May 29, 2014
  2. added this to the v07 milestone on May 29, 2014
  3. added a commit that references this issue on May 30, 2014
  4. xerial commented on May 30, 2014

    @xerial
    MemberAuthor

    The reason why unpackBinary was slow is InputStreamBufferInput involves a memory copy from InputStrem to MessageBuffer. I added a hack to avoid this copy when the input is ByteInputStream, and unpackBinary is now faster than v06.

    1__leo_weaver_local___work_git_msgpack-java__java_

    It would be also possible to skip memory copy when the input is FileInputStream by directly writing the file contents to the MessageBuffer.

  5. added a commit that references this issue on May 30, 2014
  6. xerial commented on May 30, 2014

    @xerial
    MemberAuthor

    If we reuse the byte array b in unpackBinary(b), its cost reduced to 1/3.
    1__leo_weaver_local___work_git_msgpack-java__zsh_
    So the breakdown of unpackBinary performance (without reusing the buffer) is (buffer allocation: 2/3) + (memcpy: 1/3)

    Implementing MessageUnpacker.getBinaryReference(size) with a memory-lifetime manager would be useful to improve this performance.

  7. changed the title [-]Improve unpackBinary and unpackString performance[/-] [+]Improve unpackBinary performance[/+] on May 30, 2014
  8. xerial commented on May 30, 2014

    @xerial
    MemberAuthor

    unpackString in v07 involves UTF-8 decoding while v06 has no support for this. So I removed this topic from this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions