Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
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
- links to