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

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

bq. In practice the most problematic thing seems unlimited Unsafe.copyMemory if 
we worry about stop-the-world.

bq. How copyFromBufferToArray can omit the logic?

Oversight. Thanks for turning it up. Lets fix.

bq. Another thing I should mention is that copyFromBufferToArray is forced to 
use one-by-one copy for the other VM implementations, which is an almost bug.

Another issue. Again, lets fix. There is logic in 
Bytes#LexicographicalComparerHolder that marches through the buffer long-wise, 
then by int,... and finally by byte.

bq. Unsafe is mysteriously dangerous and I doubt the performance improvement is 
practically effective at the cost of uncertain risk.

Yeah. Going this route is risky. The alternative though is all our eggs in the 
G1GC basket which is also a risk. This route of offheaping is looking promising 
(Anoop and Ram have a nice blog that will be up soon). We could end up in a new 
world of unexplained stop-the-worlds because of these offheap machinations and 
if they were unfixable, we'd have to call this (expensive) experiment a 
faillure but so far the results look good.

Thanks [~ikeda]. Keep the feedback coming.

On this patch, do we want to make it use utils before we commit?

> 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