Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-24915

Improve BlockCache read performance by specifying BlockType

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-alpha-1
    • BlockCache, Performance
    • None
    • Reviewed

    Description

      CombinedBlockCache contains l1Cache and l2Cache. l1Cache stores MetaBlock and l2Cache stores DataBlock. Because getBlock does not know the BlockType, the getBlock of CombinedBlockCache queries l1Cache first, and then l2Cache. But actually querying DataBlock is not necessary to query l1Cache.

      Therefore, in some cases where BlockType is known, BlockCache read performance can be improved.

      Codeļ¼š

      BlockCache: default call old getBlock

      default Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat,
          boolean updateCacheMetrics, BlockType blockType) {
        return getBlock(cacheKey, caching, repeat, updateCacheMetrics);
      }
      

      CombinedBlockCache:

      @Override
      public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat,
          boolean updateCacheMetrics, BlockType blockType) {
        if (blockType == null) {
          return getBlock(cacheKey, caching, repeat, updateCacheMetrics);
        }
        boolean metaBlock = isMetaBlock(blockType);
        if (metaBlock) {
          return l1Cache.getBlock(cacheKey, caching, repeat, updateCacheMetrics);
        } else {
          return l2Cache.getBlock(cacheKey, caching, repeat, updateCacheMetrics);
        }
      }private boolean isMetaBlock(BlockType blockType) {
        return blockType.getCategory() != BlockCategory.DATA;
      }
      

      HFileReaderImpl#getCachedBlock call BlockCache#getBlock(XXX, expectedBlockType)

      Attachments

        Issue Links

          Activity

            People

              fanrui fanrui
              fanrui fanrui
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: