Commit a187a0ad authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Elimiante diag_bitmaps and the mutex-profiling/measuring code.

XXX: doc-change needed.
parent 13c8fedd
......@@ -37,7 +37,6 @@
#include <stdlib.h>
#include "vtim.h"
#include "cache.h"
/*The constability of lck depends on platform pthreads implementation */
......@@ -48,7 +47,6 @@ struct ilck {
pthread_mutex_t mtx;
int held;
pthread_t owner;
double t0;
VTAILQ_ENTRY(ilck) list;
const char *w;
struct VSC_C_lck *stat;
......@@ -63,37 +61,13 @@ void __match_proto__()
Lck__Lock(struct lock *lck, const char *p, const char *f, int l)
{
struct ilck *ilck;
int r;
double t0 = 0, t;
(void)p;
(void)f;
(void)l;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
if (!(cache_param->diag_bitmap & 0x98)) {
AZ(pthread_mutex_lock(&ilck->mtx));
AZ(ilck->held);
ilck->stat->locks++;
ilck->owner = pthread_self();
ilck->held = 1;
return;
}
if (cache_param->diag_bitmap & 0x80)
t0 = VTIM_real();
r = pthread_mutex_trylock(&ilck->mtx);
assert(r == 0 || r == EBUSY);
if (r) {
ilck->stat->colls++;
if (cache_param->diag_bitmap & 0x8)
VSL(SLT_Debug, 0, "MTX_CONTEST(%s,%s,%d,%s)",
p, f, l, ilck->w);
AZ(pthread_mutex_lock(&ilck->mtx));
} else if (cache_param->diag_bitmap & 0x8) {
VSL(SLT_Debug, 0, "MTX_LOCK(%s,%s,%d,%s)", p, f, l, ilck->w);
}
if (cache_param->diag_bitmap & 0x80) {
t = VTIM_real();
VSL(SLT_Debug, 0, "MTX_LOCKWAIT(%s,%s,%d,%s) %.9fs",
p, f, l, ilck->w, t - t0);
ilck->t0 = t;
}
AZ(pthread_mutex_lock(&ilck->mtx));
AZ(ilck->held);
ilck->stat->locks++;
ilck->owner = pthread_self();
......@@ -105,6 +79,10 @@ Lck__Unlock(struct lock *lck, const char *p, const char *f, int l)
{
struct ilck *ilck;
(void)p;
(void)f;
(void)l;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
assert(pthread_equal(ilck->owner, pthread_self()));
AN(ilck->held);
......@@ -121,11 +99,6 @@ Lck__Unlock(struct lock *lck, const char *p, const char *f, int l)
*/
memset(&ilck->owner, 0, sizeof ilck->owner);
AZ(pthread_mutex_unlock(&ilck->mtx));
if (cache_param->diag_bitmap & 0x80)
VSL(SLT_Debug, 0, "MTX_UNLOCK(%s,%s,%d,%s) %.9fs",
p, f, l, ilck->w, VTIM_real() - ilck->t0);
else if (cache_param->diag_bitmap & 0x8)
VSL(SLT_Debug, 0, "MTX_UNLOCK(%s,%s,%d,%s)", p, f, l, ilck->w);
}
int __match_proto__()
......@@ -134,19 +107,18 @@ Lck__Trylock(struct lock *lck, const char *p, const char *f, int l)
struct ilck *ilck;
int r;
(void)p;
(void)f;
(void)l;
CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
r = pthread_mutex_trylock(&ilck->mtx);
assert(r == 0 || r == EBUSY);
if (cache_param->diag_bitmap & 0x8)
VSL(SLT_Debug, 0,
"MTX_TRYLOCK(%s,%s,%d,%s) = %d", p, f, l, ilck->w, r);
if (r == 0) {
AZ(ilck->held);
ilck->held = 1;
ilck->stat->locks++;
ilck->owner = pthread_self();
if (cache_param->diag_bitmap & 0x80)
ilck->t0 = VTIM_real();
}
return (r);
}
......
......@@ -155,9 +155,6 @@ struct params {
/* CLI buffer size */
unsigned cli_buffer;
/* Control diagnostic code */
unsigned diag_bitmap;
/* Log local socket address to shm */
unsigned log_local_addr;
......
......@@ -578,22 +578,6 @@ tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg)
/*--------------------------------------------------------------------*/
static void
tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg)
{
unsigned u;
(void)par;
if (arg != NULL) {
u = strtoul(arg, NULL, 0);
mgt_param.diag_bitmap = u;
} else {
VCLI_Out(cli, "0x%x", mgt_param.diag_bitmap);
}
}
/*--------------------------------------------------------------------*/
static void
tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg)
{
......@@ -1044,19 +1028,6 @@ static const struct parspec input_parspec[] = {
"Select the waiter kernel interface.\n",
WIZARD | MUST_RESTART,
WAITER_DEFAULT, NULL },
{ "diag_bitmap", tweak_diag_bitmap, 0, 0, 0,
"Bitmap controlling diagnostics code:\n"
" 0x00000008 - mutex logging.\n"
" 0x00000010 - mutex contests.\n"
" 0x00000080 - mutex timing.\n"
"\n"
"Use 0x notation and do the bitor in your head :-)\n"
"\n"
"Note: Mutex timing will add extra overhead and "
"synchronization between threads, consequently changing the "
"locking characteristics.\n",
0,
"0", "bitmap" },
{ "ban_dups", tweak_bool, &mgt_param.ban_dups, 0, 0,
"Detect and eliminate duplicate bans.\n",
0,
......
......@@ -20,12 +20,6 @@ varnish v1 -clierr 105 "help 1 2 3"
varnish v1 -cliok "param.show"
varnish v1 -cliok "param.show diag_bitmap"
varnish v1 -cliok "param.set diag_bitmap 0x80"
varnish v1 -cliok "param.set diag_bitmap 0x0"
varnish v1 -start
varnish v1 -cliok "help"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment