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
main
Ashish Shenoy 8 years ago
parent def2f7bd0e
commit 99765ed855
  1. 12
      db/compaction_picker.cc
  2. 2
      db/compaction_picker_test.cc
  3. 6
      db/db_impl.cc
  4. 3
      db/db_impl_experimental.cc
  5. 8
      db/version_set.cc
  6. 4
      db/version_set.h
  7. 4
      util/mutable_cf_options.h

@ -626,11 +626,7 @@ Compaction* CompactionPicker::CompactRange(
// takes running compactions into account (by skipping files that are already // takes running compactions into account (by skipping files that are already
// being compacted). Since we just changed compaction score, we recalculate it // being compacted). Since we just changed compaction score, we recalculate it
// here // here
{ // this piece of code recomputes compaction score vstorage->ComputeCompactionScore(mutable_cf_options);
CompactionOptionsFIFO dummy_compaction_options_fifo;
vstorage->ComputeCompactionScore(mutable_cf_options,
dummy_compaction_options_fifo);
}
return compaction; return compaction;
} }
@ -1038,11 +1034,7 @@ Compaction* LevelCompactionPicker::PickCompaction(
// takes running compactions into account (by skipping files that are already // takes running compactions into account (by skipping files that are already
// being compacted). Since we just changed compaction score, we recalculate it // being compacted). Since we just changed compaction score, we recalculate it
// here // here
{ // this piece of code recomputes compaction score vstorage->ComputeCompactionScore(mutable_cf_options);
CompactionOptionsFIFO dummy_compaction_options_fifo;
vstorage->ComputeCompactionScore(mutable_cf_options,
dummy_compaction_options_fifo);
}
TEST_SYNC_POINT_CALLBACK("LevelCompactionPicker::PickCompaction:Return", c); TEST_SYNC_POINT_CALLBACK("LevelCompactionPicker::PickCompaction:Return", c);

@ -119,7 +119,7 @@ class CompactionPickerTest : public testing::Test {
vstorage_->UpdateNumNonEmptyLevels(); vstorage_->UpdateNumNonEmptyLevels();
vstorage_->GenerateFileIndexer(); vstorage_->GenerateFileIndexer();
vstorage_->GenerateLevelFilesBrief(); vstorage_->GenerateLevelFilesBrief();
vstorage_->ComputeCompactionScore(mutable_cf_options_, fifo_options_); vstorage_->ComputeCompactionScore(mutable_cf_options_);
vstorage_->GenerateLevel0NonOverlapping(); vstorage_->GenerateLevel0NonOverlapping();
vstorage_->SetFinalized(); vstorage_->SetFinalized();
} }

@ -2081,11 +2081,7 @@ Status DBImpl::CompactFilesImpl(
// takes running compactions into account (by skipping files that are already // takes running compactions into account (by skipping files that are already
// being compacted). Since we just changed compaction score, we recalculate it // being compacted). Since we just changed compaction score, we recalculate it
// here. // here.
{ version->storage_info()->ComputeCompactionScore(*c->mutable_cf_options());
CompactionOptionsFIFO dummy_compaction_options_fifo;
version->storage_info()->ComputeCompactionScore(
*c->mutable_cf_options(), dummy_compaction_options_fifo);
}
compaction_job.Prepare(); 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 // Since we have some more files to compact, we should also recompute
// compaction score // compaction score
vstorage->ComputeCompactionScore(*cfd->GetLatestMutableCFOptions(), vstorage->ComputeCompactionScore(*cfd->GetLatestMutableCFOptions());
CompactionOptionsFIFO());
SchedulePendingCompaction(cfd); SchedulePendingCompaction(cfd);
MaybeScheduleFlushOrCompaction(); MaybeScheduleFlushOrCompaction();
} }

@ -1245,8 +1245,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
} }
void VersionStorageInfo::ComputeCompactionScore( void VersionStorageInfo::ComputeCompactionScore(
const MutableCFOptions& mutable_cf_options, const MutableCFOptions& mutable_cf_options) {
const CompactionOptionsFIFO& compaction_options_fifo) {
for (int level = 0; level <= MaxInputLevel(); level++) { for (int level = 0; level <= MaxInputLevel(); level++) {
double score; double score;
if (level == 0) { if (level == 0) {
@ -1282,7 +1281,7 @@ void VersionStorageInfo::ComputeCompactionScore(
if (compaction_style_ == kCompactionStyleFIFO) { if (compaction_style_ == kCompactionStyleFIFO) {
score = static_cast<double>(total_size) / score = static_cast<double>(total_size) /
compaction_options_fifo.max_table_files_size; mutable_cf_options.compaction_options_fifo.max_table_files_size;
} else { } else {
score = static_cast<double>(num_sorted_runs) / score = static_cast<double>(num_sorted_runs) /
mutable_cf_options.level0_file_num_compaction_trigger; mutable_cf_options.level0_file_num_compaction_trigger;
@ -2138,8 +2137,7 @@ void VersionSet::AppendVersion(ColumnFamilyData* column_family_data,
Version* v) { Version* v) {
// compute new compaction score // compute new compaction score
v->storage_info()->ComputeCompactionScore( v->storage_info()->ComputeCompactionScore(
*column_family_data->GetLatestMutableCFOptions(), *column_family_data->GetLatestMutableCFOptions());
column_family_data->ioptions()->compaction_options_fifo);
// Mark v finalized // Mark v finalized
v->storage_info_.SetFinalized(); v->storage_info_.SetFinalized();

@ -121,9 +121,7 @@ class VersionStorageInfo {
// We use compaction scores to figure out which compaction to do next // We use compaction scores to figure out which compaction to do next
// REQUIRES: db_mutex held!! // REQUIRES: db_mutex held!!
// TODO find a better way to pass compaction_options_fifo. // TODO find a better way to pass compaction_options_fifo.
void ComputeCompactionScore( void ComputeCompactionScore(const MutableCFOptions& mutable_cf_options);
const MutableCFOptions& mutable_cf_options,
const CompactionOptionsFIFO& compaction_options_fifo);
// Estimate est_comp_needed_bytes_ // Estimate est_comp_needed_bytes_
void EstimateCompactionBytesNeeded( void EstimateCompactionBytesNeeded(

@ -50,7 +50,8 @@ struct MutableCFOptions {
paranoid_file_checks(options.paranoid_file_checks), paranoid_file_checks(options.paranoid_file_checks),
report_bg_io_stats(options.report_bg_io_stats), report_bg_io_stats(options.report_bg_io_stats),
compression(options.compression), 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); RefreshDerivedOptions(ioptions);
} }
MutableCFOptions() MutableCFOptions()
@ -141,6 +142,7 @@ struct MutableCFOptions {
bool report_bg_io_stats; bool report_bg_io_stats;
CompressionType compression; CompressionType compression;
uint32_t min_partial_merge_operands; uint32_t min_partial_merge_operands;
CompactionOptionsFIFO compaction_options_fifo;
// Derived options // Derived options
// Per-level target file size. // Per-level target file size.

Loading…
Cancel
Save