r4445 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Jan 11 15:56:52 CET 2010
Author: phk
Date: 2010-01-11 15:56:52 +0100 (Mon, 11 Jan 2010)
New Revision: 4445
Modified:
trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c
Log:
Don't recycle sessions one by one, batch them up for efficiency.
Modified: trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-01-11 06:48:32 UTC (rev 4444)
+++ trunk/varnish-cache/bin/varnishd/cache_waiter_poll.c 2010-01-11 14:56:52 UTC (rev 4445)
@@ -44,6 +44,8 @@
#include "cache.h"
#include "cache_waiter.h"
+#define NEEV 128
+
static pthread_t vca_poll_thread;
static struct pollfd *pollfd;
static unsigned npoll, hpoll;
@@ -106,9 +108,9 @@
vca_main(void *arg)
{
unsigned v;
- struct sess *sp, *sp2;
+ struct sess *ss[NEEV], *sp, *sp2;
double deadline;
- int i, fd;
+ int i, j, fd;
THR_SetName("cache-poll");
(void)arg;
@@ -119,11 +121,14 @@
v = poll(pollfd, hpoll + 1, 100);
if (v && pollfd[vca_pipes[0]].revents) {
v--;
- i = read(vca_pipes[0], &sp, sizeof sp);
- assert(i == sizeof sp);
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- VTAILQ_INSERT_TAIL(&sesshead, sp, list);
- vca_poll(sp->fd);
+ i = read(vca_pipes[0], ss, sizeof ss);
+ assert(i >= 0);
+ assert((i % sizeof ss[0]) == 0);
+ for (j = 0; j * sizeof ss[0] < i; j += sizeof ss[0]) {
+ CHECK_OBJ_NOTNULL(ss[j], SESS_MAGIC);
+ VTAILQ_INSERT_TAIL(&sesshead, ss[j], list);
+ vca_poll(ss[j]->fd);
+ }
}
deadline = TIM_real() - params->sess_timeout;
VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
More information about the varnish-commit
mailing list