r3781 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Tue Feb 17 11:29:20 CET 2009


Author: phk
Date: 2009-02-17 11:29:20 +0100 (Tue, 17 Feb 2009)
New Revision: 3781

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/bin/varnishd/default.vcl
   trunk/varnish-cache/bin/varnishd/flint.sh
   trunk/varnish-cache/include/vcl.h
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Eliminate prefetch, grace was a much better idea.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-02-17 10:29:20 UTC (rev 3781)
@@ -265,7 +265,6 @@
 	double			ttl;
 	unsigned char		timer_what;
 #define OC_T_TTL		1
-#define OC_T_PREFETCH		2
 	unsigned char		flags;
 #define OC_F_ONLRU		(1<<0)
 #define OC_F_BUSY		(1<<1)
@@ -300,7 +299,6 @@
 	double			age;
 	double			entered;
 	double			grace;
-	double			prefetch;
 
 	double			last_modified;
 	double			last_lru;

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-02-17 10:29:20 UTC (rev 3781)
@@ -70,7 +70,6 @@
 
 static const char *timer_what[] = {
 	[OC_T_TTL]	=	"TTL",
-	[OC_T_PREFETCH]	=	"Prefetch",
 };
 
 /*
@@ -96,17 +95,8 @@
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	Lck_AssertHeld(&exp_mtx);
 
-	if (o->prefetch < 0.0) {
-		when = oc->ttl + o->prefetch;
-		what = OC_T_PREFETCH;
-	} else if (o->prefetch > 0.0) {
-		assert(o->prefetch <= oc->ttl);
-		when = o->prefetch;
-		what = OC_T_PREFETCH;
-	} else {
-		when = oc->ttl + HSH_Grace(o->grace);
-		what = OC_T_TTL;
-	}
+	when = oc->ttl + HSH_Grace(o->grace);
+	what = OC_T_TTL;
 	assert(!isnan(when));
 	oc->timer_what = what;
 	if (when == oc->timer_when)
@@ -222,7 +212,7 @@
 /*--------------------------------------------------------------------
  * This thread monitors the root of the binary heap and whenever an
  * object gets close enough, VCL is asked to decide if it should be
- * discarded or prefetched.
+ * discarded.
  */
 
 static void *
@@ -281,38 +271,21 @@
 		WSL(&ww, SLT_ExpPick, 0, "%u %s", o->xid,
 		    timer_what[oc->timer_what]);
 
-		if (oc->timer_what == OC_T_PREFETCH) {
-			o->prefetch = 0.0;
-			sp->obj = o;
-			VCL_prefetch_method(sp);
-			sp->obj = NULL;
-			if (sp->handling == VCL_RET_FETCH) {
-				WSL(&ww, SLT_Debug, 0, "Attempt Prefetch %u",
-				    o->xid);
-			}
-			Lck_Lock(&exp_mtx);
-			assert(oc->timer_idx == BINHEAP_NOIDX);
-			(void)update_object_when(o);
-			binheap_insert(exp_heap, oc);
-			assert(oc->timer_idx != BINHEAP_NOIDX);
-			Lck_Unlock(&exp_mtx);
-		} else {
-			assert(oc->timer_what == OC_T_TTL);
-			sp->obj = o;
-			VCL_timeout_method(sp);
-			sp->obj = NULL;
+		assert(oc->timer_what == OC_T_TTL);
+		sp->obj = o;
+		VCL_timeout_method(sp);
+		sp->obj = NULL;
 
-			assert(sp->handling == VCL_RET_DISCARD);
-			WSL(&ww, SLT_ExpKill, 0,
-			    "%u %d", o->xid, (int)(o->objcore->ttl - t));
-			Lck_Lock(&exp_mtx);
-			assert(oc->timer_idx == BINHEAP_NOIDX);
-			VTAILQ_REMOVE(&lru, o->objcore, lru_list);
-			oc->flags &= ~OC_F_ONLRU;
-			VSL_stats->n_expired++;
-			Lck_Unlock(&exp_mtx);
-			HSH_Deref(&o);
-		}
+		assert(sp->handling == VCL_RET_DISCARD);
+		WSL(&ww, SLT_ExpKill, 0,
+		    "%u %d", o->xid, (int)(o->objcore->ttl - t));
+		Lck_Lock(&exp_mtx);
+		assert(oc->timer_idx == BINHEAP_NOIDX);
+		VTAILQ_REMOVE(&lru, o->objcore, lru_list);
+		oc->flags &= ~OC_F_ONLRU;
+		VSL_stats->n_expired++;
+		Lck_Unlock(&exp_mtx);
+		HSH_Deref(&o);
 	}
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-02-17 10:29:20 UTC (rev 3781)
@@ -424,44 +424,6 @@
 
 /*--------------------------------------------------------------------*/
 
-/* XXX: the VCL_info messages has unexpected fractions on the ttl */
-
-void
-VRT_l_obj_prefetch(const struct sess *sp, double a)
-{
-
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);	/* XXX */
-	if (sp->obj->objcore == NULL)
-		return;
-	sp->obj->prefetch = 0.0;
-	if (a == 0.0)
-		sp->obj->prefetch = a;
-	else if (a > 0.0 && a + sp->t_req <= sp->obj->objcore->ttl)
-		sp->obj->prefetch = a + sp->t_req;
-	else if (a < 0.0 && a + sp->obj->objcore->ttl > sp->t_req)
-		sp->obj->prefetch = a;
-	else if (a > 0.0)
-		WSL(sp->wrk, SLT_VCL_info, sp->id,
-		    "XID %u: obj.prefetch (%g) after TTL (%g), ignored.",
-		    sp->obj->xid, a, sp->obj->objcore->ttl - sp->t_req);
-	else /* if (a < 0.0) */
-		WSL(sp->wrk, SLT_VCL_info, sp->id,
-		    "XID %u: obj.prefetch (%g) less than ttl (%g), ignored.",
-		    sp->obj->xid, a, sp->obj->objcore->ttl - sp->t_req);
-	EXP_Rearm(sp->obj);
-}
-
-double
-VRT_r_obj_prefetch(const struct sess *sp)
-{
-	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);	/* XXX */
-	return (sp->obj->prefetch - sp->t_req);
-}
-
-/*--------------------------------------------------------------------*/
-
 #define VOBJ(type,onm,field)						\
 void									\
 VRT_l_obj_##onm(const struct sess *sp, type a)				\

Modified: trunk/varnish-cache/bin/varnishd/default.vcl
===================================================================
--- trunk/varnish-cache/bin/varnishd/default.vcl	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/bin/varnishd/default.vcl	2009-02-17 10:29:20 UTC (rev 3781)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro AS
+ * Copyright (c) 2006-2009 Linpro AS
  * All rights reserved.
  *
  * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
@@ -97,7 +97,6 @@
     if (obj.http.Set-Cookie) {
         return (pass);
     }
-    set obj.prefetch =  -30s;
     return (deliver);
 }
 
@@ -110,11 +109,6 @@
     return (discard);
 }
 
-sub vcl_prefetch {
-    /* XXX: Do not redefine vcl_prefetch{}, it is not yet supported */
-    return (fetch);
-}
-
 sub vcl_timeout {
     /* XXX: Do not redefine vcl_timeout{}, it is not yet supported */
     return (discard);

Modified: trunk/varnish-cache/bin/varnishd/flint.sh
===================================================================
--- trunk/varnish-cache/bin/varnishd/flint.sh	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/bin/varnishd/flint.sh	2009-02-17 10:29:20 UTC (rev 3781)
@@ -14,7 +14,7 @@
 	> $T
 if [ -f _flint.old ] ; then
 	diff -u _flint.old $T
-	mv $T _flint.old
 fi
 cat $T
+cp $T _flint.old
 rm $T

Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/include/vcl.h	2009-02-17 10:29:20 UTC (rev 3781)
@@ -22,12 +22,11 @@
 #define VCL_MET_HIT		(1 << 5)
 #define VCL_MET_FETCH		(1 << 6)
 #define VCL_MET_DELIVER		(1 << 7)
-#define VCL_MET_PREFETCH	(1 << 8)
-#define VCL_MET_TIMEOUT		(1 << 9)
-#define VCL_MET_DISCARD		(1 << 10)
-#define VCL_MET_ERROR		(1 << 11)
+#define VCL_MET_TIMEOUT		(1 << 8)
+#define VCL_MET_DISCARD		(1 << 9)
+#define VCL_MET_ERROR		(1 << 10)
 
-#define VCL_MET_MAX		12
+#define VCL_MET_MAX		11
 
 /* VCL Returns */
 #define VCL_RET_ERROR		0
@@ -71,7 +70,6 @@
 	vcl_func_f	*hit_func;
 	vcl_func_f	*fetch_func;
 	vcl_func_f	*deliver_func;
-	vcl_func_f	*prefetch_func;
 	vcl_func_f	*timeout_func;
 	vcl_func_f	*discard_func;
 	vcl_func_f	*error_func;

Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/include/vcl_returns.h	2009-02-17 10:29:20 UTC (rev 3781)
@@ -60,10 +60,6 @@
      ((1 << VCL_RET_RESTART)
     | (1 << VCL_RET_DELIVER)
 ))
