mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-26 07:30:54 +00:00
Clean up the ComputeCompactionScore() API
Summary: Make CompactionOptionsFIFO a part of mutable_cf_options Test Plan: UT Reviewers: sdong Reviewed By: sdong Subscribers: andrewkr, lgalanis, dhruba Differential Revision: https://reviews.facebook.net/D58653
This commit is contained in:
parent
def2f7bd0e
commit
99765ed855
|
@ -626,11 +626,7 @@ Compaction* CompactionPicker::CompactRange(
|
|||
// takes running compactions into account (by skipping files that are already
|
||||
// being compacted). Since we just changed compaction score, we recalculate it
|
||||
// here
|
||||
{ // this piece of code recomputes compaction score
|
||||
CompactionOptionsFIFO dummy_compaction_options_fifo;
|
||||
vstorage->ComputeCompactionScore(mutable_cf_options,
|
||||
dummy_compaction_options_fifo);
|
||||
}
|
||||
vstorage->ComputeCompactionScore(mutable_cf_options);
|
||||
|
||||
return compaction;
|
||||
}
|
||||
|
@ -1038,11 +1034,7 @@ Compaction* LevelCompactionPicker::PickCompaction(
|
|||
// takes running compactions into account (by skipping files that are already
|
||||
// being compacted). Since we just changed compaction score, we recalculate it
|
||||
// here
|
||||
{ // this piece of code recomputes compaction score
|
||||
CompactionOptionsFIFO dummy_compaction_options_fifo;
|
||||
vstorage->ComputeCompactionScore(mutable_cf_options,
|
||||
dummy_compaction_options_fifo);
|
||||
}
|
||||
vstorage->ComputeCompactionScore(mutable_cf_options);
|
||||
|
||||
TEST_SYNC_POINT_CALLBACK("LevelCompactionPicker::PickCompaction:Return", c);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class CompactionPickerTest : public testing::Test {
|
|||
vstorage_->UpdateNumNonEmptyLevels();
|
||||
vstorage_->GenerateFileIndexer();
|
||||
vstorage_->GenerateLevelFilesBrief();
|
||||
vstorage_->ComputeCompactionScore(mutable_cf_options_, fifo_options_);
|
||||
vstorage_->ComputeCompactionScore(mutable_cf_options_);
|
||||
vstorage_->GenerateLevel0NonOverlapping();
|
||||
vstorage_->SetFinalized();
|
||||
}
|
||||
|
|
|
@ -2081,11 +2081,7 @@ Status DBImpl::CompactFilesImpl(
|
|||
// takes running compactions into account (by skipping files that are already
|
||||
// being compacted). Since we just changed compaction score, we recalculate it
|
||||
// here.
|
||||
{
|
||||
CompactionOptionsFIFO dummy_compaction_options_fifo;
|
||||
version->storage_info()->ComputeCompactionScore(
|
||||
*c->mutable_cf_options(), dummy_compaction_options_fifo);
|
||||
}
|
||||
version->storage_info()->ComputeCompactionScore(*c->mutable_cf_options());
|
||||
|
||||
compaction_job.Prepare();
|
||||
|
||||
|
|
|
@ -49,8 +49,7 @@ Status DBImpl::SuggestCompactRange(ColumnFamilyHandle* column_family,
|
|||
}
|
||||
// Since we have some more files to compact, we should also recompute
|
||||
// compaction score
|
||||
vstorage->ComputeCompactionScore(*cfd->GetLatestMutableCFOptions(),
|
||||
CompactionOptionsFIFO());
|
||||
vstorage->ComputeCompactionScore(*cfd->GetLatestMutableCFOptions());
|
||||
SchedulePendingCompaction(cfd);
|
||||
MaybeScheduleFlushOrCompaction();
|
||||
}
|
||||
|
|
|
@ -1245,8 +1245,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
|
|||
}
|
||||
|
||||
void VersionStorageInfo::ComputeCompactionScore(
|
||||
const MutableCFOptions& mutable_cf_options,
|
||||
const CompactionOptionsFIFO& compaction_options_fifo) {
|
||||
const MutableCFOptions& mutable_cf_options) {
|
||||
for (int level = 0; level <= MaxInputLevel(); level++) {
|
||||
double score;
|
||||
if (level == 0) {
|
||||
|
@ -1282,7 +1281,7 @@ void VersionStorageInfo::ComputeCompactionScore(
|
|||
|
||||
if (compaction_style_ == kCompactionStyleFIFO) {
|
||||
score = static_cast<double>(total_size) /
|
||||
compaction_options_fifo.max_table_files_size;
|
||||
mutable_cf_options.compaction_options_fifo.max_table_files_size;
|
||||
} else {
|
||||
score = static_cast<double>(num_sorted_runs) /
|
||||
mutable_cf_options.level0_file_num_compaction_trigger;
|
||||
|
@ -2138,8 +2137,7 @@ void VersionSet::AppendVersion(ColumnFamilyData* column_family_data,
|
|||
Version* v) {
|
||||
// compute new compaction score
|
||||
v->storage_info()->ComputeCompactionScore(
|
||||
*column_family_data->GetLatestMutableCFOptions(),
|
||||
column_family_data->ioptions()->compaction_options_fifo);
|
||||
*column_family_data->GetLatestMutableCFOptions());
|
||||
|
||||
// Mark v finalized
|
||||
v->storage_info_.SetFinalized();
|
||||
|
|
|
@ -121,9 +121,7 @@ class VersionStorageInfo {
|
|||
// We use compaction scores to figure out which compaction to do next
|
||||
// REQUIRES: db_mutex held!!
|
||||
// TODO find a better way to pass compaction_options_fifo.
|
||||
void ComputeCompactionScore(
|
||||
const MutableCFOptions& mutable_cf_options,
|
||||
const CompactionOptionsFIFO& compaction_options_fifo);
|
||||
void ComputeCompactionScore(const MutableCFOptions& mutable_cf_options);
|
||||
|
||||
// Estimate est_comp_needed_bytes_
|
||||
void EstimateCompactionBytesNeeded(
|
||||
|
|
|
@ -50,7 +50,8 @@ struct MutableCFOptions {
|
|||
paranoid_file_checks(options.paranoid_file_checks),
|
||||
report_bg_io_stats(options.report_bg_io_stats),
|
||||
compression(options.compression),
|
||||
min_partial_merge_operands(options.min_partial_merge_operands) {
|
||||
min_partial_merge_operands(options.min_partial_merge_operands),
|
||||
compaction_options_fifo(ioptions.compaction_options_fifo) {
|
||||
RefreshDerivedOptions(ioptions);
|
||||
}
|
||||
MutableCFOptions()
|
||||
|
@ -141,6 +142,7 @@ struct MutableCFOptions {
|
|||
bool report_bg_io_stats;
|
||||
CompressionType compression;
|
||||
uint32_t min_partial_merge_operands;
|
||||
CompactionOptionsFIFO compaction_options_fifo;
|
||||
|
||||
// Derived options
|
||||
// Per-level target file size.
|
||||
|
|
Loading…
Reference in a new issue