Eliminate some redundant block reads.
Summary: Re-use metadata for reading Compression Dictionary on BlockBased table open, this saves two reads from disk. This helps to our 999 percentile in 5.6.1 where prefetch buffer is not present. Closes https://github.com/facebook/rocksdb/pull/3354 Differential Revision: D6695753 Pulled By: ajkr fbshipit-source-id: bb8acd9e9e66e65b89c548ab8940570ae360333c
This commit is contained in:
parent
0c6e8be9e2
commit
b010116d82
@ -759,23 +759,27 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions,
|
|||||||
|
|
||||||
// Read the compression dictionary meta block
|
// Read the compression dictionary meta block
|
||||||
bool found_compression_dict;
|
bool found_compression_dict;
|
||||||
s = SeekToCompressionDictBlock(meta_iter.get(), &found_compression_dict);
|
BlockHandle compression_dict_handle;
|
||||||
|
s = SeekToCompressionDictBlock(meta_iter.get(), &found_compression_dict,
|
||||||
|
&compression_dict_handle);
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
ROCKS_LOG_WARN(
|
ROCKS_LOG_WARN(
|
||||||
rep->ioptions.info_log,
|
rep->ioptions.info_log,
|
||||||
"Error when seeking to compression dictionary block from file: %s",
|
"Error when seeking to compression dictionary block from file: %s",
|
||||||
s.ToString().c_str());
|
s.ToString().c_str());
|
||||||
} else if (found_compression_dict) {
|
} else if (found_compression_dict && !compression_dict_handle.IsNull()) {
|
||||||
// TODO(andrewkr): Add to block cache if cache_index_and_filter_blocks is
|
// TODO(andrewkr): Add to block cache if cache_index_and_filter_blocks is
|
||||||
// true.
|
// true.
|
||||||
unique_ptr<BlockContents> compression_dict_block{new BlockContents()};
|
std::unique_ptr<BlockContents> compression_dict_cont{new BlockContents()};
|
||||||
// TODO(andrewkr): ReadMetaBlock repeats SeekToCompressionDictBlock().
|
PersistentCacheOptions cache_options;
|
||||||
// maybe decode a handle from meta_iter
|
ReadOptions read_options;
|
||||||
// and do ReadBlockContents(handle) instead
|
read_options.verify_checksums = false;
|
||||||
s = rocksdb::ReadMetaBlock(rep->file.get(), prefetch_buffer.get(),
|
BlockFetcher compression_block_fetcher(
|
||||||
file_size, kBlockBasedTableMagicNumber,
|
rep->file.get(), prefetch_buffer.get(), rep->footer, read_options,
|
||||||
rep->ioptions, rocksdb::kCompressionDictBlock,
|
compression_dict_handle, compression_dict_cont.get(), rep->ioptions, false /* decompress */,
|
||||||
compression_dict_block.get());
|
Slice() /*compression dict*/, cache_options);
|
||||||
|
s = compression_block_fetcher.ReadBlockContents();
|
||||||
|
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
ROCKS_LOG_WARN(
|
ROCKS_LOG_WARN(
|
||||||
rep->ioptions.info_log,
|
rep->ioptions.info_log,
|
||||||
@ -783,7 +787,7 @@ Status BlockBasedTable::Open(const ImmutableCFOptions& ioptions,
|
|||||||
"block %s",
|
"block %s",
|
||||||
s.ToString().c_str());
|
s.ToString().c_str());
|
||||||
} else {
|
} else {
|
||||||
rep->compression_dict_block = std::move(compression_dict_block);
|
rep->compression_dict_block = std::move(compression_dict_cont);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +215,9 @@ Status SeekToPropertiesBlock(InternalIterator* meta_iter, bool* is_found) {
|
|||||||
|
|
||||||
// Seek to the compression dictionary block.
|
// Seek to the compression dictionary block.
|
||||||
// Return true if it successfully seeks to that block.
|
// Return true if it successfully seeks to that block.
|
||||||
Status SeekToCompressionDictBlock(InternalIterator* meta_iter, bool* is_found) {
|
Status SeekToCompressionDictBlock(InternalIterator* meta_iter, bool* is_found,
|
||||||
return SeekToMetaBlock(meta_iter, kCompressionDictBlock, is_found);
|
BlockHandle* block_handle) {
|
||||||
|
return SeekToMetaBlock(meta_iter, kCompressionDictBlock, is_found, block_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status SeekToRangeDelBlock(InternalIterator* meta_iter, bool* is_found,
|
Status SeekToRangeDelBlock(InternalIterator* meta_iter, bool* is_found,
|
||||||
|
@ -21,7 +21,8 @@ Status SeekToPropertiesBlock(InternalIterator* meta_iter, bool* is_found);
|
|||||||
// Seek to the compression dictionary block.
|
// Seek to the compression dictionary block.
|
||||||
// If it successfully seeks to the properties block, "is_found" will be
|
// If it successfully seeks to the properties block, "is_found" will be
|
||||||
// set to true.
|
// set to true.
|
||||||
Status SeekToCompressionDictBlock(InternalIterator* meta_iter, bool* is_found);
|
Status SeekToCompressionDictBlock(InternalIterator* meta_iter, bool* is_found,
|
||||||
|
BlockHandle* block_handle);
|
||||||
|
|
||||||
// TODO(andrewkr) should not put all meta block in table_properties.h/cc
|
// TODO(andrewkr) should not put all meta block in table_properties.h/cc
|
||||||
Status SeekToRangeDelBlock(InternalIterator* meta_iter, bool* is_found,
|
Status SeekToRangeDelBlock(InternalIterator* meta_iter, bool* is_found,
|
||||||
|
Loading…
Reference in New Issue
Block a user