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 <[email protected]> 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 | > ============================= >
