[ https://issues.apache.org/jira/browse/HBASE-24915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Stack resolved HBASE-24915. ----------------------------------- Hadoop Flags: Reviewed Resolution: Fixed Added you as a contributor [~fanrui] . Thanks for the patch (Thanks for review [~vjasani] ) > Improve BlockCache read performance by specifying BlockType > ----------------------------------------------------------- > > Key: HBASE-24915 > URL: https://issues.apache.org/jira/browse/HBASE-24915 > Project: HBase > Issue Type: Improvement > Components: BlockCache, Performance > Reporter: fanrui > Assignee: fanrui > Priority: Major > > 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. > h2. Code: > BlockCache: default call old getBlock > {code:java} > default Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean > repeat, > boolean updateCacheMetrics, BlockType blockType) { > return getBlock(cacheKey, caching, repeat, updateCacheMetrics); > } > {code} > CombinedBlockCache: > {code:java} > @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; > } > {code} > HFileReaderImpl#getCachedBlock call BlockCache#getBlock(XXX, > expectedBlockType) -- This message was sent by Atlassian Jira (v8.3.4#803005)