[master] bc421898d Optimize ban lurker and dying objects
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Mon May 6 11:12:08 UTC 2019
commit bc421898d3bfc37b4ef162638171ac544a1db171
Author: Pål Hermunn Johansen <hermunn at varnish-software.com>
Date: Mon May 6 11:22:57 2019 +0200
Optimize ban lurker and dying objects
When an object is dying, we would rather not have the ban
lurker evalueate it against any existing bans. Now it will,
when a dying object is found, simply remove the oc off the
ban list completely. This is very cheap since we are already
holding the oh and ban mutexes.
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 0bfca2d04..16e9351d7 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -266,6 +266,8 @@ BAN_DestroyObj(struct objcore *oc)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ if (oc->ban == NULL)
+ return;
Lck_Lock(&ban_mtx);
CHECK_OBJ_ORNULL(oc->ban, BAN_MAGIC);
if (oc->ban != NULL) {
diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 053324d10..55a6b6402 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -167,8 +167,23 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt)
oh = oc->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
if (!Lck_Trylock(&oh->mtx)) {
- if (oc->refcnt == 0 || oc->flags & OC_F_BUSY) {
+ if (oc->flags & OC_F_BUSY) {
Lck_Unlock(&oh->mtx);
+ } else if (oc->refcnt == 0 ||
+ oc->flags & (OC_F_DYING | OC_F_FAILED)) {
+ /*
+ * We seize the opportunity to remove
+ * the object completely off the ban
+ * list, now that we have both the oh
+ * and ban mutexes.
+ */
+ noc = VTAILQ_NEXT(oc, ban_list);
+ VTAILQ_REMOVE(&bt->objcore, oc, ban_list);
+ oc->ban = NULL;
+ bt->refcount--;
+ Lck_Unlock(&oh->mtx);
+ oc = noc;
+ continue;
} else {
/*
* We got the lock, and the oc is not being
More information about the varnish-commit
mailing list