In single thread mode don't batch

Former-commit-id: b1cb230690a584b8bfe7f433fc0ca0320877ebd3
This commit is contained in:
John Sully 2021-09-10 00:38:08 +00:00
parent 6a3294ab7b
commit 1b02987b0c

View File

@ -2551,7 +2551,7 @@ void parseClientCommandBuffer(client *c) {
} }
/* Prefetch outside the lock for better perf */ /* Prefetch outside the lock for better perf */
if (g_pserver->prefetch_enabled && cqueriesStart < c->vecqueuedcmd.size() && if (g_pserver->prefetch_enabled && cserver.cthreads > 1 && cqueriesStart < c->vecqueuedcmd.size() &&
(g_pserver->m_pstorageFactory || aeLockContested(cserver.cthreads/2) || cserver.cthreads == 1) && !GlobalLocksAcquired()) { (g_pserver->m_pstorageFactory || aeLockContested(cserver.cthreads/2) || cserver.cthreads == 1) && !GlobalLocksAcquired()) {
auto &query = c->vecqueuedcmd.back(); auto &query = c->vecqueuedcmd.back();
if (query.argc > 0 && query.argc == query.argcMax) { if (query.argc > 0 && query.argc == query.argcMax) {
@ -2624,7 +2624,7 @@ void readQueryFromClient(connection *conn) {
int nread, readlen; int nread, readlen;
size_t qblen; size_t qblen;
serverAssertDebug(FCorrectThread(c) sdfsdf); serverAssertDebug(FCorrectThread(c));
serverAssertDebug(!GlobalLocksAcquired()); serverAssertDebug(!GlobalLocksAcquired());
AeLocker aelock; AeLocker aelock;
@ -2696,9 +2696,16 @@ void readQueryFromClient(connection *conn) {
return; return;
} }
if (cserver.cthreads > 1) {
parseClientCommandBuffer(c); parseClientCommandBuffer(c);
serverTL->vecclientsProcess.push_back(c); serverTL->vecclientsProcess.push_back(c);
} else {
// If we're single threaded its actually better to just process the command here while the query is hot in the cache
// multithreaded lock contention dominates and batching is better
aeAcquireLock();
runAndPropogateToReplicas(processInputBuffer, c, true /*fParse*/, CMD_CALL_FULL);
aeReleaseLock();
}
} }
void processClients() void processClients()