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

Move the LRU timestamp from the objcore to the object, we only access

it when we have used the object anyway.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3757 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 79c70102
...@@ -267,7 +267,6 @@ struct objcore { ...@@ -267,7 +267,6 @@ struct objcore {
VTAILQ_ENTRY(objcore) list; VTAILQ_ENTRY(objcore) list;
VTAILQ_ENTRY(objcore) lru_list; VTAILQ_ENTRY(objcore) lru_list;
int on_lru; int on_lru;
double lru_stamp;
}; };
/* Object structure --------------------------------------------------*/ /* Object structure --------------------------------------------------*/
...@@ -302,6 +301,7 @@ struct object { ...@@ -302,6 +301,7 @@ struct object {
double prefetch; double prefetch;
double last_modified; double last_modified;
double last_lru;
struct http http[1]; struct http http[1];
...@@ -463,7 +463,7 @@ extern pthread_t cli_thread; ...@@ -463,7 +463,7 @@ extern pthread_t cli_thread;
void EXP_Insert(struct object *o); void EXP_Insert(struct object *o);
void EXP_Init(void); void EXP_Init(void);
void EXP_Rearm(const struct object *o); 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); int EXP_NukeOne(struct sess *sp);
/* cache_fetch.c */ /* cache_fetch.c */
......
...@@ -159,8 +159,10 @@ cnt_deliver(struct sess *sp) ...@@ -159,8 +159,10 @@ cnt_deliver(struct sess *sp)
sp->t_resp = TIM_real(); sp->t_resp = TIM_real();
if (sp->obj->objhead != NULL) { 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 ? */ sp->obj->last_use = sp->t_resp; /* XXX: locking ? */
EXP_Touch(sp->obj, sp->t_resp);
} }
RES_BuildHttp(sp); RES_BuildHttp(sp);
VCL_deliver_method(sp); VCL_deliver_method(sp);
......
...@@ -133,7 +133,7 @@ EXP_Insert(struct object *o) ...@@ -133,7 +133,7 @@ EXP_Insert(struct object *o)
oc = o->objcore; oc = o->objcore;
assert(o->entered != 0 && !isnan(o->entered)); assert(o->entered != 0 && !isnan(o->entered));
oc->lru_stamp = o->entered; o->last_lru = o->entered;
Lck_Lock(&exp_mtx); Lck_Lock(&exp_mtx);
assert(oc->timer_idx == BINHEAP_NOIDX); assert(oc->timer_idx == BINHEAP_NOIDX);
(void)update_object_when(o); (void)update_object_when(o);
...@@ -153,27 +153,27 @@ EXP_Insert(struct object *o) ...@@ -153,27 +153,27 @@ EXP_Insert(struct object *o)
* that can be worked around by examining obj.last_use in vcl_discard{} * that can be worked around by examining obj.last_use in vcl_discard{}
*/ */
void int
EXP_Touch(const struct object *o, double now) EXP_Touch(const struct object *o)
{ {
struct objcore *oc; struct objcore *oc;
int retval = 0;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore; oc = o->objcore;
if (oc == NULL) if (oc == NULL)
return; return (retval);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->lru_stamp + params->lru_timeout > now)
return;
if (Lck_Trylock(&exp_mtx)) if (Lck_Trylock(&exp_mtx))
return; return (retval);
if (oc->on_lru) { if (oc->on_lru) {
VTAILQ_REMOVE(&lru, oc, lru_list); VTAILQ_REMOVE(&lru, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru, oc, lru_list); VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
oc->lru_stamp = now;
VSL_stats->n_lru_moved++; VSL_stats->n_lru_moved++;
retval = 1;
} }
Lck_Unlock(&exp_mtx); Lck_Unlock(&exp_mtx);
return (retval);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
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