r2560 - in trunk/varnish-cache: bin/varnishd include
phk at projects.linpro.no
phk at projects.linpro.no
Fri Mar 7 12:36:52 CET 2008
Author: phk
Date: 2008-03-07 12:36:52 +0100 (Fri, 07 Mar 2008)
New Revision: 2560
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
trunk/varnish-cache/bin/varnishd/cache_ws.c
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/include/stat_field.h
Log:
Add diagnostic features to keep track of object workspace usage.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-03-07 11:36:52 UTC (rev 2560)
@@ -107,6 +107,7 @@
char *f; /* (F)ree pointer */
char *r; /* (R)eserved length */
char *e; /* (E)nd of buffer */
+ int overflow; /* workspace overflowed */
};
/*--------------------------------------------------------------------
@@ -444,7 +445,7 @@
int HSH_Compare(const struct sess *sp, const struct objhead *o);
void HSH_Copy(const struct sess *sp, const struct objhead *o);
struct object *HSH_Lookup(struct sess *sp);
-void HSH_Unbusy(struct object *o);
+void HSH_Unbusy(struct sess *sp);
void HSH_Ref(struct object *o);
void HSH_Deref(struct object *o);
void HSH_Init(void);
@@ -580,6 +581,7 @@
char *WS_Alloc(struct ws *ws, unsigned bytes);
char *WS_Dup(struct ws *ws, const char *);
char *WS_Snapshot(struct ws *ws);
+unsigned WS_Used(struct ws *ws);
/* rfc2616.c */
int RFC2616_cache_policy(const struct sess *sp, const struct http *hp);
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-03-07 11:36:52 UTC (rev 2560)
@@ -352,7 +352,7 @@
case VCL_RET_RESTART:
sp->obj->ttl = 0;
sp->obj->cacheable = 0;
- HSH_Unbusy(sp->obj);
+ HSH_Unbusy(sp);
HSH_Deref(sp->obj);
sp->obj = NULL;
if (sp->handling == VCL_RET_ERROR)
@@ -375,7 +375,7 @@
if (sp->obj->objhead != NULL) {
VRY_Create(sp);
EXP_Insert(sp->obj, sp->wrk->used);
- HSH_Unbusy(sp->obj);
+ HSH_Unbusy(sp);
}
sp->wrk->acct.fetch++;
sp->step = STP_DELIVER;
@@ -626,7 +626,7 @@
VCL_miss_method(sp);
if (sp->handling == VCL_RET_ERROR) {
sp->obj->cacheable = 0;
- HSH_Unbusy(sp->obj);
+ HSH_Unbusy(sp);
HSH_Deref(sp->obj);
sp->obj = NULL;
VBE_free_bereq(sp->bereq);
@@ -636,7 +636,7 @@
}
if (sp->handling == VCL_RET_PASS) {
sp->obj->cacheable = 0;
- HSH_Unbusy(sp->obj);
+ HSH_Unbusy(sp);
HSH_Deref(sp->obj);
sp->obj = NULL;
sp->step = STP_PASS;
Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-03-07 11:36:52 UTC (rev 2560)
@@ -285,14 +285,23 @@
}
void
-HSH_Unbusy(struct object *o)
+HSH_Unbusy(struct sess *sp)
{
+ struct object *o;
struct objhead *oh;
struct object *parent;
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ o = sp->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy);
assert(o->refcnt > 0);
+ if (o->ws_o->overflow)
+ VSL_stats->n_objoverflow++;
+ if (params->diag_bitmap & 0x40)
+ WSP(sp, SLT_Debug,
+ "Object workspace used %u", WS_Used(o->ws_o));
+
oh = o->objhead;
if (oh != NULL) {
CHECK_OBJ(oh, OBJHEAD_MAGIC);
@@ -356,6 +365,10 @@
if (r != 0)
return;
+ if (params->diag_bitmap & 0x40)
+ VSL(SLT_Debug, 0,
+ "Object workspace max used %u", WS_Used(o->ws_o));
+
if (o->vary != NULL)
free(o->vary);
Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-03-07 11:36:52 UTC (rev 2560)
@@ -111,8 +111,10 @@
WS_Assert(ws);
assert(ws->r == NULL);
- if (ws->f + bytes > ws->e)
+ if (ws->f + bytes > ws->e) {
+ ws->overflow++;
return(NULL);
+ }
r = ws->f;
ws->f += bytes;
WS_DEBUG("WS_Alloc(%p, %u) = %p", ws, bytes, r);
@@ -133,6 +135,14 @@
return (p);
}
+unsigned
+WS_Used(struct ws *ws)
+{
+
+ WS_Assert(ws);
+ return(ws->f - ws->s);
+}
+
char *
WS_Snapshot(struct ws *ws)
{
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-03-07 11:36:52 UTC (rev 2560)
@@ -652,6 +652,7 @@
" 0x00000008 - mutex logging.\n"
" 0x00000010 - mutex contests.\n"
" 0x00000020 - waiting list.\n"
+ " 0x00000040 - object workspace.\n"
"Use 0x notation and do the bitor in your head :-)\n",
0,
"0", "bitmap" },
Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h 2008-03-07 11:13:11 UTC (rev 2559)
+++ trunk/varnish-cache/include/stat_field.h 2008-03-07 11:36:52 UTC (rev 2560)
@@ -72,6 +72,7 @@
MAC_STAT(n_objsendfile, uint64_t, 'a', "Objects sent with sendfile")
MAC_STAT(n_objwrite, uint64_t, 'a', "Objects sent with write")
+MAC_STAT(n_objoverflow, uint64_t, 'a', "Objects overflowing workspace")
MAC_STAT(s_sess, uint64_t, 'a', "Total Sessions")
MAC_STAT(s_req, uint64_t, 'a', "Total Requests")
More information about the varnish-commit
mailing list