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

Move LRU Nuking into the stevedores, while preserving the current

stevedore selection algorithm exactly.
parent 18082164
......@@ -142,7 +142,7 @@ STV_NewObject(struct worker *wrk, struct objcore *oc,
const char *hint, unsigned wsl)
{
struct stevedore *stv, *stv0;
int i, j;
int j;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
......@@ -158,13 +158,9 @@ STV_NewObject(struct worker *wrk, struct objcore *oc,
j = stv->allocobj(wrk, stv, oc, wsl, 0);
} while (j == 0 && stv != stv0);
}
if (j == 0) {
if (j == 0 && cache_param->nuke_limit > 0) {
/* no luck; try to free some space and keep trying */
for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) {
if (EXP_NukeOne(wrk, stv->lru) == -1)
break;
j = stv->allocobj(wrk, stv, oc, wsl, 0);
}
j = stv->allocobj(wrk, stv, oc, wsl, cache_param->nuke_limit);
}
if (j == 0)
......
......@@ -517,8 +517,8 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
(void)really;
CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
assert(really >= 0);
/* Don't entertain already dead objects */
if ((oc->exp.ttl + oc->exp.grace + oc->exp.keep) <= 0.)
......@@ -527,10 +527,24 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv,
ltot = sizeof(struct object) + PRNDUP(wsl);
ltot = IRNUP(sc, ltot);
st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg);
if (st == NULL)
return (0);
while (1) {
if (really > 0) {
if (EXP_NukeOne(wrk, stv->lru) == -1)
return (0);
really--;
}
st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg);
if (st != NULL && st->space < ltot) {
stv->free(st); // NOP
st = NULL;
}
if (st != NULL)
break;
if (!really)
return (0);
}
AN(st);
assert(st->space >= ltot);
o = SML_MkObject(stv, oc, st->ptr);
......
......@@ -84,15 +84,25 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
(void)really;
assert(really >= 0);
ltot = sizeof(struct object) + PRNDUP(wsl);
st = stv->alloc(stv, ltot);
if (st == NULL)
return (0);
if (st->space < ltot) {
stv->free(st);
return (0);
while (1) {
if (really > 0) {
if (EXP_NukeOne(wrk, stv->lru) == -1)
return (0);
really--;
}
st = stv->alloc(stv, ltot);
if (st != NULL && st->space < ltot) {
stv->free(st);
st = NULL;
}
if (st != NULL)
break;
if (!really)
return (0);
}
AN(st);
o = SML_MkObject(stv, oc, st->ptr);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
st->len = sizeof(*o);
......
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