-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-30225 Performance degradation observed on ycsb reads benchmark after HBASE-29727 #8353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |
| import org.apache.hadoop.hbase.regionserver.KeyValueScanner; | ||
| import org.apache.hadoop.hbase.util.ByteBufferUtils; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.hadoop.hbase.util.HFileArchiveUtil; | ||
| import org.apache.hadoop.hbase.util.IdLock; | ||
| import org.apache.hadoop.hbase.util.ObjectIntPair; | ||
| import org.apache.hadoop.io.WritableUtils; | ||
|
|
@@ -124,6 +125,14 @@ public abstract class HFileReaderImpl implements HFile.Reader, Configurable { | |
| /** Minor versions starting with this number have faked index key */ | ||
| static final int MINOR_VERSION_WITH_FAKED_KEY = 3; | ||
|
|
||
| private final String fileName; | ||
|
|
||
| private final String region; | ||
|
|
||
| private final String family; | ||
|
|
||
| private final boolean archived; | ||
|
|
||
| /** | ||
| * Opens a HFile. | ||
| * @param context Reader context info | ||
|
|
@@ -149,6 +158,10 @@ public HFileReaderImpl(ReaderContext context, HFileInfo fileInfo, CacheConfig ca | |
| fsBlockReader.setDataBlockEncoder(dataBlockEncoder, conf); | ||
| dataBlockIndexReader = fileInfo.getDataBlockIndexReader(); | ||
| metaBlockIndexReader = fileInfo.getMetaBlockIndexReader(); | ||
| fileName = path.getName(); | ||
| family = path.getParent().getName(); | ||
| region = path.getParent().getParent().getName(); | ||
| archived = HFileArchiveUtil.isHFileArchived(path); | ||
| } | ||
|
|
||
| @SuppressWarnings("serial") | ||
|
|
@@ -1246,8 +1259,8 @@ public HFileBlock getMetaBlock(String metaBlockName, boolean cacheBlock) throws | |
| synchronized (metaBlockIndexReader.getRootBlockKey(block)) { | ||
| // Check cache for block. If found return. | ||
| long metaBlockOffset = metaBlockIndexReader.getRootBlockOffset(block); | ||
| BlockCacheKey cacheKey = | ||
| new BlockCacheKey(path, metaBlockOffset, this.isPrimaryReplicaReader(), BlockType.META); | ||
| BlockCacheKey cacheKey = new BlockCacheKey(fileName, family, region, metaBlockOffset, | ||
| this.isPrimaryReplicaReader(), BlockType.META, archived); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is one of the optimization right? We calculate archived once when constructing the HFileReaderImpl, and do not need to calcuate it every time when constructing a BlockCacheKey?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Same for region and CF name. |
||
|
|
||
| cacheBlock &= | ||
| cacheConf.shouldCacheBlockOnRead(BlockType.META.getCategory(), getHFileInfo(), conf); | ||
|
|
@@ -1336,9 +1349,8 @@ public HFileBlock readBlock(long dataBlockOffset, long onDiskBlockSize, final bo | |
| // the other choice is to duplicate work (which the cache would prevent you | ||
| // from doing). | ||
|
|
||
| BlockCacheKey cacheKey = | ||
| new BlockCacheKey(path, dataBlockOffset, this.isPrimaryReplicaReader(), expectedBlockType); | ||
|
|
||
| BlockCacheKey cacheKey = new BlockCacheKey(fileName, family, region, dataBlockOffset, | ||
| this.isPrimaryReplicaReader(), expectedBlockType, archived); | ||
| boolean useLock = false; | ||
| IdLock.Entry lockEntry = null; | ||
| final Span span = Span.current(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why here we can use false directly?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are actually only using this constructor on tests now. Because the HFileUtils.isArchived call seems too expensive to be performed on every block cache key creation, that check should be delegated to the reader, which can do it once during it's initialisation. Writers don't even need it, since a being written file is guaranteed to be "non-archived", so writers can benefit from constructors that alwas set archived as false. Let me add javadoc to explain this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why not just remoev this flag in BlockCacheKey if it does not change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might change when it's created by a Reader (see HFileReaderImpl#1352).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then can we just remove this constructor? Or leave the code as is since it only calls from test code? It does not affect real performance if it only calls in test code right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.