use of Unsafe for ASCII detection
aph at redhat.com
Thu Jan 7 10:04:43 UTC 2016
On 06/01/16 23:21, Martin Buchholz wrote:
> That is, the Unsafe code is 3x faster than the simple code. The
> ByteBuffer code used to be 2x slower and is now 2x faster - well
> done - crowd goes wild!
Why, thank you.
> I see it uses new and well-hidden Unsafe.getLongUnaligned ... all
> the performance fanatics want to use that, but y'all don't want to
> give it to us. And we don't want to allocate a temp ByteBuffer
> object. What to do?
If you allocate a temp ByteBuffer object carefully so that it does not
escape, it will be removed and you should get the same code as
directly using Unsafe. I certainly tested it during the work on
Unsafe.getXXUnaligned and it was the same. I'll have a look at your
More information about the core-libs-dev