hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BlueDavy Lin <blued...@gmail.com>
Subject can readBlock change to this for improving performance
Date Wed, 27 Jul 2011 14:56:51 GMT
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                |
=============================

Mime
View raw message