-
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
Open
wchevreuil
wants to merge
2
commits into
apache:master
Choose a base branch
from
wchevreuil:HBASE-30225
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−15
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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? |
||
|
|
||
| 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(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?