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

phk at projects.linpro.no phk at projects.linpro.no
Mon Jul 10 17:02:06 CEST 2006


Author: phk
Date: 2006-07-10 17:02:06 +0200 (Mon, 10 Jul 2006)
New Revision: 410

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/include/stat_field.h
Log:
More statistics about worker threads.


Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-10 14:52:04 UTC (rev 409)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-10 15:02:06 UTC (rev 410)
@@ -138,24 +138,25 @@
 	assert(w->sb != NULL);
 	
 	AZ(pthread_mutex_lock(&wrk_mtx));
-	VSL_stats->n_wrk++;
 	w->nbr = VSL_stats->n_wrk;
-	if (priv == NULL)
+	if (priv == NULL) {
+		VSL_stats->n_wrk_create++;
 		VSL(SLT_WorkThread, 0, "%u born dynamic", w->nbr);
-	else
+	} else {
 		VSL(SLT_WorkThread, 0, "%u born permanent", w->nbr);
+	}
 	TAILQ_INSERT_HEAD(&wrk_head, w, list);
 	while (1) {
 		wrq = TAILQ_FIRST(&wrk_reqhead);
 		if (wrq != NULL) {
-			VSL_stats->n_wrkbusy++;
+			VSL_stats->n_wrk_busy++;
 			TAILQ_REMOVE(&wrk_head, w, list);
 			TAILQ_REMOVE(&wrk_reqhead, wrq, list);
 			AZ(pthread_mutex_unlock(&wrk_mtx));
 			assert(wrq->sess != NULL);
 			wrk_WorkSession(w, wrq->sess);
 			AZ(pthread_mutex_lock(&wrk_mtx));
-			VSL_stats->n_wrkbusy--;
+			VSL_stats->n_wrk_busy--;
 			TAILQ_INSERT_HEAD(&wrk_head, w, list);
 		}
 		if (wrk_overflow > 0) {
@@ -219,11 +220,13 @@
 	/* Register overflow if max threads reached */
 	if (VSL_stats->n_wrk >= heritage.wthread_max) {
 		wrk_overflow++;
+		VSL_stats->n_wrk_short++;
 		AZ(pthread_mutex_unlock(&wrk_mtx));
 		return;
 	}
 
 	/* Try to create a thread */
+	VSL_stats->n_wrk++;
 	AZ(pthread_mutex_unlock(&wrk_mtx));
 	if (!pthread_create(&tp, NULL, wrk_thread, NULL)) {
 		AZ(pthread_detach(tp));
@@ -235,7 +238,10 @@
 
 	/* Register overflow */
 	AZ(pthread_mutex_lock(&wrk_mtx));
+	VSL_stats->n_wrk--;
 	wrk_overflow++;
+	VSL_stats->n_wrk_failed++;
+	VSL_stats->n_wrk_short++;
 	AZ(pthread_mutex_unlock(&wrk_mtx));
 }
 	
@@ -252,6 +258,7 @@
 
 	VSL(SLT_Debug, 0, "Starting %u worker threads", heritage.wthread_min);
 	for (i = 0; i < heritage.wthread_min; i++) {
+		VSL_stats->n_wrk++;
 		AZ(pthread_create(&tp, NULL, wrk_thread, &i));
 		AZ(pthread_detach(tp));
 	}

Modified: trunk/varnish-cache/include/stat_field.h
===================================================================
--- trunk/varnish-cache/include/stat_field.h	2006-07-10 14:52:04 UTC (rev 409)
+++ trunk/varnish-cache/include/stat_field.h	2006-07-10 15:02:06 UTC (rev 410)
@@ -17,6 +17,7 @@
 MAC_STAT(n_vbe,			uint64_t, "u", "N struct vbe");
 MAC_STAT(n_vbe_conn,		uint64_t, "u", "N struct vbe_conn");
 MAC_STAT(n_wrk,			uint64_t, "u", "N worker threads");
-MAC_STAT(n_wrkbusy,		uint64_t, "u", "N busy worker threads");
-
-
+MAC_STAT(n_wrk_create,		uint64_t, "u", "N worker threads created");
+MAC_STAT(n_wrk_failed,		uint64_t, "u", "N worker threads not created");
+MAC_STAT(n_wrk_short,		uint64_t, "u", "N worker threads shortages");
+MAC_STAT(n_wrk_busy,		uint64_t, "u", "N busy worker threads");




More information about the varnish-commit mailing list