r3757 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Feb 12 23:26:44 CET 2009


Author: phk
Date: 2009-02-12 23:26:44 +0100 (Thu, 12 Feb 2009)
New Revision: 3757

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Move the LRU timestamp from the objcore to the object, we only access
it when we have used the object anyway.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-02-12 17:23:16 UTC (rev 3756)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-02-12 22:26:44 UTC (rev 3757)
@@ -267,7 +267,6 @@
 	VTAILQ_ENTRY(objcore)	list;
 	VTAILQ_ENTRY(objcore)	lru_list;
 	int			on_lru;
-	double			lru_stamp;
 };
 
 /* Object structure --------------------------------------------------*/
@@ -302,6 +301,7 @@
 	double			prefetch;
 
 	double			last_modified;
+	double			last_lru;
 
 	struct http		http[1];
 
@@ -463,7 +463,7 @@
 void EXP_Insert(struct object *o);
 void EXP_Init(void);
 void EXP_Rearm(const struct object *o);
-void EXP_Touch(const struct object *o, double now);
+int EXP_Touch(const struct object *o);
 int EXP_NukeOne(struct sess *sp);
 
 /* cache_fetch.c */

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2009-02-12 17:23:16 UTC (rev 3756)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2009-02-12 22:26:44 UTC (rev 3757)
@@ -159,8 +159,10 @@
 
 	sp->t_resp = TIM_real();
 	if (sp->obj->objhead != NULL) {
+		if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout &&
+		    EXP_Touch(sp->obj))
+			sp->obj->last_lru = sp->t_resp;	/* XXX: locking ? */
 		sp->obj->last_use = sp->t_resp;	/* XXX: locking ? */
-		EXP_Touch(sp->obj, sp->t_resp);
 	}
 	RES_BuildHttp(sp);
 	VCL_deliver_method(sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-02-12 17:23:16 UTC (rev 3756)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-02-12 22:26:44 UTC (rev 3757)
@@ -133,7 +133,7 @@
 	oc = o->objcore;
 
 	assert(o->entered != 0 && !isnan(o->entered));
-	oc->lru_stamp = o->entered;
+	o->last_lru = o->entered;
 	Lck_Lock(&exp_mtx);
 	assert(oc->timer_idx == BINHEAP_NOIDX);
 	(void)update_object_when(o);
@@ -153,27 +153,27 @@
  * that can be worked around by examining obj.last_use in vcl_discard{}
  */
 
-void
-EXP_Touch(const struct object *o, double now)
+int
+EXP_Touch(const struct object *o)
 {
 	struct objcore *oc;
+	int retval = 0;
 
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	oc = o->objcore;
 	if (oc == NULL)
-		return;
+		return (retval);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	if (oc->lru_stamp + params->lru_timeout > now)
-		return;
 	if (Lck_Trylock(&exp_mtx))
-		return;
+		return (retval);
 	if (oc->on_lru) {
 		VTAILQ_REMOVE(&lru, oc, lru_list);
 		VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
-		oc->lru_stamp = now;
 		VSL_stats->n_lru_moved++;
+		retval = 1;
 	}
 	Lck_Unlock(&exp_mtx);
+	return (retval);
 }
 
 /*--------------------------------------------------------------------



More information about the varnish-commit mailing list