mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' into perf
This commit is contained in:
@@ -272,7 +272,8 @@ void BlockBasedTableBuilder::WriteRawBlock(const Slice& block_contents,
|
||||
CompressionType type,
|
||||
BlockHandle* handle) {
|
||||
Rep* r = rep_;
|
||||
StopWatch sw(r->options.env, r->options.statistics, WRITE_RAW_BLOCK_MICROS);
|
||||
StopWatch sw(r->options.env, r->options.statistics.get(),
|
||||
WRITE_RAW_BLOCK_MICROS);
|
||||
handle->set_offset(r->offset);
|
||||
handle->set_size(block_contents.size());
|
||||
r->status = r->file->Append(block_contents);
|
||||
@@ -530,8 +531,8 @@ Status BlockBasedTableBuilder::Finish() {
|
||||
Log(
|
||||
r->options.info_log,
|
||||
"Table was constructed:\n"
|
||||
" basic properties: %s\n"
|
||||
" user collected properties: %s",
|
||||
" [basic properties]: %s\n"
|
||||
" [user collected properties]: %s",
|
||||
r->props.ToString().c_str(),
|
||||
user_collected.c_str()
|
||||
);
|
||||
|
||||
@@ -29,7 +29,8 @@ Status BlockBasedTableFactory::GetTableReader(
|
||||
TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
||||
const Options& options, WritableFile* file,
|
||||
CompressionType compression_type) const {
|
||||
auto flush_block_policy_factory = flush_block_policy_factory_.get();
|
||||
auto flush_block_policy_factory =
|
||||
table_options_.flush_block_policy_factory.get();
|
||||
|
||||
// if flush block policy factory is not set, we'll create the default one
|
||||
// from the options.
|
||||
@@ -54,7 +55,8 @@ TableBuilder* BlockBasedTableFactory::GetTableBuilder(
|
||||
// options.
|
||||
// We can safely delete flush_block_policy_factory since it will only be used
|
||||
// during the construction of `BlockBasedTableBuilder`.
|
||||
if (flush_block_policy_factory != flush_block_policy_factory_.get()) {
|
||||
if (flush_block_policy_factory !=
|
||||
table_options_.flush_block_policy_factory.get()) {
|
||||
delete flush_block_policy_factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,14 +31,18 @@ class BlockBasedTableBuilder;
|
||||
|
||||
class BlockBasedTableFactory: public TableFactory {
|
||||
public:
|
||||
// @flush_block_policy_factory creates the instances of flush block policy.
|
||||
// which provides a configurable way to determine when to flush a block in
|
||||
// the block based tables. If not set, table builder will use the default
|
||||
// block flush policy, which cut blocks by block size (please refer to
|
||||
// `FlushBlockBySizePolicy`).
|
||||
BlockBasedTableFactory(
|
||||
FlushBlockPolicyFactory* flush_block_policy_factory = nullptr) :
|
||||
flush_block_policy_factory_(flush_block_policy_factory) {
|
||||
struct TableOptions {
|
||||
// @flush_block_policy_factory creates the instances of flush block policy.
|
||||
// which provides a configurable way to determine when to flush a block in
|
||||
// the block based tables. If not set, table builder will use the default
|
||||
// block flush policy, which cut blocks by block size (please refer to
|
||||
// `FlushBlockBySizePolicy`).
|
||||
std::shared_ptr<FlushBlockPolicyFactory> flush_block_policy_factory;
|
||||
};
|
||||
|
||||
BlockBasedTableFactory() : BlockBasedTableFactory(TableOptions()) { }
|
||||
BlockBasedTableFactory(const TableOptions& table_options):
|
||||
table_options_(table_options) {
|
||||
}
|
||||
|
||||
~BlockBasedTableFactory() {
|
||||
@@ -58,7 +62,8 @@ public:
|
||||
override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<FlushBlockPolicyFactory> flush_block_policy_factory_;
|
||||
TableOptions table_options_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace rocksdb
|
||||
|
||||
@@ -200,7 +200,7 @@ Cache::Handle* GetFromBlockCache(
|
||||
const Slice& key,
|
||||
Tickers block_cache_miss_ticker,
|
||||
Tickers block_cache_hit_ticker,
|
||||
std::shared_ptr<Statistics> statistics) {
|
||||
Statistics* statistics) {
|
||||
auto cache_handle = block_cache->Lookup(key);
|
||||
if (cache_handle != nullptr) {
|
||||
BumpPerfCount(&perf_context.block_cache_hit_count);
|
||||
@@ -515,7 +515,7 @@ Status BlockBasedTable::GetBlock(
|
||||
CachableEntry<Block>* entry) {
|
||||
bool no_io = options.read_tier == kBlockCacheTier;
|
||||
Cache* block_cache = table->rep_->options.block_cache.get();
|
||||
auto statistics = table->rep_->options.statistics;
|
||||
Statistics* statistics = table->rep_->options.statistics.get();
|
||||
Status s;
|
||||
|
||||
if (block_cache != nullptr) {
|
||||
@@ -532,7 +532,7 @@ Status BlockBasedTable::GetBlock(
|
||||
key,
|
||||
block_cache_miss_ticker,
|
||||
block_cache_hit_ticker,
|
||||
table->rep_->options.statistics
|
||||
statistics
|
||||
);
|
||||
|
||||
if (entry->cache_handle != nullptr) {
|
||||
@@ -593,7 +593,7 @@ Iterator* BlockBasedTable::BlockReader(void* arg,
|
||||
Cache* block_cache = table->rep_->options.block_cache.get();
|
||||
Cache* block_cache_compressed = table->rep_->options.
|
||||
block_cache_compressed.get();
|
||||
std::shared_ptr<Statistics> statistics = table->rep_->options.statistics;
|
||||
Statistics* statistics = table->rep_->options.statistics.get();
|
||||
Block* block = nullptr;
|
||||
Block* cblock = nullptr;
|
||||
Cache::Handle* cache_handle = nullptr;
|
||||
@@ -791,12 +791,13 @@ BlockBasedTable::GetFilter(bool no_io) const {
|
||||
cache_key
|
||||
);
|
||||
|
||||
Statistics* statistics = rep_->options.statistics.get();
|
||||
auto cache_handle = GetFromBlockCache(
|
||||
block_cache,
|
||||
key,
|
||||
BLOCK_CACHE_FILTER_MISS,
|
||||
BLOCK_CACHE_FILTER_HIT,
|
||||
rep_->options.statistics
|
||||
statistics
|
||||
);
|
||||
|
||||
FilterBlockReader* filter = nullptr;
|
||||
@@ -824,7 +825,7 @@ BlockBasedTable::GetFilter(bool no_io) const {
|
||||
|
||||
cache_handle = block_cache->Insert(
|
||||
key, filter, filter_size, &DeleteCachedFilter);
|
||||
RecordTick(rep_->options.statistics, BLOCK_CACHE_ADD);
|
||||
RecordTick(statistics, BLOCK_CACHE_ADD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -945,9 +946,10 @@ bool BlockBasedTable::PrefixMayMatch(const Slice& internal_prefix) {
|
||||
filter_entry.Release(rep_->options.block_cache.get());
|
||||
}
|
||||
|
||||
RecordTick(rep_->options.statistics, BLOOM_FILTER_PREFIX_CHECKED);
|
||||
Statistics* statistics = rep_->options.statistics.get();
|
||||
RecordTick(statistics, BLOOM_FILTER_PREFIX_CHECKED);
|
||||
if (!may_match) {
|
||||
RecordTick(rep_->options.statistics, BLOOM_FILTER_PREFIX_USEFUL);
|
||||
RecordTick(statistics, BLOOM_FILTER_PREFIX_USEFUL);
|
||||
}
|
||||
|
||||
return may_match;
|
||||
@@ -997,7 +999,7 @@ Status BlockBasedTable::Get(
|
||||
// Not found
|
||||
// TODO: think about interaction with Merge. If a user key cannot
|
||||
// cross one data block, we should be fine.
|
||||
RecordTick(rep_->options.statistics, BLOOM_FILTER_USEFUL);
|
||||
RecordTick(rep_->options.statistics.get(), BLOOM_FILTER_USEFUL);
|
||||
break;
|
||||
} else {
|
||||
bool didIO = false;
|
||||
|
||||
Reference in New Issue
Block a user