r3032 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Wed Jul 30 17:34:39 CEST 2008


Author: phk
Date: 2008-07-30 17:34:38 +0200 (Wed, 30 Jul 2008)
New Revision: 3032

Modified:
   trunk/varnish-cache/bin/varnishd/cache_ban.c
   trunk/varnish-cache/include/stat_field.h
Log:
Add statistics about regexp purges.



Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_ban.c	2008-07-30 12:18:57 UTC (rev 3031)
+++ trunk/varnish-cache/bin/varnishd/cache_ban.c	2008-07-30 15:34:38 UTC (rev 3032)
@@ -95,7 +95,10 @@
 	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 @@
 
 	/* 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 @@
 {
 	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 @@
 	 * 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 @@
 	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 */

Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h	2008-07-30 12:18:57 UTC (rev 3031)
+++ trunk/varnish-cache/include/stat_field.h	2008-07-30 15:34:38 UTC (rev 3032)
@@ -116,3 +116,8 @@
 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")




More information about the varnish-commit mailing list