-VCL_MET_MAC(prefetch,PREFETCH,
-     ((1 << VCL_RET_FETCH)
-    | (1 << VCL_RET_PASS)
-))
 VCL_MET_MAC(timeout,TIMEOUT,
      ((1 << VCL_RET_FETCH)
     | (1 << VCL_RET_DISCARD)

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/include/vrt_obj.h	2009-02-17 10:29:20 UTC (rev 3781)
@@ -47,8 +47,6 @@
 void VRT_l_obj_ttl(const struct sess *, double);
 double VRT_r_obj_grace(const struct sess *);
 void VRT_l_obj_grace(const struct sess *, double);
-double VRT_r_obj_prefetch(const struct sess *);
-void VRT_l_obj_prefetch(const struct sess *, double);
 double VRT_r_obj_lastuse(const struct sess *);
 const char * VRT_r_obj_hash(const struct sess *);
 const char * VRT_r_resp_proto(const struct sess *);

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-02-17 10:29:20 UTC (rev 3781)
@@ -174,11 +174,10 @@
 	vsb_cat(sb, "#define VCL_MET_HIT\t\t(1 << 5)\n");
 	vsb_cat(sb, "#define VCL_MET_FETCH\t\t(1 << 6)\n");
 	vsb_cat(sb, "#define VCL_MET_DELIVER\t\t(1 << 7)\n");
-	vsb_cat(sb, "#define VCL_MET_PREFETCH\t(1 << 8)\n");
-	vsb_cat(sb, "#define VCL_MET_TIMEOUT\t\t(1 << 9)\n");
-	vsb_cat(sb, "#define VCL_MET_DISCARD\t\t(1 << 10)\n");
-	vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 11)\n");
-	vsb_cat(sb, "\n#define VCL_MET_MAX\t\t12\n\n");
+	vsb_cat(sb, "#define VCL_MET_TIMEOUT\t\t(1 << 8)\n");
+	vsb_cat(sb, "#define VCL_MET_DISCARD\t\t(1 << 9)\n");
+	vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 10)\n");
+	vsb_cat(sb, "\n#define VCL_MET_MAX\t\t11\n\n");
 	vsb_cat(sb, "/* VCL Returns */\n#define VCL_RET_ERROR\t\t0\n");
 	vsb_cat(sb, "#define VCL_RET_LOOKUP\t\t1\n#define VCL_RET_HASH\t\t2");
 	vsb_cat(sb, "\n#define VCL_RET_PIPE\t\t3\n#define VCL_RET_PASS\t\t4");
@@ -199,10 +198,9 @@
 	vsb_cat(sb, "\tvcl_func_f\t*pass_func;\n\tvcl_func_f\t*hash_func;\n");
 	vsb_cat(sb, "\tvcl_func_f\t*miss_func;\n\tvcl_func_f\t*hit_func;\n");
 	vsb_cat(sb, "\tvcl_func_f\t*fetch_func;\n\tvcl_func_f\t*deliver_fun");
-	vsb_cat(sb, "c;\n\tvcl_func_f\t*prefetch_func;\n");
-	vsb_cat(sb, "\tvcl_func_f\t*timeout_func;\n\tvcl_func_f\t*discard_f");
-	vsb_cat(sb, "unc;\n\tvcl_func_f\t*error_func;\n");
-	vsb_cat(sb, "};\n");
+	vsb_cat(sb, "c;\n\tvcl_func_f\t*timeout_func;\n");
+	vsb_cat(sb, "\tvcl_func_f\t*discard_func;\n\tvcl_func_f\t*error_fun");
+	vsb_cat(sb, "c;\n};\n");
 
 	/* ../../include/vrt.h */
 
@@ -235,8 +233,8 @@
 	vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
 	vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
 	vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
-	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3541 2009-01-23 21:");
-	vsb_cat(sb, "17:02Z phk $\n *\n * Runtime support for compiled VCL ");
+	vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3542 2009-01-24 10:");
+	vsb_cat(sb, "36:46Z phk $\n *\n * Runtime support for compiled VCL ");
 	vsb_cat(sb, "programs.\n *\n * XXX: When this file is changed, lib/");
 	vsb_cat(sb, "libvcl/vcc_gen_fixed_token.tcl\n");
 	vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n");
@@ -324,9 +322,9 @@
 
 	/* ../../include/vrt_obj.h */
 
-	vsb_cat(sb, "/*\n * $Id: vrt_obj.h 3406 2008-11-19 14:13:57Z petter");
-	vsb_cat(sb, " $\n *\n * NB:  This file is machine generated, DO NOT");
-	vsb_cat(sb, " EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3406 2008-11-19 14:13:57Z ");
+	vsb_cat(sb, "petter $\n *\n * NB:  This file is machine generated, ");
+	vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
 	vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
 	vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
 	vsb_cat(sb, "s *);\nint VRT_r_server_port(struct sess *);\n");
@@ -370,8 +368,6 @@
 	vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
 	vsb_cat(sb, "double VRT_r_obj_grace(const struct sess *);\n");
 	vsb_cat(sb, "void VRT_l_obj_grace(const struct sess *, double);\n");
-	vsb_cat(sb, "double VRT_r_obj_prefetch(const struct sess *);\n");
-	vsb_cat(sb, "void VRT_l_obj_prefetch(const struct sess *, double);\n");
 	vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
 	vsb_cat(sb, "const char * VRT_r_obj_hash(const struct sess *);\n");
 	vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2009-02-17 10:29:20 UTC (rev 3781)
@@ -1,7 +1,7 @@
 #!/usr/local/bin/tclsh8.4
 #-
 # Copyright (c) 2006 Verdens Gang AS
-# Copyright (c) 2006-2008 Linpro AS
+# Copyright (c) 2006-2009 Linpro AS
 # All rights reserved.
 #
 # Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
@@ -42,7 +42,6 @@
 	{hit		{error restart pass deliver}}
 	{fetch		{error restart pass deliver}}
 	{deliver	{restart deliver}}
-	{prefetch	{fetch pass}}
 	{timeout	{fetch discard}}
 	{discard	{discard keep}}
 	{error		{deliver}}

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-02-17 10:29:20 UTC (rev 3781)
@@ -1,7 +1,7 @@
 #!/usr/local/bin/tclsh8.4
 #-
 # Copyright (c) 2006 Verdens Gang AS
-# Copyright (c) 2006-2008 Linpro AS
+# Copyright (c) 2006-2009 Linpro AS
 # All rights reserved.
 #
 # Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
@@ -185,11 +185,6 @@
 	{                         hit fetch         discard timeout error}
 	"const struct sess *"
     }
-    { obj.prefetch
-	RW RTIME
-	{ fetch prefetch }
-	"const struct sess *"
-    }
     { obj.lastuse
 	RO TIME
 	{                         hit fetch deliver discard timeout error}

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-02-17 10:12:21 UTC (rev 3780)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-02-17 10:29:20 UTC (rev 3781)
@@ -166,11 +166,6 @@
 	    VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
 	     | VCL_MET_ERROR
 	},
-	{ "obj.prefetch", RTIME, 12,
-	    "VRT_r_obj_prefetch(sp)",	    "VRT_l_obj_prefetch(sp, ",
-	    V_RW,	    0,
-	    VCL_MET_FETCH | VCL_MET_PREFETCH
-	},
 	{ "obj.lastuse", TIME, 11,
 	    "VRT_r_obj_lastuse(sp)",	    NULL,
 	    V_RO,	    0,



More information about the varnish-commit mailing list