Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

varnishd: add lock duration #3977

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bin/varnishd/cache/cache_lck.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct ilck {
pthread_t owner;
const char *w;
struct VSC_lck *stat;
vtim_dur taken_us;
};

/*--------------------------------------------------------------------*/
Expand Down Expand Up @@ -127,6 +128,7 @@ Lck__Lock(struct lock *lck, const char *p, int l)
ilck->stat->dbg_busy++;
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->taken_us = 1e6L * VTIM_mono();
ilck->held = 1;
}

Expand All @@ -141,6 +143,7 @@ Lck__Unlock(struct lock *lck, const char *p, int l)
AN(lck);
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
assert(pthread_equal(ilck->owner, pthread_self()));
ilck->stat->dur_us += 1e6L * VTIM_mono() - ilck->taken_us;
AN(ilck->held);
ilck->held = 0;
/*
Expand Down Expand Up @@ -180,6 +183,7 @@ Lck__Trylock(struct lock *lck, const char *p, int l)
ilck->held = 1;
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->taken_us = 1e6L * VTIM_mono();
} else if (DO_DEBUG(DBG_LCK))
ilck->stat->dbg_try_fail++;
return (r);
Expand Down Expand Up @@ -234,6 +238,7 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when)
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
AN(ilck->held);
assert(pthread_equal(ilck->owner, pthread_self()));
ilck->stat->dur_us += 1e6L * VTIM_mono() - ilck->taken_us;
ilck->held = 0;
if (when == 0) {
errno = pthread_cond_wait(cond, &ilck->mtx);
Expand Down Expand Up @@ -278,6 +283,7 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when)
AZ(ilck->held);
ilck->held = 1;
ilck->owner = pthread_self();
ilck->taken_us = 1e6L * VTIM_mono();
return (errno);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/libvsc/VSC_lck.vsc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
:level: debug
:oneliner: Lock Operations

.. varnish_vsc:: dur_us
:type: counter
:level: debug
:oneliner: Lock duration

.. varnish_vsc:: dbg_busy
:type: counter
Expand Down