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

Zephyr Guo commented on HBASE-14490:
------------------------------------

[~anoop.hbase] Thanks for your review.

{quote}
 If read alone is the consideration, it is high?
{quote}
Seem big.How about 16K?I have no test.Just experience...
Dynamic adjustment is better?Set it to average at sometime.
{quote}
We need to have check <= ?
{quote}
No.
If dataLength==READ_REQ_REUSED_BUF_SIZE, we can use it exactly.

{quote}
processRequest(ByteBuffer buf)
{quote}
I will improve the method.

{quote}
The 'unwrappedData' ref set to be null now. But we dont do that for data. That 
be an issue? Why dont going with SoftRef way here? Am I missing some thing?
{quote}

invoking chain:
process —> saslReadAndProcess —> processUnwrappedData

Supposing we come into processUnwrappedData now.Define A as reused buffer and B 
as temporary buffer(a large buffer).

{{data}} is not null obviously(reference to A or B) and it has no useful data 
to read.So we just use {{data}} again.
 
In the end of {{process}}, we do {{data = null}}. If {{data}} is A, the BB will 
be reference by SoftRef only.If data is B, no one reference to it.

Because we have no variable {{unwrappedData}}, so we can clear buffer 
uniformly.Just set data to be null in end of {{process}}.

{quote}
U mean call to evaluateResponse occurs just once? After that the boolean 
saslContextEstablished will be true.
{quote}
At least occur one time.I just want to say ‘evaluateResponse(byte[] rsp, int 
off, int len) is best’.But SASL API not look like this currently.So we have to 
copy.
{code}
replyToken = saslServer.evaluateResponse(
            new Bytes(saslToken.array(), saslToken.position(), 
saslToken.remaining()).copyBytes());
{code}
I mark here by ’TODO’.If the API be improved in the future, we can modify 
here.If there misunderstanding , can remove.It’s not important.


> [RpcServer] reuse request read buffer
> -------------------------------------
>
>                 Key: HBASE-14490
>                 URL: https://issues.apache.org/jira/browse/HBASE-14490
>             Project: HBase
>          Issue Type: Improvement
>          Components: IPC/RPC
>    Affects Versions: 2.0.0, 1.0.2
>            Reporter: Zephyr Guo
>            Assignee: Zephyr Guo
>              Labels: performance
>             Fix For: 2.0.0, 1.0.2
>
>         Attachments: HBASE-14490-v1.patch, HBASE-14490-v2.patch, 
> HBASE-14490-v3.patch, HBASE-14490-v4.patch, HBASE-14490-v5.patch, 
> HBASE-14490-v6.patch, HBASE-14490-v7.patch, HBASE-14490-v8.patch, 
> HBASE-14490-v9.patch
>
>
> Reuse buffer to read request.It's not necessary free data's buffer for each 
> request.Optimization is to reduce the times that allocate ByteBuffer.
> *patch modification*
> * {{saslReadAndProcess}} and {{processOneRpc}} accept a ByteBuffer instead of 
> byte[].
> * {{processUnwrappedData}} can reuse the same ByteBuffer that 
> {{saslReadAndProcess}} used.
> * Maintaining a reused ByteBuffer each {{Reader}} for most request.
> ** Buffer size is fixed.
> ** Using a SoftReference to reference the buffer.
> ** If request is too large, we allocate a temporary ByteBuffer.Freeing it 
> when  {{process()}} will have been finished.



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

Reply via email to