Thanks for the nice findings ikeda
This jira solves 3 issues with Unsafe operations and ByteBufferUtils
1. We can do sun unsafe based reads and writes iff unsafe package is available and underlying platform is having unaligned-access capability. But we were missing the second check
2. Java NIO is doing a chunk based copy while doing Unsafe copyMemory. The max chunk size is 1 MB. This is done for "A limit is imposed to allow for safepoint polling during a large copy" as mentioned in comments in Bits.java. We are also going to do same way
3. In ByteBufferUtils, when Unsafe is not available and ByteBuffers are off heap, we were doing byte by byte operation (read/copy). We can avoid this and do better way.
- is related to
HBASE-11425 Cell/DBB end-to-end on the read-path