Commit ee46a84a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add diagnostic features to keep track of object workspace usage.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2560 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e1b3481c
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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" },
......
......@@ -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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment