From: phk Date: Wed, 14 Jan 2009 20:28:27 +0000 (+0000) Subject: Originally we shaved 64 bytes from the session to the worker thread X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91308c53aaafde9e3f19e78207727511fba900dc;p=varnish 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 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3512 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index d0df6f94..22135bd5 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -199,7 +199,6 @@ struct worker { struct VCL_conf *vcl; struct srcaddr *srcaddr; - struct acct acct; unsigned char *wlb, *wlp, *wle; unsigned wlr; @@ -370,6 +369,7 @@ struct sess { struct workreq workreq; struct acct acct; + struct acct acct_req; /* pointers to hash string components */ unsigned nhashptr; diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 88435779..258fbeb2 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -427,7 +427,7 @@ cnt_fetch(struct sess *sp) 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 @@ cnt_first(struct sess *sp) /* 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 @@ cnt_lookup(struct sess *sp) 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 @@ cnt_pass(struct sess *sp) 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 @@ cnt_pipe(struct sess *sp) 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 @@ cnt_start(struct sess *sp) 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 */ diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 5ed25ff2..4ae3f83b 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -84,10 +84,10 @@ PipeSession(struct sess *sp) 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)) { diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index aad5431f..c23da11e 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -140,7 +140,7 @@ RES_WriteObj(struct sess *sp) 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 @@ RES_WriteObj(struct sess *sp) 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 diff --git a/varnish-cache/bin/varnishd/cache_session.c b/varnish-cache/bin/varnishd/cache_session.c index 444e4613..8878baf7 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -222,7 +222,7 @@ ses_sum_acct(struct acct *sum, const struct acct *inc) 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); diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index e000798f..a75a1cf5 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -808,7 +808,7 @@ ESI_Deliver(struct sess *sp) 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);