From 1d0f362f4f7ff48700bf8948b8560babff907cfd Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 18 Feb 2008 11:47:55 +0000 Subject: [PATCH] Move the logging of state engine states to use the diag_bitmap instead of #ifdef DIAGNOSTICS for control. Also reduce VSL mutex cost by 50% for the common case where we have a worker thread: We did a WSL_Flush() followed by a VSL(), doing a WSL() before the WSL_FLush saves one VSL mutex op. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2509 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_center.c | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 94b52f1a..a89e10d0 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -868,6 +868,21 @@ cnt_start(struct sess *sp) * */ +static void +cnt_diag(struct sess *sp, const char *state) +{ + if (sp->wrk != NULL) { + WSL(sp->wrk, SLT_Debug, sp->id, + "thr %p STP_%s sp %p obj %p vcl %p", + pthread_self(), state, sp, sp->obj, sp->vcl); + WSL_Flush(sp->wrk); + } else { + VSL(SLT_Debug, sp->id, + "thr %p STP_%s sp %p obj %p vcl %p", + pthread_self(), state, sp, sp->obj, sp->vcl); + } +} + void CNT_Session(struct sess *sp) { @@ -892,22 +907,12 @@ CNT_Session(struct sess *sp) CHECK_OBJ_ORNULL(sp->director, DIRECTOR_MAGIC); switch (sp->step) { -#ifdef DIAGNOSTICS -#define STEP(l,u) \ - case STP_##u: \ - if (sp->wrk) \ - WSL_Flush(sp->wrk); \ - VSL(SLT_Debug, sp->id, \ - "thr %p STP_%s sp %p obj %p vcl %p", \ - pthread_self(), #u, sp, sp->obj, sp->vcl); \ - done = cnt_##l(sp); \ - break; -#else #define STEP(l,u) \ case STP_##u: \ + if (params->diag_bitmap & 0x01) \ + cnt_diag(sp, #u); \ done = cnt_##l(sp); \ break; -#endif #include "steps.h" #undef STEP default: INCOMPL(); -- 2.39.5