Skip to content

Commit

Permalink
REDIS_MAX_COMPLETED_JOBS_PROCESSED is now in percentage, not number o…
Browse files Browse the repository at this point in the history
…f jobs. Moved a debugging message a few lines forward as it was called where a few logged parameters where invalid, leading to a crash
  • Loading branch information
antirez committed Jan 21, 2010
1 parent 76b7233 commit f6c0bba
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,10 @@
#define REDIS_VM_MAX_RANDOM_JUMP 4096
#define REDIS_VM_MAX_THREADS 32
#define REDIS_THREAD_STACK_SIZE (1024*1024*4)
/* The following is the number of completed I/O jobs to process when the
* handelr is called. 1 is the minimum, and also the default, as it allows
* to block as little as possible other accessing clients. While Virtual
* Memory I/O operations are performed by threads, this operations must
* be processed by the main thread when completed to take effect. */
/* The following is the *percentage* of completed I/O jobs to process when the
* handelr is called. While Virtual Memory I/O operations are performed by
* threads, this operations must be processed by the main thread when completed
* in order to take effect. */
#define REDIS_MAX_COMPLETED_JOBS_PROCESSED 1

/* Client flags */
Expand Down Expand Up @@ -7170,7 +7169,6 @@ static int vmFindContiguousPages(off_t *first, off_t n) {
while(offset < server.vm_pages) {
off_t this = base+offset;

redisLog(REDIS_DEBUG, "THIS: %lld (%c)\n", (long long) this, vmFreePage(this) ? 'F' : 'X');
/* If we overflow, restart from page zero */
if (this >= server.vm_pages) {
this -= server.vm_pages;
Expand All @@ -7180,6 +7178,7 @@ static int vmFindContiguousPages(off_t *first, off_t n) {
numfree = 0;
}
}
redisLog(REDIS_DEBUG, "THIS: %lld (%c)\n", (long long) this, vmFreePage(this) ? 'F' : 'X');
if (vmFreePage(this)) {
/* This is a free page */
numfree++;
Expand Down Expand Up @@ -7503,6 +7502,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
char buf[1];
int retval;
int processed = 0;
int toprocess = -1;
REDIS_NOTUSED(el);
REDIS_NOTUSED(mask);
REDIS_NOTUSED(privdata);
Expand All @@ -7520,6 +7520,10 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
/* Get the processed element (the oldest one) */
lockThreadedIO();
assert(listLength(server.io_processed) != 0);
if (toprocess == -1) {
toprocess = (listLength(server.io_processed)*REDIS_MAX_COMPLETED_JOBS_PROCESSED)/100;
if (toprocess <= 0) toprocess = 1;
}
ln = listFirst(server.io_processed);
j = ln->value;
listDelNode(server.io_processed,ln);
Expand Down Expand Up @@ -7608,7 +7612,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
}
}
processed++;
if (processed == REDIS_MAX_COMPLETED_JOBS_PROCESSED) return;
if (processed == toprocess) return;
}
if (retval < 0 && errno != EAGAIN) {
redisLog(REDIS_WARNING,
Expand Down

0 comments on commit f6c0bba

Please sign in to comment.