From: phk Date: Tue, 17 Feb 2009 10:29:20 +0000 (+0000) Subject: Eliminate prefetch, grace was a much better idea. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=088f4b40d1967ca27721354fe58efd95886a0920;p=varnish Eliminate prefetch, grace was a much better idea. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3781 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 637aac60..ba020bfe 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -265,7 +265,6 @@ struct objcore { 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 @@ struct object { double age; double entered; double grace; - double prefetch; double last_modified; double last_lru; diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index e6f20e97..9d3d7a4e 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -70,7 +70,6 @@ static VTAILQ_HEAD(,objcore) lru = VTAILQ_HEAD_INITIALIZER(lru); static const char *timer_what[] = { [OC_T_TTL] = "TTL", - [OC_T_PREFETCH] = "Prefetch", }; /* @@ -96,17 +95,8 @@ update_object_when(const struct object *o) 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 @@ EXP_Rearm(const struct object *o) /*-------------------------------------------------------------------- * 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 @@ exp_timer(void *arg) 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(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(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); } } diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 86621b28..290ddae3 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -424,44 +424,6 @@ VRT_r_obj_grace(const struct sess *sp) /*--------------------------------------------------------------------*/ -/* 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) \ diff --git a/varnish-cache/bin/varnishd/default.vcl b/varnish-cache/bin/varnishd/default.vcl index 711aeaa8..dcf144ac 100644 --- a/varnish-cache/bin/varnishd/default.vcl +++ b/varnish-cache/bin/varnishd/default.vcl @@ -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 @@ -97,7 +97,6 @@ sub vcl_fetch { if (obj.http.Set-Cookie) { return (pass); } - set obj.prefetch = -30s; return (deliver); } @@ -110,11 +109,6 @@ sub vcl_discard { 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); diff --git a/varnish-cache/bin/varnishd/flint.sh b/varnish-cache/bin/varnishd/flint.sh index 8497ae96..659cdbbc 100755 --- a/varnish-cache/bin/varnishd/flint.sh +++ b/varnish-cache/bin/varnishd/flint.sh @@ -14,7 +14,7 @@ flexelint \ > $T if [ -f _flint.old ] ; then diff -u _flint.old $T - mv $T _flint.old fi cat $T +cp $T _flint.old rm $T diff --git a/varnish-cache/include/vcl.h b/varnish-cache/include/vcl.h index 9bd7ae6f..d8b51cd4 100644 --- a/varnish-cache/include/vcl.h +++ b/varnish-cache/include/vcl.h @@ -22,12 +22,11 @@ typedef int vcl_func_f(struct sess *sp); #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 @@ struct VCL_conf { 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; diff --git a/varnish-cache/include/vcl_returns.h b/varnish-cache/include/vcl_returns.h index 18fbc84f..6421a6de 100644 --- a/varnish-cache/include/vcl_returns.h +++ b/varnish-cache/include/vcl_returns.h @@ -60,10 +60,6 @@ VCL_MET_MAC(deliver,DELIVER, ((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) diff --git a/varnish-cache/include/vrt_obj.h b/varnish-cache/include/vrt_obj.h index 44c17380..74490878 100644 --- a/varnish-cache/include/vrt_obj.h +++ b/varnish-cache/include/vrt_obj.h @@ -47,8 +47,6 @@ double VRT_r_obj_ttl(const struct sess *); 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 *); diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index bb6df1d8..3a737f15 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -174,11 +174,10 @@ vcl_output_lang_h(struct vsb *sb) 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 @@ vcl_output_lang_h(struct vsb *sb) 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 @@ vcl_output_lang_h(struct vsb *sb) 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 @@ vcl_output_lang_h(struct vsb *sb) /* ../../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 @@ vcl_output_lang_h(struct vsb *sb) 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"); diff --git a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl index 648a8257..66033c96 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl @@ -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 @@ -42,7 +42,6 @@ set methods { {hit {error restart pass deliver}} {fetch {error restart pass deliver}} {deliver {restart deliver}} - {prefetch {fetch pass}} {timeout {fetch discard}} {discard {discard keep}} {error {deliver}} diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index 405ca02b..89ce9029 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -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 @@ -185,11 +185,6 @@ set spobj { { 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} diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index a7f98211..c9c6c98b 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -166,11 +166,6 @@ struct var vcc_vars[] = { 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,