From: phk Date: Mon, 10 Jul 2006 15:02:06 +0000 (+0000) Subject: More statistics about worker threads. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d2dce6fcce9de18e2a465cbeec76b2d7d11f80a;p=varnish More statistics about worker threads. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@410 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 07a41a25..4971db65 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -138,24 +138,25 @@ wrk_thread(void *priv) 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 @@ WRK_QueueSession(struct sess *sp) /* 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 @@ WRK_QueueSession(struct sess *sp) /* 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 @@ WRK_Init(void) 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)); } diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index f3a81ef9..d9e69e36 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -17,6 +17,7 @@ MAC_STAT(n_smf, uint64_t, "u", "N struct smf"); 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");