[master] 5d5c345 Put busy elements at the tail of the objhdr list, move them to the front when unbusy'ing. This should still keep the list roughly sorted in Date: order, but keep the busy objects out of the way for lookups.
Poul-Henning Kamp
phk at varnish-cache.org
Fri Apr 29 11:38:44 CEST 2011
commit 5d5c3453a97ae9743dec9c8d15b60978b7c9d3e4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Apr 29 09:37:22 2011 +0000
Put busy elements at the tail of the objhdr list, move them to the
front when unbusy'ing. This should still keep the list roughly sorted in
Date: order, but keep the busy objects out of the way for lookups.
diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c
index 249e1a7..bb18642 100644
--- a/bin/varnishd/cache_hash.c
+++ b/bin/varnishd/cache_hash.c
@@ -281,8 +281,7 @@ HSH_Insert(const struct sess *sp)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AZ(oc->flags & OC_F_BUSY);
- /* XXX: Should this not be ..._HEAD now ? */
- VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
+ VTAILQ_INSERT_HEAD(&oh->objcs, oc, list);
/* NB: do not deref objhead the new object inherits our reference */
oc->objhead = oh;
Lck_Unlock(&oh->mtx);
@@ -446,7 +445,11 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
AN(oc->flags & OC_F_BUSY);
oc->refcnt = 1;
- VTAILQ_INSERT_HEAD(&oh->objcs, oc, list);
+ /*
+ * Busy objects go on the tail, so they will not trip up searches.
+ * HSH_Unbusy() will move them to the front.
+ */
+ VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
oc->objhead = oh;
/* NB: do not deref objhead the new object inherits our reference */
Lck_Unlock(&oh->mtx);
@@ -600,8 +603,12 @@ HSH_Unbusy(const struct sess *sp)
WSP(sp, SLT_Debug,
"Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
+ /* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
Lck_Lock(&oh->mtx);
assert(oh->refcnt > 0);
+ /* XXX: strictly speaking, we should sort in Date: order. */
+ VTAILQ_REMOVE(&oh->objcs, oc, list);
+ VTAILQ_INSERT_HEAD(&oh->objcs, oc, list);
oc->flags &= ~OC_F_BUSY;
hsh_rush(oh);
AN(oc->ban);
More information about the varnish-commit
mailing list