Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit c4b498b

Browse files
committed
make the threadpool parametrized from settings.h
1 parent fd023eb commit c4b498b

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

src/common/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ void PelotonInit::Initialize() {
4040
thread_pool.Initialize(0, std::thread::hardware_concurrency() + 3);
4141

4242
// start worker pool
43-
threadpool::MonoQueuePool::GetInstance(32, 4).Startup();
43+
threadpool::MonoQueuePool::GetInstance().Startup();
4444

4545
// start brain thread pool
4646
if (settings::SettingsManager::GetBool(settings::SettingId::brain)) {
47-
threadpool::MonoQueuePool::GetBrainInstance(32, 1).Startup();
47+
threadpool::MonoQueuePool::GetBrainInstance().Startup();
4848
}
4949

5050
int parallelism = (std::thread::hardware_concurrency() + 3) / 4;
@@ -110,11 +110,11 @@ void PelotonInit::Shutdown() {
110110
concurrency::EpochManagerFactory::GetInstance().StopEpoch();
111111

112112
// stop worker pool
113-
threadpool::MonoQueuePool::GetInstance(32, 4).Shutdown();
113+
threadpool::MonoQueuePool::GetInstance().Shutdown();
114114

115115
// stop brain thread pool
116116
if (settings::SettingsManager::GetBool(settings::SettingId::brain)) {
117-
threadpool::MonoQueuePool::GetBrainInstance(32, 1).Shutdown();
117+
threadpool::MonoQueuePool::GetBrainInstance().Shutdown();
118118
}
119119

120120
thread_pool.Shutdown();

src/gc/transaction_level_gc_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int TransactionLevelGCManager::Unlink(const int &thread_id,
136136
std::vector<std::string> query_strings = txn_ctx->GetQueryStrings();
137137
if(query_strings.size() != 0) {
138138
uint64_t timestamp = txn_ctx->GetTimestamp();
139-
auto &pool = threadpool::MonoQueuePool::GetBrainInstance(32, 1);
139+
auto &pool = threadpool::MonoQueuePool::GetBrainInstance();
140140
for(auto query_string: query_strings) {
141141
pool.SubmitTask([this, query_string, timestamp] {
142142
brain::QueryLogger::LogQuery(query_string, timestamp);

src/include/settings/settings.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ SETTING_double(bnlj_buffer_size,
7171
1.0 * 1024.0 * 1024.0,
7272
true, true)
7373

74+
// Size of the MonoQueue task queue
75+
SETTING_int(monoqueue_task_queue_size,
76+
"MonoQueue Task Queue Size (default: 32)",
77+
32,
78+
false, false)
79+
80+
// Size of the MonoQueue worker pool
81+
SETTING_int(monoqueue_worker_pool_size,
82+
"MonoQueue Worker Pool Size (default: 4)",
83+
4,
84+
false, false)
85+
7486
//===----------------------------------------------------------------------===//
7587
// WRITE AHEAD LOG
7688
//===----------------------------------------------------------------------===//
@@ -125,6 +137,17 @@ SETTING_bool(brain,
125137
false,
126138
true, true)
127139

140+
// Size of the brain task queue
141+
SETTING_int(brain_task_queue_size,
142+
"Brain Task Queue Size (default: 32)",
143+
32,
144+
false, false)
145+
146+
// Size of the brain worker pool
147+
SETTING_int(brain_worker_pool_size,
148+
"Brain Worker Pool Size (default: 1)",
149+
1,
150+
false, false)
128151

129152
//===----------------------------------------------------------------------===//
130153
// CODEGEN

src/include/threadpool/mono_queue_pool.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#pragma once
1414

15+
#include "settings/settings_manager.h"
1516
#include "worker_pool.h"
1617

1718
namespace peloton {
@@ -51,13 +52,21 @@ class MonoQueuePool {
5152
task_queue_.Enqueue(std::move(func));
5253
}
5354

54-
static MonoQueuePool &GetInstance(int task_queue_size, int worker_pool_size) {
55+
static MonoQueuePool &GetInstance() {
56+
int task_queue_size = settings::SettingsManager::GetBool(
57+
settings::SettingId::monoqueue_task_queue_size);
58+
int worker_pool_size = settings::SettingsManager::GetBool(
59+
settings::SettingId::monoqueue_worker_pool_size);
60+
5561
static MonoQueuePool mono_queue_pool(task_queue_size, worker_pool_size);
5662
return mono_queue_pool;
5763
}
5864

59-
static MonoQueuePool &GetBrainInstance(int task_queue_size,
60-
int worker_pool_size) {
65+
static MonoQueuePool &GetBrainInstance() {
66+
int task_queue_size = settings::SettingsManager::GetBool(
67+
settings::SettingId::brain_task_queue_size);
68+
int worker_pool_size = settings::SettingsManager::GetBool(
69+
settings::SettingId::brain_worker_pool_size);
6170
static MonoQueuePool brain_queue_pool(task_queue_size, worker_pool_size);
6271
return brain_queue_pool;
6372
}

src/traffic_cop/traffic_cop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ executor::ExecutionResult TrafficCop::ExecuteHelper(
187187
task_callback_(task_callback_arg_);
188188
};
189189

190-
auto &pool = threadpool::MonoQueuePool::GetInstance(32, 4);
190+
auto &pool = threadpool::MonoQueuePool::GetInstance();
191191
pool.SubmitTask([plan, txn, &params, &result, &result_format, on_complete] {
192192
executor::PlanExecutor::ExecutePlan(plan, txn, params, result_format,
193193
on_complete);

0 commit comments

Comments
 (0)