Skip to content

Commit

Permalink
expire: New MAIN.n_superseded counter
Browse files Browse the repository at this point in the history
  • Loading branch information
dridi committed Mar 1, 2024
1 parent e8264aa commit 241be56
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion bin/varnishd/cache/cache_expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ EXP_RefNewObjcore(struct objcore *oc)
*/

void
EXP_Remove(struct objcore *oc)
EXP_Remove(struct objcore *oc, const struct objcore *new_oc)
{

CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_ORNULL(new_oc, OBJCORE_MAGIC);

if (oc->exp_flags & OC_EF_REFD) {
Lck_Lock(&exphdl->mtx);
if (new_oc != NULL)
VSC_C_main->n_superseded++;
if (oc->exp_flags & OC_EF_NEW) {
/* EXP_Insert has not been called for this object
* yet. Mark it for removal, and EXP_Insert will
Expand Down
8 changes: 4 additions & 4 deletions bin/varnishd/cache/cache_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)

if (BAN_CheckObject(wrk, oc, req)) {
oc->flags |= OC_F_DYING;
EXP_Remove(oc);
EXP_Remove(oc, NULL);
continue;
}

Expand Down Expand Up @@ -743,7 +743,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
for (i = 0; i < j; i++) {
CHECK_OBJ_NOTNULL(ocp[i], OBJCORE_MAGIC);
if (is_purge)
EXP_Remove(ocp[i]);
EXP_Remove(ocp[i], NULL);
else
EXP_Rearm(ocp[i], ttl_now, ttl, grace, keep);
(void)HSH_DerefObjCore(wrk, &ocp[i], 0);
Expand Down Expand Up @@ -919,7 +919,7 @@ HSH_Kill(struct objcore *oc)
Lck_Lock(&oc->objhead->mtx);
oc->flags |= OC_F_DYING;
Lck_Unlock(&oc->objhead->mtx);
EXP_Remove(oc);
EXP_Remove(oc, NULL);
}

/*====================================================================
Expand All @@ -946,7 +946,7 @@ HSH_Snipe(const struct worker *wrk, struct objcore *oc)
Lck_Unlock(&oc->objhead->mtx);
}
if (retval)
EXP_Remove(oc);
EXP_Remove(oc, NULL);
return (retval);
}

Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_varnishd.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ vtim_real EXP_Ttl(const struct req *, const struct objcore *);
vtim_real EXP_Ttl_grace(const struct req *, const struct objcore *oc);
void EXP_RefNewObjcore(struct objcore *);
void EXP_Insert(struct worker *wrk, struct objcore *oc);
void EXP_Remove(struct objcore *);
void EXP_Remove(struct objcore *, const struct objcore *);

#define EXP_Dttl(req, oc) (oc->ttl - (req->t_req - oc->t_origin))

Expand Down
6 changes: 6 additions & 0 deletions lib/libvsc/VSC_main.vsc
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@

Number of objects that expired from cache because of old age.

.. varnish_vsc:: n_superseded
:level: diag
:oneliner: Number of superseded objects

Number of times an object was superseded by a new one.

.. varnish_vsc:: n_lru_nuked
:oneliner: Number of LRU nuked objects

Expand Down

0 comments on commit 241be56

Please sign in to comment.