]> err.no Git - varnish/commitdiff
More statistics about worker threads.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 10 Jul 2006 15:02:06 +0000 (15:02 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 10 Jul 2006 15:02:06 +0000 (15:02 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@410 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/include/stat_field.h

index 07a41a25c6e25444154e1878002c700d6e1b6f2f..4971db652c75dae158aab70891785eaf42dbd318 100644 (file)
@@ -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));
        }
index f3a81ef97281ef1f29dbe5d71fd375235036d4a7..d9e69e36065dbe50aece131885a75f8b83f2d8ac 100644 (file)
@@ -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");