r3512 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Wed Jan 14 21:28:27 CET 2009


Author: phk
Date: 2009-01-14 21:28:27 +0100 (Wed, 14 Jan 2009)
New Revision: 3512

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
   trunk/varnish-cache/bin/varnishd/cache_session.c
   trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
Log:
Originally we shaved 64 bytes from the session to the worker thread
by keeping the current requests accounting stats in the worker thread.

For reasons which will be explained in the next commit, this is no
longer a good idea, and this commit moves these counters from
the worker thread to the session at a slight but all in all
trivial cost in memory footprint.

Remove the call to SES_Charge() when we hit a busy object, it is
not necessary to clean the worker thread counters here now.

Move these counters from the worker thread to the see


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-01-14 20:28:27 UTC (rev 3512)
@@ -199,7 +199,6 @@
 
 	struct VCL_conf		*vcl;
 	struct srcaddr		*srcaddr;
-	struct acct		acct;
 
 	unsigned char		*wlb, *wlp, *wle;
 	unsigned		wlr;
@@ -370,6 +369,7 @@
 
 	struct workreq		workreq;
 	struct acct		acct;
+	struct acct		acct_req;
 
 	/* pointers to hash string components */
 	unsigned		nhashptr;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-01-14 20:28:27 UTC (rev 3512)
@@ -427,7 +427,7 @@
 		EXP_Insert(sp->obj);
 		HSH_Unbusy(sp);
 	}
-	sp->wrk->acct.fetch++;
+	sp->acct_req.fetch++;
 	sp->step = STP_DELIVER;
 	return (0);
 }
@@ -457,7 +457,7 @@
 	/* Receive a HTTP protocol request */
 	HTC_Init(sp->htc, sp->ws, sp->fd);
 	sp->wrk->lastused = sp->t_open;
-	sp->wrk->acct.sess++;
+	sp->acct_req.sess++;
 	SES_RefSrcAddr(sp);
 	do
 		i = HTC_Rx(sp->htc);
@@ -591,7 +591,6 @@
 		if (params->diag_bitmap & 0x20)
 			WSP(sp, SLT_Debug,
 			    "on waiting list <%s>", sp->objhead->hash);
-		SES_Charge(sp);
 		return (1);
 	}
 
@@ -721,7 +720,7 @@
 		return (0);
 	}
 	assert(sp->handling == VCL_RET_PASS);
-	sp->wrk->acct.pass++;
+	sp->acct_req.pass++;
 	HSH_Prealloc(sp);
 	sp->obj = sp->wrk->nobj;
 	sp->wrk->nobj = NULL;
@@ -763,7 +762,7 @@
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
 
-	sp->wrk->acct.pipe++;
+	sp->acct_req.pipe++;
 	http_FilterHeader(sp, HTTPH_R_PIPE);
 
 	VCL_pipe_method(sp);
@@ -871,7 +870,7 @@
 	VSL_stats->client_req++;			/* XXX not locked */
 	sp->t_req = TIM_real();
 	sp->wrk->lastused = sp->t_req;
-	sp->wrk->acct.req++;
+	sp->acct_req.req++;
 
 	/* Assign XID and log */
 	sp->xid = ++xids;				/* XXX not locked */

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2009-01-14 20:28:27 UTC (rev 3512)
@@ -84,10 +84,10 @@
 	TCP_blocking(vc->fd);
 
 	WRW_Reserve(w, &vc->fd);
-	w->acct.hdrbytes += http_Write(w, bereq->http, 0);
+	sp->acct_req.hdrbytes += http_Write(w, bereq->http, 0);
 
 	if (sp->htc->pipeline.b != NULL)
-		w->acct.bodybytes +=
+		sp->acct_req.bodybytes +=
 		    WRW_Write(w, sp->htc->pipeline.b, Tlen(sp->htc->pipeline));
 
 	if (WRW_FlushRelease(w)) {

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2009-01-14 20:28:27 UTC (rev 3512)
@@ -140,7 +140,7 @@
 	WRW_Reserve(sp->wrk, &sp->fd);
 
 	if (sp->esis == 0)
-		sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1);
+		sp->acct_req.hdrbytes += http_Write(sp->wrk, sp->http, 1);
 
 	if (sp->wantbody && !VTAILQ_EMPTY(&sp->obj->esibits)) {
 		if (WRW_FlushRelease(sp->wrk)) {
@@ -161,7 +161,7 @@
 			CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 			CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
 			u += st->len;
-			sp->wrk->acct.bodybytes += st->len;
+			sp->acct_req.bodybytes += st->len;
 #ifdef SENDFILE_WORKS
 			/*
 			 * XXX: the overhead of setting up sendfile is not

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c	2009-01-14 20:28:27 UTC (rev 3512)
@@ -222,7 +222,7 @@
 void
 SES_Charge(struct sess *sp)
 {
-	struct acct *a = &sp->wrk->acct;
+	struct acct *a = &sp->acct_req;
 	struct acct b;
 
 	ses_sum_acct(&sp->acct, a);

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2009-01-13 14:18:54 UTC (rev 3511)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2009-01-14 20:28:27 UTC (rev 3512)
@@ -808,7 +808,7 @@
 		if (Tlen(eb->verbatim)) {
 			if (sp->http->protover >= 1.1)
 				(void)WRW_Write(sp->wrk, eb->chunk_length, -1);
-			sp->wrk->acct.bodybytes += WRW_Write(sp->wrk,
+			sp->acct_req.bodybytes += WRW_Write(sp->wrk,
 			    eb->verbatim.b, Tlen(eb->verbatim));
 			if (sp->http->protover >= 1.1)
 				(void)WRW_Write(sp->wrk, "\r\n", -1);



More information about the varnish-commit mailing list