Make multithread load configurable and disabled by default (#57)
Co-authored-by: John Sully <john@csquare.ca>
This commit is contained in:
parent
6a483cc7ae
commit
52b8c153f8
@ -2778,6 +2778,7 @@ standardConfig configs[] = {
|
|||||||
createBoolConfig("cluster-allow-replica-migration", NULL, MODIFIABLE_CONFIG, g_pserver->cluster_allow_replica_migration, 1, NULL, NULL),
|
createBoolConfig("cluster-allow-replica-migration", NULL, MODIFIABLE_CONFIG, g_pserver->cluster_allow_replica_migration, 1, NULL, NULL),
|
||||||
createBoolConfig("replica-announced", NULL, MODIFIABLE_CONFIG, g_pserver->replica_announced, 1, NULL, NULL),
|
createBoolConfig("replica-announced", NULL, MODIFIABLE_CONFIG, g_pserver->replica_announced, 1, NULL, NULL),
|
||||||
createBoolConfig("enable-async-commands", NULL, MODIFIABLE_CONFIG, g_pserver->enable_async_commands, 1, NULL, NULL),
|
createBoolConfig("enable-async-commands", NULL, MODIFIABLE_CONFIG, g_pserver->enable_async_commands, 1, NULL, NULL),
|
||||||
|
createBoolConfig("multithread-load-enabled", NULL, MODIFIABLE_CONFIG, g_pserver->multithread_load_enabled, 0, NULL, NULL),
|
||||||
|
|
||||||
/* String Configs */
|
/* String Configs */
|
||||||
createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->acl_filename, "", NULL, NULL),
|
createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->acl_filename, "", NULL, NULL),
|
||||||
|
13
src/rdb.cpp
13
src/rdb.cpp
@ -2792,6 +2792,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enqueue(std::unique_ptr<rdbInsertJob> &spjob) {
|
void enqueue(std::unique_ptr<rdbInsertJob> &spjob) {
|
||||||
|
if (!fLaunched) {
|
||||||
|
processJob(*spjob);
|
||||||
|
spjob = nullptr;
|
||||||
|
} else {
|
||||||
vecbatch.push_back(spjob.release());
|
vecbatch.push_back(spjob.release());
|
||||||
if (vecbatch.size() >= 64) {
|
if (vecbatch.size() >= 64) {
|
||||||
queueJobs.enqueue_bulk(vecbatch.data(), vecbatch.size());
|
queueJobs.enqueue_bulk(vecbatch.data(), vecbatch.size());
|
||||||
@ -2799,6 +2803,7 @@ public:
|
|||||||
throttle();
|
throttle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void pauseExecution() {
|
void pauseExecution() {
|
||||||
m_lockPause.lock();
|
m_lockPause.lock();
|
||||||
@ -2809,10 +2814,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enqueue(std::function<void()> &&fn) {
|
void enqueue(std::function<void()> &&fn) {
|
||||||
|
if (!fLaunched) {
|
||||||
|
fn();
|
||||||
|
} else {
|
||||||
std::unique_ptr<JobBase> spjob = std::make_unique<rdbFunctionJob>(std::move(fn));
|
std::unique_ptr<JobBase> spjob = std::make_unique<rdbFunctionJob>(std::move(fn));
|
||||||
queueJobs.enqueue(spjob.release());
|
queueJobs.enqueue(spjob.release());
|
||||||
throttle();
|
throttle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ProcessWhileBlocked() {
|
void ProcessWhileBlocked() {
|
||||||
if ((mstime() - lastPing) > 1000) { // Ping if its been a second or longer
|
if ((mstime() - lastPing) > 1000) { // Ping if its been a second or longer
|
||||||
@ -2834,6 +2843,9 @@ public:
|
|||||||
size_t ckeys() { return ckeysLoaded; }
|
size_t ckeys() { return ckeysLoaded; }
|
||||||
|
|
||||||
size_t endWork() {
|
size_t endWork() {
|
||||||
|
if (!fLaunched) {
|
||||||
|
return ckeysLoaded;
|
||||||
|
}
|
||||||
if (!vecbatch.empty()) {
|
if (!vecbatch.empty()) {
|
||||||
queueJobs.enqueue_bulk(vecbatch.data(), vecbatch.size());
|
queueJobs.enqueue_bulk(vecbatch.data(), vecbatch.size());
|
||||||
vecbatch.clear();
|
vecbatch.clear();
|
||||||
@ -3098,6 +3110,7 @@ int rdbLoadRio(rio *rdb, int rdbflags, rdbSaveInfo *rsi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lru_clock = LRU_CLOCK();
|
lru_clock = LRU_CLOCK();
|
||||||
|
if (g_pserver->multithread_load_enabled)
|
||||||
wqueue.start();
|
wqueue.start();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -2634,6 +2634,7 @@ struct redisServer {
|
|||||||
int failover_state; /* Failover state */
|
int failover_state; /* Failover state */
|
||||||
|
|
||||||
int enable_async_commands;
|
int enable_async_commands;
|
||||||
|
int multithread_load_enabled = 0;
|
||||||
|
|
||||||
long long repl_batch_offStart = -1;
|
long long repl_batch_offStart = -1;
|
||||||
long long repl_batch_idxStart = -1;
|
long long repl_batch_idxStart = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user