From ea5ba811033de7b06241d813309008fe752c6a28 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 30 Jul 2008 15:34:38 +0000 Subject: [PATCH] Add statistics about regexp purges. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3032 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_ban.c | 14 ++++++++++++-- varnish-cache/include/stat_field.h | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index bf0d520a..c4f3f27a 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -95,7 +95,10 @@ BAN_Add(struct cli *cli, const char *regexp, int hash) LOCK(&ban_mtx); VTAILQ_INSERT_HEAD(&ban_head, b, list); ban_start = b; + VSL_stats->n_purge++; + VSL_stats->n_purge_add++; UNLOCK(&ban_mtx); + return (0); } @@ -126,10 +129,13 @@ BAN_DestroyObj(struct object *o) /* Check if we can purge the last ban entry */ b = VTAILQ_LAST(&ban_head, banhead); - if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) + if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) { + VSL_stats->n_purge--; + VSL_stats->n_purge_retire++; VTAILQ_REMOVE(&ban_head, b, list); - else + } else { b = NULL; + } UNLOCK(&ban_mtx); if (b != NULL) { free(b->ban); @@ -144,6 +150,7 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash) { struct ban *b; struct ban * volatile b0; + unsigned tests; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o->ban, BAN_MAGIC); @@ -158,7 +165,9 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash) * a refcount on a ban somewhere in the list and we do not * inspect the list past that ban. */ + tests = 0; for (b = b0; b != o->ban; b = VTAILQ_NEXT(b, list)) { + tests++; if (!regexec(&b->regexp, b->hash ? hash : url, 0, NULL, 0)) break; } @@ -167,6 +176,7 @@ BAN_CheckObject(struct object *o, const char *url, const char *hash) o->ban->refcount--; if (b == o->ban) /* not banned */ b0->refcount++; + VSL_stats->n_purge_test++; UNLOCK(&ban_mtx); if (b == o->ban) { /* not banned */ diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index 8cc050f2..6d095fbd 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -116,3 +116,8 @@ MAC_STAT(backend_req, uint64_t, 'a', "Backend requests made") MAC_STAT(n_vcl, uint64_t, 'a', "N vcl total") MAC_STAT(n_vcl_avail, uint64_t, 'a', "N vcl available") MAC_STAT(n_vcl_discard, uint64_t, 'a', "N vcl discarded") + +MAC_STAT(n_purge, uint64_t, 'i', "N total active purges") +MAC_STAT(n_purge_add, uint64_t, 'a', "N new purges added") +MAC_STAT(n_purge_retire, uint64_t, 'a', "N old purges deleted") +MAC_STAT(n_purge_test, uint64_t, 'a', "N purge record tests") -- 2.39.5