Skip to content

Commit

Permalink
#34: set purges as Pri::Low
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuval-Ariel authored and isaac-io committed Oct 24, 2022
1 parent 8f2d10a commit 382accb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions db/db_impl/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,9 @@ void DBImpl::SchedulePurge() {
mutex_.AssertHeld();
assert(opened_successfully_);

// Purge operations are put into High priority queue
// Purge operations are put into the low priority queue
bg_purge_scheduled_++;
env_->Schedule(&DBImpl::BGWorkPurge, this, Env::Priority::HIGH, nullptr);
env_->Schedule(&DBImpl::BGWorkPurge, this, Env::Priority::LOW, nullptr);
}

void DBImpl::BackgroundCallPurge() {
Expand Down
2 changes: 1 addition & 1 deletion db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@ void DBImpl::BGWorkBottomCompaction(void* arg) {
}

void DBImpl::BGWorkPurge(void* db) {
IOSTATS_SET_THREAD_POOL_ID(Env::Priority::HIGH);
IOSTATS_SET_THREAD_POOL_ID(Env::Priority::LOW);
TEST_SYNC_POINT("DBImpl::BGWorkPurge:start");
reinterpret_cast<DBImpl*>(db)->BackgroundCallPurge();
TEST_SYNC_POINT("DBImpl::BGWorkPurge:end");
Expand Down
8 changes: 5 additions & 3 deletions db/db_test2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5920,10 +5920,12 @@ TEST_F(DBTest2, BackgroundPurgeTest) {
size_t value = options.write_buffer_manager->memory_usage();
ASSERT_GT(value, base_value);

db_->GetEnv()->SetBackgroundThreads(1, Env::Priority::HIGH);
// Take up a slot in the low priority pool
// in order to prevent a purge from running when the iterator is deleted.
db_->GetEnv()->SetBackgroundThreads(1, Env::Priority::LOW);
test::SleepingBackgroundTask sleeping_task_after;
db_->GetEnv()->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);
delete iter;

Env::Default()->SleepForMicroseconds(100000);
Expand All @@ -5935,7 +5937,7 @@ TEST_F(DBTest2, BackgroundPurgeTest) {

test::SleepingBackgroundTask sleeping_task_after2;
db_->GetEnv()->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after2, Env::Priority::HIGH);
&sleeping_task_after2, Env::Priority::LOW);
sleeping_task_after2.WakeUp();
sleeping_task_after2.WaitUntilDone();

Expand Down
8 changes: 4 additions & 4 deletions db/deletefile_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ TEST_F(DeleteFileTest, BackgroundPurgeIteratorTest) {
CheckFileTypeCounts(dbname_, 0, 3, 1);
test::SleepingBackgroundTask sleeping_task_before;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_before, Env::Priority::HIGH);
&sleeping_task_before, Env::Priority::LOW);
delete itr;
test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);

// Make sure no purges are executed foreground
CheckFileTypeCounts(dbname_, 0, 3, 1);
Expand Down Expand Up @@ -334,7 +334,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) {
delete cfh;
test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);
// If background purge is enabled, the file should still be there.
CheckFileTypeCounts(dbname_, 0, bg_purge ? 1 : 0, 1);
TEST_SYNC_POINT("DeleteFileTest::BackgroundPurgeCFDropTest:1");
Expand Down Expand Up @@ -403,7 +403,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCopyOptions) {

test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);

// Make sure all background purges are executed
sleeping_task_after.WakeUp();
Expand Down
4 changes: 2 additions & 2 deletions include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -1550,8 +1550,8 @@ struct ReadOptions {
bool pin_data;

// If true, when PurgeObsoleteFile is called in CleanupIteratorState, we
// schedule a background job in the flush job queue and delete obsolete files
// in background.
// schedule a background job in the compaction job queue and delete obsolete
// files in background.
// Default: false
bool background_purge_on_iterator_cleanup;

Expand Down

0 comments on commit 382accb

Please sign in to comment.