Skip to content

Commit

Permalink
[Update PR] Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
greensky00 committed Sep 9, 2024
1 parent e17a655 commit 681c106
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
22 changes: 15 additions & 7 deletions src/db_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,24 @@ void DBMgr::initInternal(const GlobalConfig& config) {
Flusher::FlusherType flusher_type = Flusher::FlusherType::GENERIC;
if (dedicated_async_flusher) {
if (ii < config.numDedicatedFlusherForAsyncReqs) {
flusher_type = Flusher::FlusherType::ONLY_HANDLE_ASYNC;
flusher_type = Flusher::FlusherType::FLUSH_ON_DEMAND;
} else {
flusher_type = Flusher::FlusherType::ONLY_HANDLE_SYNC;
flusher_type = Flusher::FlusherType::FLUSH_ON_CONDITION;
}
}
std::string t_name = flusher_type == Flusher::FlusherType::ONLY_HANDLE_ASYNC
? "flusher_async_" + std::to_string(ii)
: (flusher_type == Flusher::FlusherType::ONLY_HANDLE_SYNC
? "flusher_sync_" + std::to_string(ii)
: "flusher_generic_" + std::to_string(ii));
std::string t_name;
switch (flusher_type) {
case Flusher::FlusherType::FLUSH_ON_DEMAND:
t_name = "flusher_od_" + std::to_string(ii);
break;
case Flusher::FlusherType::FLUSH_ON_CONDITION:
t_name = "flusher_oc_" + std::to_string(ii);
break;
default:
t_name = "flusher_" + std::to_string(ii);
break;
}

Flusher* flusher = new Flusher(t_name, config, flusher_type);
wMgr->addWorker(flusher);
flusher->run();
Expand Down
22 changes: 10 additions & 12 deletions src/flusher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ size_t FlusherQueue::size() const {
return queue.size();
}

Flusher::Flusher(const std::string& _w_name,
const GlobalConfig& _config,
FlusherType _type)
Flusher::Flusher(const std::string& w_name,
const GlobalConfig& g_config,
FlusherType f_type)
: lastCheckedFileIndex(0xffff) // Any big number to start from 0.
, type(_type) {
workerName = _w_name;
gConfig = _config;
, type(f_type) {
workerName = w_name;
gConfig = g_config;
FlusherOptions options;
options.sleepDuration_ms = gConfig.flusherSleepDuration_ms;
options.worker = this;
Expand All @@ -106,7 +106,7 @@ void Flusher::work(WorkerOptions* opt_base) {
DB* target_db = nullptr;

FlusherQueueElem* elem = nullptr;
if (type != FlusherType::ONLY_HANDLE_SYNC) {
if (type != FlusherType::FLUSH_ON_CONDITION) {
elem = dbm->flusherQueue()->pop();
}

Expand All @@ -126,7 +126,7 @@ void Flusher::work(WorkerOptions* opt_base) {
}
if (cursor) skiplist_release_node(cursor);

} else if (type != FlusherType::ONLY_HANDLE_ASYNC) {
} else if (type != FlusherType::FLUSH_ON_DEMAND) {
// Otherwise: check DB map, only when it is not the dedicated flusher.
std::lock_guard<std::mutex> l(dbm->dbMapLock);

Expand Down Expand Up @@ -159,9 +159,6 @@ void Flusher::work(WorkerOptions* opt_base) {
break;
}
}
} else {
// FlusherType::ONLY_HANDLE_ASYNC but FlusherQueue is empty, early return.
return;
}

if (target_db) {
Expand Down Expand Up @@ -244,7 +241,8 @@ void Flusher::work(WorkerOptions* opt_base) {
target_db->p->decBgTask();
}

if ( dbm->flusherQueue()->size() &&
if ( type != FlusherType::FLUSH_ON_CONDITION &&
dbm->flusherQueue()->size() &&
!delayed_task ) {
doNotSleepNextTime = true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/flusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ class FlusherQueue {

class Flusher : public WorkerBase {
public:
enum FlusherType { GENERIC = 0x0, ONLY_HANDLE_ASYNC = 0x1, ONLY_HANDLE_SYNC = 0x2 };
enum FlusherType { GENERIC = 0x0, FLUSH_ON_DEMAND = 0x1, FLUSH_ON_CONDITION = 0x2 };

struct FlusherOptions : public WorkerOptions {
};

Flusher(const std::string& _w_name,
const GlobalConfig& _config,
FlusherType _type = FlusherType::GENERIC);
Flusher(const std::string& w_name,
const GlobalConfig& g_config,
FlusherType f_type = FlusherType::GENERIC);
~Flusher();
void work(WorkerOptions* opt_base);

Expand Down
2 changes: 1 addition & 1 deletion src/jungle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ Status DB::flushLogsAsync(const FlushOptions& options,
&& db_mgr->getGlobalConfig()->numFlusherThreads
> db_mgr->getGlobalConfig()->numDedicatedFlusherForAsyncReqs;
const std::string WORKER_PREFIX =
dedicated_async_flusher ? "flusher_async" : "flusher_generic";
dedicated_async_flusher ? "flusher_od" : "flusher";

if (options.execDelayUs) {
// Delay is given.
Expand Down

0 comments on commit 681c106

Please sign in to comment.