Optimize usage of Status in CompactionJob
Summary: Based on @ljin feedback Test Plan: compiles Reviewers: ljin, yhchiang, sdong Reviewed By: sdong Subscribers: ljin, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D28515
This commit is contained in:
parent
bcdb9671c0
commit
4a3bd2bad2
@ -455,14 +455,14 @@ Status CompactionJob::Run() {
|
||||
return status;
|
||||
}
|
||||
|
||||
Status CompactionJob::Install(Status status, port::Mutex* db_mutex) {
|
||||
void CompactionJob::Install(Status* status, port::Mutex* db_mutex) {
|
||||
db_mutex->AssertHeld();
|
||||
ColumnFamilyData* cfd = compact_->compaction->column_family_data();
|
||||
cfd->internal_stats()->AddCompactionStats(
|
||||
compact_->compaction->output_level(), compaction_stats_);
|
||||
|
||||
if (status.ok()) {
|
||||
status = InstallCompactionResults(db_mutex);
|
||||
if (status->ok()) {
|
||||
*status = InstallCompactionResults(db_mutex);
|
||||
}
|
||||
VersionStorageInfo::LevelSummaryStorage tmp;
|
||||
const auto& stats = compaction_stats_;
|
||||
@ -483,11 +483,10 @@ Status CompactionJob::Install(Status status, port::Mutex* db_mutex) {
|
||||
(stats.bytes_written + stats.bytes_readnp1 + stats.bytes_readn) /
|
||||
static_cast<double>(stats.bytes_readn),
|
||||
stats.bytes_written / static_cast<double>(stats.bytes_readn),
|
||||
status.ToString().c_str(), stats.num_input_records,
|
||||
status->ToString().c_str(), stats.num_input_records,
|
||||
stats.num_dropped_records);
|
||||
|
||||
CleanupCompaction(status);
|
||||
return status;
|
||||
CleanupCompaction(*status);
|
||||
}
|
||||
|
||||
Status CompactionJob::ProcessKeyValueCompaction(int64_t* imm_micros,
|
||||
@ -1054,7 +1053,7 @@ Status CompactionJob::OpenCompactionOutputFile() {
|
||||
return s;
|
||||
}
|
||||
|
||||
void CompactionJob::CleanupCompaction(Status status) {
|
||||
void CompactionJob::CleanupCompaction(const Status& status) {
|
||||
if (compact_->builder != nullptr) {
|
||||
// May happen if we get a shutdown call in the middle of compaction
|
||||
compact_->builder->Abandon();
|
||||
|
@ -75,7 +75,7 @@ class CompactionJob {
|
||||
Status Run();
|
||||
// REQUIRED: mutex held
|
||||
// status is the return of Run()
|
||||
Status Install(Status status, port::Mutex* db_mutex);
|
||||
void Install(Status* status, port::Mutex* db_mutex);
|
||||
|
||||
private:
|
||||
void AllocateCompactionOutputFileNumbers();
|
||||
@ -92,7 +92,7 @@ class CompactionJob {
|
||||
SequenceNumber* prev_snapshot);
|
||||
void RecordCompactionIOStats();
|
||||
Status OpenCompactionOutputFile();
|
||||
void CleanupCompaction(Status status);
|
||||
void CleanupCompaction(const Status& status);
|
||||
|
||||
// CompactionJob state
|
||||
struct CompactionState;
|
||||
|
@ -1295,13 +1295,11 @@ Status DBImpl::CompactFilesImpl(
|
||||
mutex_.Unlock();
|
||||
Status status = compaction_job.Run();
|
||||
mutex_.Lock();
|
||||
if (status.ok()) {
|
||||
status = compaction_job.Install(status, &mutex_);
|
||||
compaction_job.Install(&status, &mutex_);
|
||||
if (status.ok()) {
|
||||
InstallSuperVersionBackground(c->column_family_data(), &job_context,
|
||||
*c->mutable_cf_options());
|
||||
}
|
||||
}
|
||||
c->ReleaseCompactionFiles(s);
|
||||
c->ReleaseInputs();
|
||||
c.reset();
|
||||
@ -2070,7 +2068,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
|
||||
mutex_.Unlock();
|
||||
status = compaction_job.Run();
|
||||
mutex_.Lock();
|
||||
status = compaction_job.Install(status, &mutex_);
|
||||
compaction_job.Install(&status, &mutex_);
|
||||
if (status.ok()) {
|
||||
InstallSuperVersionBackground(c->column_family_data(), job_context,
|
||||
*c->mutable_cf_options());
|
||||
|
Loading…
Reference in New Issue
Block a user