[master] a0c9c7e Add two counters, one counts purge operations, the other objects purged.

Poul-Henning Kamp phk at FreeBSD.org
Tue May 6 10:57:34 CEST 2014


commit a0c9c7ec12596df022e1546fb21b88acc9c65340
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 6 08:56:41 2014 +0000

    Add two counters, one counts purge operations, the other objects purged.
    
    Suggested by:	Steven Engelhardt via github

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index b0740c1..75a64ac 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1219,6 +1219,7 @@ void WAIT_Write_Session(struct sess *sp, int fd);
 void WRK_Init(void);
 int WRK_TrySumStat(struct worker *w);
 void WRK_SumStat(struct worker *w);
+void WRK_PurgeStat(unsigned nobj);
 void *WRK_thread(void *priv);
 typedef void *bgthread_t(struct worker *, void *priv);
 void WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func,
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index f4bbae0..7aa6d24 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -602,6 +602,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, double ttl, double grace)
 		(void)HSH_DerefObj(&wrk->stats, &o);
 	}
 	WS_Release(wrk->aws, 0);
+	WRK_PurgeStat(nobj);
 }
 
 
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index ec18df9..6496a3a 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -77,6 +77,19 @@ WRK_TrySumStat(struct worker *w)
 }
 
 /*--------------------------------------------------------------------
+ * Helper function to update stats for purges under lock
+ */
+
+void
+WRK_PurgeStat(unsigned nobj)
+{
+	Lck_Lock(&wstat_mtx);
+	VSC_C_main->n_purges++;
+	VSC_C_main->n_obj_purged += nobj;
+	Lck_Unlock(&wstat_mtx);
+}
+
+/*--------------------------------------------------------------------
  * Create and starte a back-ground thread which as its own worker and
  * session data structures;
  */
diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h
index 4040b0d..8f25d39 100644
--- a/include/tbl/vsc_f_main.h
+++ b/include/tbl/vsc_f_main.h
@@ -583,6 +583,17 @@ VSC_F(bans_persisted_fragmentation,	uint64_t, 0, 'g', diag,
 
 /*--------------------------------------------------------------------*/
 
+VSC_F(n_purges,			uint64_t, 0, 'i', info,
+    "Number of purge operations",
+	""
+)
+VSC_F(n_obj_purged,		uint64_t, 0, 'i', info,
+    "number of purged objects",
+	""
+)
+
+/*--------------------------------------------------------------------*/
+
 VSC_F(exp_mailed,			uint64_t, 0, 'c', diag,
     "Number of objects mailed to expiry thread",
 	"Number of objects mailed to expiry thread for handling."



More information about the varnish-commit mailing list