r4226 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include

phk at projects.linpro.no phk at projects.linpro.no
Thu Sep 3 12:48:16 CEST 2009


Author: phk
Date: 2009-09-03 12:48:15 +0200 (Thu, 03 Sep 2009)
New Revision: 4226

Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
   trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
   trunk/varnish-cache/include/stat_field.h
Log:
Account for unresurrected persistent objects in their own stats counter
to fix the discrepancy in the object/objcore count they would otherwise
represent.

XXX: Not quite sure if they should also be counted as a subset of
n_object to give people an easy way to access "total objects available
in cache".  Will decide this later.




Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-09-03 10:48:15 UTC (rev 4226)
@@ -504,7 +504,7 @@
 
 	/*
 	 * At this point we are either committed to flesh out the busy
-	 * object we have in the hash or we have let go of it if we ever
+	 * object we have in the hash or we have let go of it, if we ever
 	 * had one.
 	 */
 

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-09-03 10:48:15 UTC (rev 4226)
@@ -306,6 +306,7 @@
 			sp->objhead = oc->objhead;
 			sp->objcore = oc;
 			HSH_DerefObjCore(sp);
+			sp->wrk->stats.n_vampireobject--;
 		}
 	}
 	NEEDLESS_RETURN(NULL);

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-09-03 10:48:15 UTC (rev 4226)
@@ -183,6 +183,7 @@
 
 	if (w->nobjcore != NULL) {
 		FREE_OBJ(w->nobjcore);
+		w->stats.n_objectcore--;
 		w->nobjcore = NULL;
 	}
 	if (w->nobjhead != NULL) {
@@ -419,7 +420,7 @@
 	/* NB: do not deref objhead the new object inherits our reference */
 	oc->objhead = oh;
 	Lck_Unlock(&oh->mtx);
-	sp->wrk->stats.n_object++;
+	sp->wrk->stats.n_vampireobject++;
 	return (oc);
 }
 
@@ -661,7 +662,6 @@
 
 	Lck_Lock(&oh->mtx);
 	VTAILQ_REMOVE(&oh->objcs, oc, list);
-	sp->wrk->stats.n_object--;
 	Lck_Unlock(&oh->mtx);
 	assert(oh->refcnt > 0);
 	FREE_OBJ(oc);

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-09-03 10:48:15 UTC (rev 4226)
@@ -635,6 +635,8 @@
 	oc->obj->ban = oc->ban;
 
 	sg->nfixed++;
+	sp->wrk->stats.n_object++;
+	sp->wrk->stats.n_vampireobject--;
 }
 
 /*--------------------------------------------------------------------

Modified: trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc	2009-09-03 10:48:15 UTC (rev 4226)
@@ -40,7 +40,8 @@
 varnish v1 -start 
 varnish v1 -cliok "debug.xid 2000"
 
-varnish v1 -expect n_object == 2
+varnish v1 -expect n_vampireobject == 2
+varnish v1 -expect n_object == 0
 
 client c1 {
 	txreq -url "/foo"
@@ -50,7 +51,8 @@
 	expect resp.http.foo == "foo"
 } -run
 
-varnish v1 -expect n_object == 2
+varnish v1 -expect n_vampireobject == 1
+varnish v1 -expect n_object == 1
 
 client c1 {
 	txreq -url "/bar"
@@ -61,3 +63,4 @@
 } -run
 
 varnish v1 -expect n_object == 2
+varnish v1 -expect n_vampireobject == 0

Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h	2009-09-02 20:09:29 UTC (rev 4225)
+++ trunk/varnish-cache/include/stat_field.h	2009-09-03 10:48:15 UTC (rev 4226)
@@ -52,6 +52,7 @@
 MAC_STAT(n_sess_mem,		uint64_t, 0, 'i', "N struct sess_mem")
 MAC_STAT(n_sess,		uint64_t, 0, 'i', "N struct sess")
 MAC_STAT(n_object,		uint64_t, 1, 'i', "N struct object")
+MAC_STAT(n_vampireobject,	uint64_t, 1, 'i', "N unresurrected objects")
 MAC_STAT(n_objectcore,		uint64_t, 1, 'i', "N struct objectcore")
 MAC_STAT(n_objecthead,		uint64_t, 1, 'i', "N struct objecthead")
 MAC_STAT(n_smf,			uint64_t, 0, 'i', "N struct smf")



More information about the varnish-commit mailing list