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

Zheng Hu commented on HBASE-22802:
----------------------------------

Sounds good to do this.  Few questions: 
1. The ByteBuffAllocator#allocate(length) will get a ByteBuff (composited by 
multi nio ByteBuffers), while the fileChannel#read (from JDK) can only accept 
nio ByteBuffers,  so we need to read ByteBuffer one by one for a MultiByteBuff 
?  I think so.
2.  When to release the ByteBuff ?  Seems we can release the ByteBuff once the 
Cacheable#release it. 

Thanks.

> Avoid temp ByteBuffer allocation in FileIOEngine#read
> -----------------------------------------------------
>
>                 Key: HBASE-22802
>                 URL: https://issues.apache.org/jira/browse/HBASE-22802
>             Project: HBase
>          Issue Type: Improvement
>          Components: BucketCache
>            Reporter: chenxu
>            Priority: Major
>         Attachments: profile_mem_alloc.png
>
>
> a temp ByteBuffer was allocated each time FileIOEngine#read was called
> {code:java}
> public Cacheable read(BucketEntry be) throws IOException {
>   long offset = be.offset();
>   int length = be.getLength();
>   Preconditions.checkArgument(length >= 0, "Length of read can not be less 
> than 0.");
>   ByteBuffer dstBuffer = ByteBuffer.allocate(length);
>   ...
> }
> {code}
> we can avoid this by use of ByteBuffAllocator#allocate(length) after 
> HBASE-21879



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to