Mailing List Archive

r2509 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2008-02-18 12:47:55 +0100 (Mon, 18 Feb 2008)
New Revision: 2509

Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
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.




Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-02-18 11:45:58 UTC (rev 2508)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-02-18 11:47:55 UTC (rev 2509)
@@ -868,6 +868,21 @@
*
*/

+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 @@
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); \
+ if (params->diag_bitmap & 0x01) \
+ cnt_diag(sp, #u); \
done = cnt_##l(sp); \
- break;
-#else
-#define STEP(l,u) \
- case STP_##u: \
- done = cnt_##l(sp); \
break;
-#endif
#include "steps.h"
#undef STEP
default: INCOMPL();