]> err.no Git - varnish/commitdiff
Add statistics about regexp purges.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 30 Jul 2008 15:34:38 +0000 (15:34 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 30 Jul 2008 15:34:38 +0000 (15:34 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3032 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_ban.c
varnish-cache/include/stat_field.h

index bf0d520afbadf85a58d258b23ef0eb657380ad32..c4f3f27aa5ea7c2a943fe757e6e0c16a1238f779 100644 (file)
@@ -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 */
index 8cc050f2370dc8ab3abde5c3231cd1ab8612c6de..6d095fbd23ccf64dd89192b189f91eb1d621c352 100644 (file)
@@ -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")