Commit 06890681 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Eliminate prefetch, grace was a much better idea.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3781 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 04d699bc
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -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) \
......
/*-
* 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@phk.freebsd.dk>
......@@ -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);
......
......@@ -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
......@@ -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;
......
......@@ -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)
......
......@@ -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 *);
......
......@@ -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");
......
#!/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@phk.freebsd.dk>
......@@ -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}}
......
#!/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@phk.freebsd.dk>
......@@ -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}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment