-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
BlockBasedTableReader: automatically adjust tail prefetch size #4156
Closed
Closed
Changes from all commits
Commits
Show all changes
3 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 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 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 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 |
---|---|---|
|
@@ -26,6 +26,22 @@ struct EnvOptions; | |
using std::unique_ptr; | ||
class BlockBasedTableBuilder; | ||
|
||
// A class used to track actual bytes written from the tail in the recent SST | ||
// file opens, and provide a suggestion for following open. | ||
class TailPrefetchStats { | ||
public: | ||
void RecordEffectiveSize(size_t len); | ||
// 0 indicates no information to determine. | ||
size_t GetSuggestedPrefetchSize(); | ||
|
||
private: | ||
const static size_t kNumTracked = 32; | ||
size_t records_[kNumTracked]; | ||
port::Mutex mutex_; | ||
size_t next_ = 0; | ||
size_t num_records_ = 0; | ||
}; | ||
|
||
class BlockBasedTableFactory : public TableFactory { | ||
public: | ||
explicit BlockBasedTableFactory( | ||
|
@@ -64,6 +80,7 @@ class BlockBasedTableFactory : public TableFactory { | |
|
||
private: | ||
BlockBasedTableOptions table_options_; | ||
mutable TailPrefetchStats tail_prefetch_stats_; | ||
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. I think it might be useful to export these stats and see a distribution (for later; not immediately needed). |
||
}; | ||
|
||
extern const std::string kHashIndexPrefixesBlock; | ||
|
This file contains 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 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.
Maybe its just me, but this for loop was somehow more complicated for me to understand.
My thought process was: For
read
, the value is multiplied by the array size. But forwasted
, you are only multiplying with the current index ... why not multiply by the array size here too similar to read? Ultimately I realized that the wasted space for all subsequent reads should be considered as 0; and hence the algorithm works. (You did mention in the comments, but somehow it wasn't immediately obvious even after reading the comment).