[ 
https://issues.apache.org/jira/browse/HBASE-14873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15037243#comment-15037243
 ] 

stack commented on HBASE-14873:
-------------------------------

bq. Sorry for my poor expression, I just complained that I prefer no waste.

Please continue. You are helping us out.

bq. ...  but the Oracle implementation uses these methods only if the class 
variable unaligned (commented as "Cached unaligned-access capability") is true, 
which seems to be calculated whether the architecture is i386, x86, amd64, or 
x86_64.

Endianness was raised a few times during the offheap work. Alignment may not 
have been considered by architecture ([~ram_krish]/[~anoop.hbase]?). The 
argument that we'd Unsafe to avoid boundary checks is good by me having seen 
the difference in perf numbers when the checks are avoided. You raise a good 
point about possible costs doing Unsafe against onheap allocations (This 
combination not be rare in practice?)

bq. In addition, Oracle seems to plan to remove Unsafe in Java 9.

Sort of. In here, 
https://www.youtube.com/watch?v=4HG0YQVy8UM&list=PLX8CzqL3ArzUo2dtMurvpUTAaujPMeuuU&index=1,
 it won't be REMOVED... but rather, it will fade away gradually replaced with 
flags to being back old behaviors at least for a while. We'll see.

Thanks for the in put Hiroshi. Helps.

> Problems around BoundedByteBufferPool providing direct buffers
> --------------------------------------------------------------
>
>                 Key: HBASE-14873
>                 URL: https://issues.apache.org/jira/browse/HBASE-14873
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Hiroshi Ikeda
>            Assignee: Hiroshi Ikeda
>         Attachments: HBASE-14873-V2.patch, HBASE-14873.patch, 
> HBASE-14873.patch, HBASE-14873.patch
>
>
> HBASE-13819 made BoundedByteBufferPool provide direct buffers.
> See RpcServer.java:
> {code}
> ...
> class Call implements RpcCallContext {
>   protected synchronized void setResponse(...) {
> ...
>     this.cellBlock = ipcUtil.buildCellBlock(..., reservoir);
> ...
>     bc = new BufferChain(..., this.cellBlock);
>     if (connection.useWrap) {
>       bc = wrapWithSasl(bc);
>     }
> ...
>   private BufferChain wrapWithSasl(BufferChain bc) throws IOException {
> ...
>     byte[] responseBytes = bc.getBytes();
> ...
> {code}
> {{cellBlock}} is expected to be a direct buffer retrieved from {{reservoir}} 
> (but not always), and {{bc}} may be composed of both direct and non-direct 
> buffers.
> And then, see BufferChain.java:
> {code}
> byte [] getBytes() {
> ...
>     for (ByteBuffer bb: this.buffers) {
>       System.arraycopy(bb.array(), ...);
> {code}
> A direct buffer doesn't give its array, and will throw 
> UnsupportedOperationException.
> Another problem; {{cellBlock}} is allowed to be a non-direct buffer, and 
> after use it will be put to {{reservoir}}, mixing direct and non-direct 
> buffers in the pool.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to