]> err.no Git - varnish/commitdiff
Add diagnostic features to keep track of object workspace usage.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Mar 2008 11:36:52 +0000 (11:36 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Mar 2008 11:36:52 +0000 (11:36 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2560 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_ws.c
varnish-cache/bin/varnishd/mgt_param.c
varnish-cache/include/stat_field.h

index b4352a1a65a988bc994c8ead736d947d5bfde150..732444edee590eed358dcefbca4f1b16f5bc6609 100644 (file)
@@ -107,6 +107,7 @@ struct ws {
        char                    *f;             /* (F)ree pointer */
        char                    *r;             /* (R)eserved length */
        char                    *e;             /* (E)nd of buffer */
+       int                     overflow;       /* workspace overflowed */
 };
 
 /*--------------------------------------------------------------------
@@ -444,7 +445,7 @@ void HSH_Prealloc(struct sess *sp);
 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 @@ void WS_Reset(struct ws *ws, char *p);
 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);
index 91a202e08b4a4d68e51e4a4b834231b894417e4a..b6ee80283c8bd8fcbe3d8d225d6f299b6a7fcbd8 100644 (file)
@@ -352,7 +352,7 @@ cnt_fetch(struct sess *sp)
        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 @@ cnt_fetch(struct sess *sp)
        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 @@ cnt_miss(struct sess *sp)
        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 @@ cnt_miss(struct sess *sp)
        }
        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;
index 5c628f5dd6421a3100b030fe1111f9e193fecb1a..59022c02866fbb7823700183474cadf9271c5d25 100644 (file)
@@ -285,14 +285,23 @@ hsh_rush(struct objhead *oh)
 }
 
 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 @@ HSH_Deref(struct object *o)
        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);
 
index e40e1e073ee15fbd189ac7ef1b7094688c84f534..a5b0d793d0d397f4c25c3182cadb958c667cf18e 100644 (file)
@@ -111,8 +111,10 @@ WS_Alloc(struct ws *ws, unsigned bytes)
 
        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 @@ WS_Dup(struct ws *ws, const char *s)
        return (p);
 }
 
+unsigned
+WS_Used(struct ws *ws)
+{
+
+       WS_Assert(ws);
+       return(ws->f - ws->s);
+}
+
 char *
 WS_Snapshot(struct ws *ws)
 {
index c394ea9f26c7084cb250caa518e31dfbd9e9c542..0ab4ea03e6af3d6cd4205d9d7fbea75a612bc7c7 100644 (file)
@@ -652,6 +652,7 @@ static const struct parspec parspec[] = {
                "  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" },
index c3910eba2437a7b0366e65de3e5d157555777d8f..95fc980e4bd3d93ceef4cb0d8d02ef3ae5f19762 100644 (file)
@@ -72,6 +72,7 @@ MAC_STAT(losthdr,             uint64_t, 'a', "HTTP header overflows")
 
 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")