You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
It would be also possible to skip memory copy when the input is FileInputStream by directly writing the file contents to the MessageBuffer.
If we reuse the byte array b in unpackBinary(b), its cost reduced to 1/3.
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.
Activity
[-]Improving unpackBinary performance[/-][+]Improve unpackBinary and unpackString performance[/+]#103 Optimization for ByteArrayInputStream
xerial commentedon May 30, 2014
The reason why
unpackBinarywas 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.It would be also possible to skip memory copy when the input is FileInputStream by directly writing the file contents to the MessageBuffer.
#103: Simplified ArrayBufferInput
xerial commentedon May 30, 2014
If we reuse the byte array

binunpackBinary(b), its cost reduced to 1/3.So the breakdown of
unpackBinaryperformance (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.[-]Improve unpackBinary and unpackString performance[/-][+]Improve unpackBinary performance[/+]xerial commentedon May 30, 2014
unpackStringin v07 involves UTF-8 decoding while v06 has no support for this. So I removed this topic from this thread.