Skip to content
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

Speed up ByteBuffer parsing #39

Open
non opened this issue Jul 28, 2015 · 1 comment
Open

Speed up ByteBuffer parsing #39

non opened this issue Jul 28, 2015 · 1 comment

Comments

@non
Copy link
Contributor

non commented Jul 28, 2015

This is relatively slow for some reason. Figure out why!

@xerial
Copy link

xerial commented Aug 20, 2018

@non A reason why ByteBuffer in JVM is slow is it generates TypeProfile https://wiki.openjdk.java.net/display/HotSpot/TypeProfile to resolve a single method from many ByteBuffer sub classes in Java standard libraries. So each ByteBuffer.get(i) call will look up the TypeProfile table and become slower than Array[Byte] lookup.

A workaround is extracting the internal buffer (array or off-heap) of ByteBuffer like this implementation: https://github.com/msgpack/msgpack-java/blob/develop/msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java

However this kind of implementation needs sun.misc.Unsafe and introduce some complexities to your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants