r1051 - in trunk/varnish-cache: bin/varnishd include

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 17 21:30:31 CEST 2006


Author: phk
Date: 2006-09-17 21:30:31 +0200 (Sun, 17 Sep 2006)
New Revision: 1051

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/shmlog.c
   trunk/varnish-cache/include/Makefile.am
   trunk/varnish-cache/include/stat_field.h
Log:
Keep track of shmlog mutex contests


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-09-17 18:31:31 UTC (rev 1050)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-09-17 19:30:31 UTC (rev 1051)
@@ -422,9 +422,6 @@
 /* rfc2616.c */
 int RFC2616_cache_policy(struct sess *sp, struct http *hp);
 
-#define LOCKSHM(foo)	AZ(pthread_mutex_lock(foo))
-#define UNLOCKSHM(foo)	AZ(pthread_mutex_unlock(foo))
-
 #if 1
 #define MTX			pthread_mutex_t
 #define MTX_INIT(foo)		AZ(pthread_mutex_init(foo, NULL))

Modified: trunk/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/shmlog.c	2006-09-17 18:31:31 UTC (rev 1050)
+++ trunk/varnish-cache/bin/varnishd/shmlog.c	2006-09-17 19:30:31 UTC (rev 1051)
@@ -16,6 +16,16 @@
 
 #include "heritage.h"
 
+#define LOCKSHM(foo)					\
+	do {						\
+		if (pthread_mutex_trylock(foo)) {	\
+			AZ(pthread_mutex_lock(foo));	\
+			VSL_stats->shm_cont++;		\
+		}					\
+	} while (0);
+		
+#define UNLOCKSHM(foo)	AZ(pthread_mutex_unlock(foo))
+
 #ifndef MAP_HASSEMAPHORE
 #define MAP_HASSEMAPHORE 0 /* XXX Linux */
 #endif

Modified: trunk/varnish-cache/include/Makefile.am
===================================================================
--- trunk/varnish-cache/include/Makefile.am	2006-09-17 18:31:31 UTC (rev 1050)
+++ trunk/varnish-cache/include/Makefile.am	2006-09-17 19:30:31 UTC (rev 1051)
@@ -24,7 +24,6 @@
 	shmlog_tags.h \
 	stat_field.h \
 	stats.h \
-	tree.h \
 	varnish/assert.h \
 	varnishapi.h \
 	vcl.h \

Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h	2006-09-17 18:31:31 UTC (rev 1050)
+++ trunk/varnish-cache/include/stat_field.h	2006-09-17 19:30:31 UTC (rev 1051)
@@ -48,3 +48,5 @@
 MAC_STAT(sess_pipeline,		uint64_t, "u", "Session Pipeline")
 MAC_STAT(sess_readahead,	uint64_t, "u", "Session Read Ahead")
 MAC_STAT(sess_herd,		uint64_t, "u", "Session herd")
+
+MAC_STAT(shm_cont,		uint64_t, "u", "SHM MTX contention")




More information about the varnish-commit mailing list