You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by BlueDavy Lin <bl...@gmail.com> on 2011/07/27 16:56:51 UTC
can readBlock change to this for improving performance
hi!
In hbase 0.90.2, HFile$Reader readBlock do this:
synchronized (blockIndex.blockKeys[block]) {
blockLoads++;
// Check cache for block. If found return.
if (cache != null) {
ByteBuffer cachedBuf = cache.getBlock(name + block, cacheBlock);
if (cachedBuf != null) {
// Return a distinct 'shallow copy' of the block,
// so pos doesnt get messed by the scanner
cacheHits++;
return cachedBuf.duplicate();
}
// Carry on, please load.
}
// load from file
// put to cache
}
Why check cache code snippets be wrote in synchronized? I think we
can also do the check cache for block code outside the synchronized,so
we can improve performance.
--
=============================
| BlueDavy |
| http://www.bluedavy.com |
=============================
Re: can readBlock change to this for improving performance
Posted by Stack <st...@duboce.net>.
What you thinking? That we do the below call twice?
ByteBuffer cachedBuf = cache.getBlock(name + block, cacheBlock);
Once before we go into the synchronized block (and if it returns a
non-null value, return) and then a second time once inside the
synchronized block?
Have you tried it? Do you see a speedup?
Thanks,
St.Ack
On Wed, Jul 27, 2011 at 7:56 AM, BlueDavy Lin <bl...@gmail.com> wrote:
> hi!
>
> In hbase 0.90.2, HFile$Reader readBlock do this:
> synchronized (blockIndex.blockKeys[block]) {
> blockLoads++;
> // Check cache for block. If found return.
> if (cache != null) {
> ByteBuffer cachedBuf = cache.getBlock(name + block, cacheBlock);
> if (cachedBuf != null) {
> // Return a distinct 'shallow copy' of the block,
> // so pos doesnt get messed by the scanner
> cacheHits++;
> return cachedBuf.duplicate();
> }
> // Carry on, please load.
> }
>
> // load from file
>
> // put to cache
> }
>
> Why check cache code snippets be wrote in synchronized? I think we
> can also do the check cache for block code outside the synchronized,so
> we can improve performance.
>
> --
> =============================
> | BlueDavy |
> | http://www.bluedavy.com |
> =============================
>