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

Integrate EXP_Touch() into sml_touch()

parent 6f6bf9db
......@@ -690,7 +690,6 @@ void EXP_Insert(struct worker *wrk, struct objcore *oc);
void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep);
void EXP_Touch(struct objcore *oc, double now);
int EXP_NukeOne(struct worker *wrk, struct lru *lru);
enum exp_event_e {
......
......@@ -216,45 +216,6 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
exp_mail_it(oc);
}
/*--------------------------------------------------------------------
* Object was used, move to tail of LRU list.
*
* To avoid the exphdl->mtx becoming a hotspot, we only attempt to move
* objects if they have not been moved recently and if the lock is available.
* This optimization obviously leaves the LRU list imperfectly sorted.
*/
void
EXP_Touch(struct objcore *oc, double now)
{
struct lru *lru;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->flags & OC_F_INCOMPLETE)
return;
if (now - oc->last_lru < cache_param->lru_interval)
return;
lru = ObjGetLRU(oc);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
if (Lck_Trylock(&lru->mtx))
return;
AN(oc->exp_flags & OC_EF_EXP);
if (!(oc->exp_flags & OC_EF_OFFLRU)) {
/* Can only touch it while it's actually on the LRU list */
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
VSC_C_main->n_lru_moved++;
}
oc->last_lru = now;
Lck_Unlock(&lru->mtx);
}
/*--------------------------------------------------------------------
* We have changed one or more of the object timers, tell the exp_thread
*
......
......@@ -560,10 +560,40 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
static void __match_proto__(objtouch_f)
sml_touch(struct worker *wrk, struct objcore *oc, double now)
{
struct lru *lru;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
EXP_Touch(oc, now);
/*
* To avoid the exphdl->mtx becoming a hotspot, we only
* attempt to move objects if they have not been moved
* recently and if the lock is available. This optimization
* obviously leaves the LRU list imperfectly sorted.
*/
if (oc->flags & OC_F_INCOMPLETE)
return;
if (now - oc->last_lru < cache_param->lru_interval)
return;
lru = ObjGetLRU(oc);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
if (Lck_Trylock(&lru->mtx))
return;
AN(oc->exp_flags & OC_EF_EXP);
if (!(oc->exp_flags & OC_EF_OFFLRU)) {
/* Can only touch it while it's actually on the LRU list */
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
VSC_C_main->n_lru_moved++;
}
oc->last_lru = now;
Lck_Unlock(&lru->mtx);
}
const struct obj_methods SML_methods = {
......
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