Remove unnecessary work from critical path (Latency Fixes)
Former-commit-id: 096a90deb7afe489875d3186f3f8f43e41fea329
This commit is contained in:
parent
91a803815d
commit
782e675072
@ -2306,6 +2306,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
|||||||
g_pserver->rdb_bgsave_scheduled = 0;
|
g_pserver->rdb_bgsave_scheduled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
if (cserver.storage_memory_model == STORAGE_WRITEBACK && g_pserver->m_pstorageFactory) {
|
if (cserver.storage_memory_model == STORAGE_WRITEBACK && g_pserver->m_pstorageFactory) {
|
||||||
run_with_period(g_pserver->storage_flush_period) {
|
run_with_period(g_pserver->storage_flush_period) {
|
||||||
flushStorageWeak();
|
flushStorageWeak();
|
||||||
@ -2316,6 +2317,15 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
|||||||
g_pserver->db[0]->consolidate_snapshot();
|
g_pserver->db[0]->consolidate_snapshot();
|
||||||
}, true /*HiPri*/);
|
}, true /*HiPri*/);
|
||||||
|
|
||||||
|
=======
|
||||||
|
if (g_pserver->db[0]->FSnapshot()) // BUG only db 0?!
|
||||||
|
{
|
||||||
|
g_pserver->asyncworkqueue->AddWorkFunction([]{
|
||||||
|
g_pserver->db[0]->consolidate_snapshot();
|
||||||
|
}, true /*HiPri*/);
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> dd700f1d6... Remove unnecessary work from critical path (Latency Fixes)
|
||||||
/* Fire the cron loop modules event. */
|
/* Fire the cron loop modules event. */
|
||||||
RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,g_pserver->hz};
|
RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,g_pserver->hz};
|
||||||
moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP,
|
moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP,
|
||||||
@ -2441,7 +2451,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
|||||||
static thread_local bool fFirstRun = true;
|
static thread_local bool fFirstRun = true;
|
||||||
// note: we also copy the DB pointer in case a DB swap is done while the lock is released
|
// note: we also copy the DB pointer in case a DB swap is done while the lock is released
|
||||||
std::vector<redisDb*> vecdb; // note we cache the database pointer in case a dbswap is done while the lock is released
|
std::vector<redisDb*> vecdb; // note we cache the database pointer in case a dbswap is done while the lock is released
|
||||||
if (cserver.storage_memory_model == STORAGE_WRITETHROUGH)
|
if (cserver.storage_memory_model == STORAGE_WRITETHROUGH && g_pserver->m_pstorageFactory != nullptr)
|
||||||
{
|
{
|
||||||
if (!fFirstRun) {
|
if (!fFirstRun) {
|
||||||
mstime_t storage_process_latency;
|
mstime_t storage_process_latency;
|
||||||
@ -2462,8 +2472,11 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
|
|||||||
|
|
||||||
mstime_t commit_latency;
|
mstime_t commit_latency;
|
||||||
latencyStartMonitor(commit_latency);
|
latencyStartMonitor(commit_latency);
|
||||||
|
if (g_pserver->m_pstorageFactory != nullptr)
|
||||||
|
{
|
||||||
for (redisDb *db : vecdb)
|
for (redisDb *db : vecdb)
|
||||||
db->commitChanges();
|
db->commitChanges();
|
||||||
|
}
|
||||||
latencyEndMonitor(commit_latency);
|
latencyEndMonitor(commit_latency);
|
||||||
latencyAddSampleIfNeeded("storage-commit", commit_latency);
|
latencyAddSampleIfNeeded("storage-commit", commit_latency);
|
||||||
|
|
||||||
@ -4150,6 +4163,7 @@ int processCommand(client *c, int callFlags, AeLocker &locker) {
|
|||||||
queueMultiCommand(c);
|
queueMultiCommand(c);
|
||||||
addReply(c,shared.queued);
|
addReply(c,shared.queued);
|
||||||
} else {
|
} else {
|
||||||
|
<<<<<<< HEAD
|
||||||
#if 0
|
#if 0
|
||||||
if (cserver.cthreads >= 2 && !g_fTestMode && g_pserver->m_pstorageFactory == nullptr && listLength(g_pserver->monitors) == 0 && c->cmd->proc == getCommand)
|
if (cserver.cthreads >= 2 && !g_fTestMode && g_pserver->m_pstorageFactory == nullptr && listLength(g_pserver->monitors) == 0 && c->cmd->proc == getCommand)
|
||||||
{
|
{
|
||||||
@ -4157,6 +4171,8 @@ int processCommand(client *c, int callFlags, AeLocker &locker) {
|
|||||||
return C_OK;
|
return C_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
=======
|
||||||
|
>>>>>>> dd700f1d6... Remove unnecessary work from critical path (Latency Fixes)
|
||||||
locker.arm(c);
|
locker.arm(c);
|
||||||
incrementMvccTstamp();
|
incrementMvccTstamp();
|
||||||
call(c,callFlags);
|
call(c,callFlags);
|
||||||
|
@ -1350,6 +1350,8 @@ public:
|
|||||||
bool removeCachedValue(const char *key);
|
bool removeCachedValue(const char *key);
|
||||||
void removeAllCachedValues();
|
void removeAllCachedValues();
|
||||||
|
|
||||||
|
bool FSnapshot() const { return m_spdbSnapshotHOLDER != nullptr; }
|
||||||
|
|
||||||
dict_iter find_cached_threadsafe(const char *key) const;
|
dict_iter find_cached_threadsafe(const char *key) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1425,6 +1427,7 @@ public:
|
|||||||
using redisDbPersistentData::endSnapshotAsync;
|
using redisDbPersistentData::endSnapshotAsync;
|
||||||
using redisDbPersistentData::end;
|
using redisDbPersistentData::end;
|
||||||
using redisDbPersistentData::find_cached_threadsafe;
|
using redisDbPersistentData::find_cached_threadsafe;
|
||||||
|
using redisDbPersistentData::FSnapshot;
|
||||||
|
|
||||||
dict_iter random_cache_threadsafe(bool fPrimaryOnly = false) const;
|
dict_iter random_cache_threadsafe(bool fPrimaryOnly = false) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user