Unverified Commit cff9f517 authored by Connor's avatar Connor Committed by GitHub

Schedule GC to bottom priority pool (#38)

* schedule gc to bottom priority pool
Signed-off-by: 's avatarConnor1996 <zbk602423539@gmail.com>
parent f80342b8
...@@ -225,15 +225,15 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs, ...@@ -225,15 +225,15 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
static bool has_init_background_threads = false; static bool has_init_background_threads = false;
if (!has_init_background_threads) { if (!has_init_background_threads) {
auto low_pri_threads_num = env_->GetBackgroundThreads(Env::Priority::LOW); auto bottom_pri_threads_num =
assert(low_pri_threads_num > 0); env_->GetBackgroundThreads(Env::Priority::BOTTOM);
if (!db_options_.disable_background_gc && if (!db_options_.disable_background_gc &&
db_options_.max_background_gc > 0) { db_options_.max_background_gc > 0) {
env_->IncBackgroundThreadsIfNeeded( env_->IncBackgroundThreadsIfNeeded(
db_options_.max_background_gc + low_pri_threads_num, db_options_.max_background_gc + bottom_pri_threads_num,
Env::Priority::LOW); Env::Priority::BOTTOM);
assert(env_->GetBackgroundThreads(Env::Priority::LOW) == assert(env_->GetBackgroundThreads(Env::Priority::BOTTOM) ==
low_pri_threads_num + db_options_.max_background_gc); bottom_pri_threads_num + db_options_.max_background_gc);
} }
has_init_background_threads = true; has_init_background_threads = true;
} }
...@@ -289,7 +289,7 @@ Status TitanDBImpl::CloseImpl() { ...@@ -289,7 +289,7 @@ Status TitanDBImpl::CloseImpl() {
shuting_down_.store(true, std::memory_order_release); shuting_down_.store(true, std::memory_order_release);
} }
int gc_unscheduled = env_->UnSchedule(this, Env::Priority::LOW); int gc_unscheduled = env_->UnSchedule(this, Env::Priority::BOTTOM);
{ {
MutexLock l(&mutex_); MutexLock l(&mutex_);
bg_gc_scheduled_ -= gc_unscheduled; bg_gc_scheduled_ -= gc_unscheduled;
......
...@@ -20,7 +20,7 @@ void TitanDBImpl::MaybeScheduleGC() { ...@@ -20,7 +20,7 @@ void TitanDBImpl::MaybeScheduleGC() {
bg_gc_scheduled_.fetch_add(1, std::memory_order_release); bg_gc_scheduled_.fetch_add(1, std::memory_order_release);
env_->Schedule(&TitanDBImpl::BGWorkGC, this, Env::Priority::LOW, this); env_->Schedule(&TitanDBImpl::BGWorkGC, this, Env::Priority::BOTTOM, this);
} }
void TitanDBImpl::BGWorkGC(void* db) { void TitanDBImpl::BGWorkGC(void* db) {
...@@ -53,7 +53,7 @@ void TitanDBImpl::BackgroundCallGC() { ...@@ -53,7 +53,7 @@ void TitanDBImpl::BackgroundCallGC() {
} }
// IMPORTANT: there should be no code after calling SignalAll. This call may // IMPORTANT: there should be no code after calling SignalAll. This call may
// signal the DB destructor that it's OK to proceed with destruction. In // signal the DB destructor that it's OK to proceed with destruction. In
// that case, all DB variables will be dealloacated and referencing them // that case, all DB variables will be deallocated and referencing them
// will cause trouble. // will cause trouble.
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment