From 1a952dfc5a011a49737d39c2f54d8c261b6acd93 Mon Sep 17 00:00:00 2001 From: bowang Date: Mon, 16 May 2022 12:33:29 -0700 Subject: [PATCH] updates --- db/compaction/compaction_job.cc | 29 ++++++++--------------------- db/compaction/compaction_job.h | 2 +- db/flush_job.cc | 16 ++++------------ db/flush_job.h | 2 +- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/db/compaction/compaction_job.cc b/db/compaction/compaction_job.cc index d5268845c..777740122 100644 --- a/db/compaction/compaction_job.cc +++ b/db/compaction/compaction_job.cc @@ -2285,8 +2285,7 @@ Status CompactionJob::OpenCompactionOutputFile( /*enable_hash=*/paranoid_file_checks_); } - writable_file->SetIOPriority( - GetRateLimiterPriority(RateLimiter::OpType::kWrite)); + writable_file->SetIOPriority(GetRateLimiterPriorityForWrite()); writable_file->SetWriteLifeTimeHint(write_hint_); FileTypeSet tmp_set = db_options_.checksum_handoff_file_types; writable_file->SetPreallocationBlockSize(static_cast( @@ -2477,30 +2476,18 @@ std::string CompactionJob::GetTableFileName(uint64_t file_number) { file_number, compact_->compaction->output_path_id()); } -Env::IOPriority CompactionJob::GetRateLimiterPriority( - const RateLimiter::OpType op_type) { +Env::IOPriority CompactionJob::GetRateLimiterPriorityForWrite() { if (versions_ && versions_->GetColumnFamilySet() && versions_->GetColumnFamilySet()->write_controller()) { WriteController* write_controller = versions_->GetColumnFamilySet()->write_controller(); - // TODO: if all priorities are the same for read and write, update this. - if (op_type == RateLimiter::OpType::kWrite) { - if (write_controller->NeedsDelay() || write_controller->IsStopped()) { - return Env::IO_USER; - } else if (write_controller->NeedSpeedupCompaction()) { - return Env::IO_HIGH; - } - - return Env::IO_LOW; - } else { - if (write_controller->NeedsDelay() || write_controller->IsStopped()) { - return Env::IO_USER; - } else if (write_controller->NeedSpeedupCompaction()) { - return Env::IO_HIGH; - } - - return Env::IO_LOW; + if (write_controller->NeedsDelay() || write_controller->IsStopped()) { + return Env::IO_USER; + } else if (write_controller->NeedSpeedupCompaction()) { + return Env::IO_HIGH; } + + return Env::IO_LOW; } return Env::IO_LOW; diff --git a/db/compaction/compaction_job.h b/db/compaction/compaction_job.h index 299aad5a5..30f3c7b01 100644 --- a/db/compaction/compaction_job.h +++ b/db/compaction/compaction_job.h @@ -237,7 +237,7 @@ class CompactionJob { // `output_directory_`. virtual std::string GetTableFileName(uint64_t file_number); // The rate limiter priority (io_priority) is determined dynamically here. - Env::IOPriority GetRateLimiterPriority(const RateLimiter::OpType op_type); + Env::IOPriority GetRateLimiterPriorityForWrite(); }; // CompactionServiceInput is used the pass compaction information between two diff --git a/db/flush_job.cc b/db/flush_job.cc index a87691871..8331ec1cb 100644 --- a/db/flush_job.cc +++ b/db/flush_job.cc @@ -809,8 +809,7 @@ Status FlushJob::WriteLevel0Table() { { auto write_hint = cfd_->CalculateSSTWriteHint(0); - Env::IOPriority io_priority = - GetRateLimiterPriority(RateLimiter::OpType::kWrite); + Env::IOPriority io_priority = GetRateLimiterPriorityForWrite(); db_mutex_->Unlock(); if (log_buffer_) { log_buffer_->FlushBufferToLog(); @@ -1033,24 +1032,17 @@ Status FlushJob::WriteLevel0Table() { return s; } -Env::IOPriority FlushJob::GetRateLimiterPriority( - const RateLimiter::OpType op_type) { +Env::IOPriority FlushJob::GetRateLimiterPriorityForWrite() { if (versions_ && versions_->GetColumnFamilySet() && versions_->GetColumnFamilySet()->write_controller()) { WriteController* write_controller = versions_->GetColumnFamilySet()->write_controller(); - - if (op_type == RateLimiter::OpType::kWrite) { - if (write_controller->IsStopped() || write_controller->NeedsDelay()) { - return Env::IO_USER; - } - return Env::IO_HIGH; - } else { + if (write_controller->IsStopped() || write_controller->NeedsDelay()) { return Env::IO_USER; } } - return op_type == RateLimiter::OpType::kWrite ? Env::IO_HIGH : Env::IO_USER; + return Env::IO_HIGH; } #ifndef ROCKSDB_LITE diff --git a/db/flush_job.h b/db/flush_job.h index 4c53b95a3..8045c8351 100644 --- a/db/flush_job.h +++ b/db/flush_job.h @@ -124,7 +124,7 @@ class FlushJob { Status MemPurge(); bool MemPurgeDecider(); // The rate limiter priority (io_priority) is determined dynamically here. - Env::IOPriority GetRateLimiterPriority(const RateLimiter::OpType op_type); + Env::IOPriority GetRateLimiterPriorityForWrite(); #ifndef ROCKSDB_LITE std::unique_ptr GetFlushJobInfo() const; #endif // !ROCKSDB_LITE