Skip to content

Commit

Permalink
Internal stats pass through
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Jan 15, 2025
1 parent 5938ad2 commit afcda27
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 22 deletions.
1 change: 1 addition & 0 deletions db/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ Status BuildTable(
std::unique_ptr<InternalIterator> it(table_cache->NewIterator(
tboptions.read_options, file_options, tboptions.internal_comparator,
*meta, nullptr /* range_del_agg */, mutable_cf_options, nullptr,
(internal_stats == nullptr) ? nullptr : nullptr,
(internal_stats == nullptr) ? nullptr
: internal_stats->GetFileReadHist(0),
TableReaderCaller::kFlush, /*arena=*/nullptr,
Expand Down
2 changes: 1 addition & 1 deletion db/column_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class ColumnFamilyData {
const DBOptions& db_options,
const std::unordered_map<std::string, std::string>& options_map);

InternalStats* internal_stats() { return internal_stats_.get(); }
InternalStats* internal_stats() const { return internal_stats_.get(); }

MemTableList* imm() { return &imm_; }
MemTable* mem() { return mem_; }
Expand Down
2 changes: 1 addition & 1 deletion db/compaction/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ Status CompactionJob::Run() {
cfd->internal_comparator(), files_output[file_idx]->meta,
/*range_del_agg=*/nullptr,
*compact_->compaction->mutable_cf_options(),
/*table_reader_ptr=*/nullptr,
/*table_reader_ptr=*/nullptr, cfd->internal_stats(),
cfd->internal_stats()->GetFileReadHist(
compact_->compaction->output_level()),
TableReaderCaller::kCompactionRefill, /*arena=*/nullptr,
Expand Down
16 changes: 10 additions & 6 deletions db/forward_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ForwardLevelIterator : public InternalIterator {
*files_[file_index_],
read_options_.ignore_range_deletions ? nullptr : &range_del_agg,
mutable_cf_options_, /*table_reader_ptr=*/nullptr,
cfd_->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kUserIterator,
/*arena=*/nullptr, /*skip_filters=*/false, /*level=*/-1,
/*max_file_size_for_l0_meta_pin=*/0,
Expand Down Expand Up @@ -749,8 +750,9 @@ void ForwardIterator::RebuildIterators(bool refresh_sv) {
read_options_, *cfd_->soptions(), cfd_->internal_comparator(), *l0,
read_options_.ignore_range_deletions ? nullptr : &range_del_agg,
sv_->mutable_cf_options,
/*table_reader_ptr=*/nullptr, /*file_read_hist=*/nullptr,
TableReaderCaller::kUserIterator, /*arena=*/nullptr,
/*table_reader_ptr=*/nullptr, cfd_->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kUserIterator,
/*arena=*/nullptr,
/*skip_filters=*/false, /*level=*/-1,
MaxFileSizeForL0MetaPin(sv_->mutable_cf_options),
/*smallest_compaction_key=*/nullptr,
Expand Down Expand Up @@ -837,8 +839,9 @@ void ForwardIterator::RenewIterators() {
*l0_files_new[inew],
read_options_.ignore_range_deletions ? nullptr : &range_del_agg,
svnew->mutable_cf_options,
/*table_reader_ptr=*/nullptr, /*file_read_hist=*/nullptr,
TableReaderCaller::kUserIterator, /*arena=*/nullptr,
/*table_reader_ptr=*/nullptr, cfd_->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kUserIterator,
/*arena=*/nullptr,
/*skip_filters=*/false, /*level=*/-1,
MaxFileSizeForL0MetaPin(svnew->mutable_cf_options),
/*smallest_compaction_key=*/nullptr,
Expand Down Expand Up @@ -902,8 +905,9 @@ void ForwardIterator::ResetIncompleteIterators() {
l0_iters_[i] = cfd_->table_cache()->NewIterator(
read_options_, *cfd_->soptions(), cfd_->internal_comparator(),
*l0_files[i], /*range_del_agg=*/nullptr, sv_->mutable_cf_options,
/*table_reader_ptr=*/nullptr, /*file_read_hist=*/nullptr,
TableReaderCaller::kUserIterator, /*arena=*/nullptr,
/*table_reader_ptr=*/nullptr, cfd_->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kUserIterator,
/*arena=*/nullptr,
/*skip_filters=*/false, /*level=*/-1,
MaxFileSizeForL0MetaPin(sv_->mutable_cf_options),
/*smallest_compaction_key=*/nullptr,
Expand Down
5 changes: 3 additions & 2 deletions db/repair.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,9 @@ class Repairer {
InternalIterator* iter = table_cache_->NewIterator(
ropts, file_options_, cfd->internal_comparator(), t->meta,
nullptr /* range_del_agg */, *cfd->GetLatestMutableCFOptions(),
/*table_reader_ptr=*/nullptr, /*file_read_hist=*/nullptr,
TableReaderCaller::kRepair, /*arena=*/nullptr, /*skip_filters=*/false,
/*table_reader_ptr=*/nullptr, cfd->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kRepair,
/*arena=*/nullptr, /*skip_filters=*/false,
/*level=*/-1, /*max_file_size_for_l0_meta_pin=*/0,
/*smallest_compaction_key=*/nullptr,
/*largest_compaction_key=*/nullptr,
Expand Down
5 changes: 3 additions & 2 deletions db/table_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ InternalIterator* TableCache::NewIterator(
const InternalKeyComparator& icomparator, const FileMetaData& file_meta,
RangeDelAggregator* range_del_agg,
const MutableCFOptions& mutable_cf_options, TableReader** table_reader_ptr,
HistogramImpl* file_read_hist, TableReaderCaller caller, Arena* arena,
bool skip_filters, int level, size_t max_file_size_for_l0_meta_pin,
InternalStats* internal_stats, HistogramImpl* file_read_hist,
TableReaderCaller caller, Arena* arena, bool skip_filters, int level,
size_t max_file_size_for_l0_meta_pin,
const InternalKey* smallest_compaction_key,
const InternalKey* largest_compaction_key, bool allow_unprepared_value,
const SequenceNumber* read_seqno,
Expand Down
7 changes: 4 additions & 3 deletions db/table_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "cache/typed_cache.h"
#include "db/dbformat.h"
#include "db/internal_stats.h"
#include "db/range_del_aggregator.h"
#include "options/cf_options.h"
#include "port/port.h"
Expand Down Expand Up @@ -93,9 +94,9 @@ class TableCache {
const InternalKeyComparator& internal_comparator,
const FileMetaData& file_meta, RangeDelAggregator* range_del_agg,
const MutableCFOptions& mutable_cf_options,
TableReader** table_reader_ptr, HistogramImpl* file_read_hist,
TableReaderCaller caller, Arena* arena, bool skip_filters, int level,
size_t max_file_size_for_l0_meta_pin,
TableReader** table_reader_ptr, InternalStats* internal_stats,
HistogramImpl* file_read_hist, TableReaderCaller caller, Arena* arena,
bool skip_filters, int level, size_t max_file_size_for_l0_meta_pin,
const InternalKey* smallest_compaction_key,
const InternalKey* largest_compaction_key, bool allow_unprepared_value,
const SequenceNumber* range_del_read_seqno = nullptr,
Expand Down
18 changes: 11 additions & 7 deletions db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,9 @@ class LevelIterator final : public InternalIterator {
TableCache* table_cache, const ReadOptions& read_options,
const FileOptions& file_options, const InternalKeyComparator& icomparator,
const LevelFilesBrief* flevel, const MutableCFOptions& mutable_cf_options,
bool should_sample, HistogramImpl* file_read_hist,
TableReaderCaller caller, bool skip_filters, int level,
RangeDelAggregator* range_del_agg,
bool should_sample, InternalStats* internal_stats,
HistogramImpl* file_read_hist, TableReaderCaller caller,
bool skip_filters, int level, RangeDelAggregator* range_del_agg,
const std::vector<AtomicCompactionUnitBoundary>* compaction_boundaries =
nullptr,
bool allow_unprepared_value = false,
Expand All @@ -987,6 +987,7 @@ class LevelIterator final : public InternalIterator {
flevel_(flevel),
mutable_cf_options_(mutable_cf_options),
prefix_extractor_(mutable_cf_options.prefix_extractor.get()),
internal_stats_(internal_stats),
file_read_hist_(file_read_hist),
caller_(caller),
file_index_(flevel_->num_files),
Expand Down Expand Up @@ -1149,7 +1150,8 @@ class LevelIterator final : public InternalIterator {
return table_cache_->NewIterator(
read_options_, file_options_, icomparator_, *file_meta.file_metadata,
range_del_agg_, mutable_cf_options_,
nullptr /* don't need reference to table */, file_read_hist_, caller_,
nullptr /* don't need reference to table */, internal_stats_,
file_read_hist_, caller_,
/*arena=*/nullptr, skip_filters_, level_,
/*max_file_size_for_l0_meta_pin=*/0, smallest_compaction_key,
largest_compaction_key, allow_unprepared_value_, &read_seq_,
Expand Down Expand Up @@ -1180,6 +1182,7 @@ class LevelIterator final : public InternalIterator {
const MutableCFOptions& mutable_cf_options_;
const SliceTransform* prefix_extractor_;

InternalStats* internal_stats_;
HistogramImpl* file_read_hist_;
TableReaderCaller caller_;
size_t file_index_;
Expand Down Expand Up @@ -2038,7 +2041,8 @@ void Version::AddIteratorsForLevel(const ReadOptions& read_options,
auto table_iter = cfd_->table_cache()->NewIterator(
read_options, soptions, cfd_->internal_comparator(),
*file.file_metadata, /*range_del_agg=*/nullptr, mutable_cf_options_,
nullptr, cfd_->internal_stats()->GetFileReadHist(0),
nullptr, cfd_->internal_stats(),
cfd_->internal_stats()->GetFileReadHist(0),
TableReaderCaller::kUserIterator, arena,
/*skip_filters=*/false, /*level=*/0, max_file_size_for_l0_meta_pin_,
/*smallest_compaction_key=*/nullptr,
Expand Down Expand Up @@ -2111,7 +2115,7 @@ Status Version::OverlapWithLevelIterator(const ReadOptions& read_options,
ScopedArenaPtr<InternalIterator> iter(cfd_->table_cache()->NewIterator(
read_options, file_options, cfd_->internal_comparator(),
*file->file_metadata, &range_del_agg, mutable_cf_options_, nullptr,
cfd_->internal_stats()->GetFileReadHist(0),
cfd_->internal_stats(), cfd_->internal_stats()->GetFileReadHist(0),
TableReaderCaller::kUserIterator, &arena,
/*skip_filters=*/false, /*level=*/0, max_file_size_for_l0_meta_pin_,
/*smallest_compaction_key=*/nullptr,
Expand Down Expand Up @@ -7086,7 +7090,7 @@ InternalIterator* VersionSet::MakeInputIterator(
read_options, file_options_compactions,
cfd->internal_comparator(), fmd, range_del_agg,
*c->mutable_cf_options(),
/*table_reader_ptr=*/nullptr,
/*table_reader_ptr=*/nullptr, cfd->internal_stats(),
/*file_read_hist=*/nullptr, TableReaderCaller::kCompaction,
/*arena=*/nullptr,
/*skip_filters=*/false,
Expand Down

0 comments on commit afcda27

Please sign in to comment.