Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 6b0a8c8

Browse files
committed
hash: Skip the cache ceremony for private objects
This reduces a great deal of spurious activity on the private_oh waiting list and removes unncessary conditionals when dealing with cacheable (or at least searchable) objects. There is still some waiting list no-op activity via HSH_Fail() but it can be considered negligible compared to the happy path.
1 parent d11bb69 commit 6b0a8c8

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

bin/varnishd/cache/cache_hash.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -918,27 +918,36 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)
918918
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
919919
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
920920
CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
921+
AN(oc->flags & OC_F_BUSY);
921922

922923
oh = oc->objhead;
923924
CHECK_OBJ(oh, OBJHEAD_MAGIC);
925+
926+
/* NB: It is guaranteed that exactly one request is waiting for
927+
* the objcore for pass objects. The other reference is held by
928+
* the current fetch task.
929+
*/
930+
if (oc->flags & OC_F_PRIVATE) {
931+
assert(oc->refcnt == 2);
932+
oc->flags &= ~OC_F_BUSY;
933+
return;
934+
}
935+
924936
INIT_OBJ(&rush, RUSH_MAGIC);
925937

926938
AN(oc->stobj->stevedore);
927-
AN(oc->flags & OC_F_BUSY);
939+
AZ(oc->flags & OC_F_PRIVATE);
928940
assert(oh->refcnt > 0);
929941
assert(oc->refcnt > 0);
930942

931-
if (!(oc->flags & OC_F_PRIVATE)) {
932-
BAN_NewObjCore(oc);
933-
AN(oc->ban);
934-
}
943+
BAN_NewObjCore(oc);
944+
AN(oc->ban);
935945

936946
/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
937947
Lck_Lock(&oh->mtx);
938948
assert(oh->refcnt > 0);
939949
assert(oc->refcnt > 0);
940-
if (!(oc->flags & OC_F_PRIVATE))
941-
EXP_RefNewObjcore(oc); /* Takes a ref for expiry */
950+
EXP_RefNewObjcore(oc); /* Takes a ref for expiry */
942951
/* XXX: strictly speaking, we should sort in Date: order. */
943952
VTAILQ_REMOVE(&oh->objcs, oc, hsh_list);
944953
VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list);
@@ -948,8 +957,7 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)
948957
hsh_rush1(wrk, oc, &rush);
949958
}
950959
Lck_Unlock(&oh->mtx);
951-
EXP_Insert(wrk, oc); /* Does nothing unless EXP_RefNewObjcore was
952-
* called */
960+
EXP_Insert(wrk, oc);
953961
hsh_rush2(wrk, &rush);
954962
}
955963

0 commit comments

Comments
 (0)