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

Reduce cost of HSH_Insert by one oh->mtx lock/unlock by grabbing

the refcount adjecent to the call.
parent 44108468
......@@ -124,12 +124,11 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->refcnt >= 2);
AZ(oc->exp_flags & (OC_EF_INSERT | OC_EF_MOVE));
AZ(oc->flags & OC_F_DYING);
HSH_Ref(oc);
ObjSendEvent(wrk, oc, OEV_INSERT);
exp_mail_it(oc, OC_EF_INSERT | OC_EF_EXP | OC_EF_MOVE);
}
......
......@@ -263,7 +263,9 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc,
AN(digest);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(ban);
AN(oc->flags & OC_F_BUSY);
AZ(oc->flags & OC_F_PRIVATE);
assert(oc->refcnt == 1);
hsh_prealloc(wrk);
......@@ -275,9 +277,9 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc,
/* Mark object busy and insert (precreated) objcore in
objecthead. The new object inherits our objhead reference. */
oc->flags |= OC_F_BUSY;
oc->objhead = oh;
VTAILQ_INSERT_TAIL(&oh->objcs, oc, hsh_list);
oc->refcnt++; // For EXP_Insert
Lck_Unlock(&oh->mtx);
BAN_RefBan(oc, ban);
......@@ -662,16 +664,19 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)
AN(oc->stobj->stevedore);
AN(oc->flags & OC_F_BUSY);
assert(oh->refcnt > 0);
assert(oc->refcnt > 0);
if (!(oc->flags & OC_F_PRIVATE)) {
BAN_NewObjCore(oc);
AN(oc->ban);
EXP_Insert(wrk, oc);
}
/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
Lck_Lock(&oh->mtx);
assert(oh->refcnt > 0);
assert(oc->refcnt > 0);
if (!(oc->flags & OC_F_PRIVATE))
oc->refcnt++; // For EXP_Insert
/* XXX: strictly speaking, we should sort in Date: order. */
VTAILQ_REMOVE(&oh->objcs, oc, hsh_list);
VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list);
......@@ -679,6 +684,8 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)
if (!VTAILQ_EMPTY(&oh->waitinglist))
hsh_rush(wrk, oh);
Lck_Unlock(&oh->mtx);
if (!(oc->flags & OC_F_PRIVATE))
EXP_Insert(wrk, oc);
}
/*====================================================================
......
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