Commit d5d55fc3 authored by antirez's avatar antirez
Browse files

loading side of the threaded VM

parent a544018d
...@@ -17,6 +17,7 @@ Virtual Memory sub-TODO: ...@@ -17,6 +17,7 @@ Virtual Memory sub-TODO:
* Possibly decrRefCount() against swapped objects can be moved into I/O threads, as it's a slow operation against million elements list, and in general consumes CPU time that can be consumed by other threads (and cores). * Possibly decrRefCount() against swapped objects can be moved into I/O threads, as it's a slow operation against million elements list, and in general consumes CPU time that can be consumed by other threads (and cores).
* EXISTS should avoid loading the object if possible without too make the code too specialized. * EXISTS should avoid loading the object if possible without too make the code too specialized.
* vm-min-age <seconds> option * vm-min-age <seconds> option
* Make sure objects loaded from the VM are specially encoded when possible.
* Hashes (GET/SET/DEL/INCRBY/EXISTS/FIELDS/LEN/MSET/MGET). Special encoding for hashes with < N keys. * Hashes (GET/SET/DEL/INCRBY/EXISTS/FIELDS/LEN/MSET/MGET). Special encoding for hashes with < N keys.
......
...@@ -62,6 +62,7 @@ aeEventLoop *aeCreateEventLoop(void) { ...@@ -62,6 +62,7 @@ aeEventLoop *aeCreateEventLoop(void) {
eventLoop->timeEventNextId = 0; eventLoop->timeEventNextId = 0;
eventLoop->stop = 0; eventLoop->stop = 0;
eventLoop->maxfd = -1; eventLoop->maxfd = -1;
eventLoop->beforesleep = NULL;
if (aeApiCreate(eventLoop) == -1) { if (aeApiCreate(eventLoop) == -1) {
zfree(eventLoop); zfree(eventLoop);
return NULL; return NULL;
...@@ -373,10 +374,17 @@ int aeWait(int fd, int mask, long long milliseconds) { ...@@ -373,10 +374,17 @@ int aeWait(int fd, int mask, long long milliseconds) {
void aeMain(aeEventLoop *eventLoop) { void aeMain(aeEventLoop *eventLoop) {
eventLoop->stop = 0; eventLoop->stop = 0;
while (!eventLoop->stop) while (!eventLoop->stop) {
if (eventLoop->beforesleep != NULL)
eventLoop->beforesleep(eventLoop);
aeProcessEvents(eventLoop, AE_ALL_EVENTS); aeProcessEvents(eventLoop, AE_ALL_EVENTS);
}
} }
char *aeGetApiName(void) { char *aeGetApiName(void) {
return aeApiName(); return aeApiName();
} }
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep) {
eventLoop->beforesleep = beforesleep;
}
...@@ -58,6 +58,7 @@ struct aeEventLoop; ...@@ -58,6 +58,7 @@ struct aeEventLoop;
typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask); typedef void aeFileProc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask);
typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData); typedef int aeTimeProc(struct aeEventLoop *eventLoop, long long id, void *clientData);
typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData); typedef void aeEventFinalizerProc(struct aeEventLoop *eventLoop, void *clientData);
typedef void aeBeforeSleepProc(struct aeEventLoop *eventLoop);
/* File event structure */ /* File event structure */
typedef struct aeFileEvent { typedef struct aeFileEvent {
...@@ -93,6 +94,7 @@ typedef struct aeEventLoop { ...@@ -93,6 +94,7 @@ typedef struct aeEventLoop {
aeTimeEvent *timeEventHead; aeTimeEvent *timeEventHead;
int stop; int stop;
void *apidata; /* This is used for polling API specific data */ void *apidata; /* This is used for polling API specific data */
aeBeforeSleepProc *beforesleep;
} aeEventLoop; } aeEventLoop;
/* Prototypes */ /* Prototypes */
...@@ -110,5 +112,6 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags); ...@@ -110,5 +112,6 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags);
int aeWait(int fd, int mask, long long milliseconds); int aeWait(int fd, int mask, long long milliseconds);
void aeMain(aeEventLoop *eventLoop); void aeMain(aeEventLoop *eventLoop);
char *aeGetApiName(void); char *aeGetApiName(void);
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep);
#endif #endif
This diff is collapsed.
...@@ -9,8 +9,10 @@ static struct redisFunctionSym symsTable[] = { ...@@ -9,8 +9,10 @@ static struct redisFunctionSym symsTable[] = {
{"aofRemoveTempFile",(unsigned long)aofRemoveTempFile}, {"aofRemoveTempFile",(unsigned long)aofRemoveTempFile},
{"appendServerSaveParams",(unsigned long)appendServerSaveParams}, {"appendServerSaveParams",(unsigned long)appendServerSaveParams},
{"authCommand",(unsigned long)authCommand}, {"authCommand",(unsigned long)authCommand},
{"beforeSleep",(unsigned long)beforeSleep},
{"bgrewriteaofCommand",(unsigned long)bgrewriteaofCommand}, {"bgrewriteaofCommand",(unsigned long)bgrewriteaofCommand},
{"bgsaveCommand",(unsigned long)bgsaveCommand}, {"bgsaveCommand",(unsigned long)bgsaveCommand},
{"blockClientOnSwappedKeys",(unsigned long)blockClientOnSwappedKeys},
{"blockForKeys",(unsigned long)blockForKeys}, {"blockForKeys",(unsigned long)blockForKeys},
{"blockingPopGenericCommand",(unsigned long)blockingPopGenericCommand}, {"blockingPopGenericCommand",(unsigned long)blockingPopGenericCommand},
{"blpopCommand",(unsigned long)blpopCommand}, {"blpopCommand",(unsigned long)blpopCommand},
...@@ -43,6 +45,7 @@ static struct redisFunctionSym symsTable[] = { ...@@ -43,6 +45,7 @@ static struct redisFunctionSym symsTable[] = {
{"dictObjKeyCompare",(unsigned long)dictObjKeyCompare}, {"dictObjKeyCompare",(unsigned long)dictObjKeyCompare},
{"dictRedisObjectDestructor",(unsigned long)dictRedisObjectDestructor}, {"dictRedisObjectDestructor",(unsigned long)dictRedisObjectDestructor},
{"dictVanillaFree",(unsigned long)dictVanillaFree}, {"dictVanillaFree",(unsigned long)dictVanillaFree},
{"dontWaitForSwappedKey",(unsigned long)dontWaitForSwappedKey},
{"dupClientReplyValue",(unsigned long)dupClientReplyValue}, {"dupClientReplyValue",(unsigned long)dupClientReplyValue},
{"dupStringObject",(unsigned long)dupStringObject}, {"dupStringObject",(unsigned long)dupStringObject},
{"echoCommand",(unsigned long)echoCommand}, {"echoCommand",(unsigned long)echoCommand},
...@@ -79,6 +82,7 @@ static struct redisFunctionSym symsTable[] = { ...@@ -79,6 +82,7 @@ static struct redisFunctionSym symsTable[] = {
{"getMcontextEip",(unsigned long)getMcontextEip}, {"getMcontextEip",(unsigned long)getMcontextEip},
{"getsetCommand",(unsigned long)getsetCommand}, {"getsetCommand",(unsigned long)getsetCommand},
{"glueReplyBuffersIfNeeded",(unsigned long)glueReplyBuffersIfNeeded}, {"glueReplyBuffersIfNeeded",(unsigned long)glueReplyBuffersIfNeeded},
{"handleClientsBlockedOnSwappedKey",(unsigned long)handleClientsBlockedOnSwappedKey},
{"handleClientsWaitingListPush",(unsigned long)handleClientsWaitingListPush}, {"handleClientsWaitingListPush",(unsigned long)handleClientsWaitingListPush},
{"htNeedsResize",(unsigned long)htNeedsResize}, {"htNeedsResize",(unsigned long)htNeedsResize},
{"incrCommand",(unsigned long)incrCommand}, {"incrCommand",(unsigned long)incrCommand},
...@@ -231,6 +235,7 @@ static struct redisFunctionSym symsTable[] = { ...@@ -231,6 +235,7 @@ static struct redisFunctionSym symsTable[] = {
{"vmThreadedIOCompletedJob",(unsigned long)vmThreadedIOCompletedJob}, {"vmThreadedIOCompletedJob",(unsigned long)vmThreadedIOCompletedJob},
{"vmWriteObjectOnSwap",(unsigned long)vmWriteObjectOnSwap}, {"vmWriteObjectOnSwap",(unsigned long)vmWriteObjectOnSwap},
{"waitEmptyIOJobsQueue",(unsigned long)waitEmptyIOJobsQueue}, {"waitEmptyIOJobsQueue",(unsigned long)waitEmptyIOJobsQueue},
{"waitForSwappedKey",(unsigned long)waitForSwappedKey},
{"yesnotoi",(unsigned long)yesnotoi}, {"yesnotoi",(unsigned long)yesnotoi},
{"zaddCommand",(unsigned long)zaddCommand}, {"zaddCommand",(unsigned long)zaddCommand},
{"zaddGenericCommand",(unsigned long)zaddGenericCommand}, {"zaddGenericCommand",(unsigned long)zaddGenericCommand},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment