]> err.no Git - varnish/commitdiff
Add more stats
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Jul 2006 13:13:56 +0000 (13:13 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Jul 2006 13:13:56 +0000 (13:13 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@328 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_backend.c
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/storage_file.c
varnish-cache/include/stat_field.h

index c0750ed80dc89f1e7376b295e07f36c48a419f1b..22d7c49be731cb61d8c7be17ea3b0c4c7731811d 100644 (file)
@@ -154,6 +154,7 @@ accept_f(int fd, short event, void *arg)
                                 * XXX: this is probably one we should handle
                                 * XXX: accept, emit error NNN and close
                                 */
+       VSL_stats->n_sess++;
 
        sp = &sm->s;
        sp->rd_e = &sm->e;
@@ -242,6 +243,7 @@ vca_return_session(struct sess *sp)
        } else {
                if (sp->http != NULL)
                        http_Delete(sp->http);
+               VSL_stats->n_sess--;
                free(sp->mem);
        }
 }
index b7868c0bbfa1b5a839997dc635022bfa293e758a..ed57620ed2d667673c0235749535fb44facd0498 100644 (file)
@@ -90,10 +90,13 @@ connect_to_backend(struct vbe_conn *vc, struct backend *bp)
        memset(&hint, 0, sizeof hint);
        hint.ai_family = PF_UNSPEC;
        hint.ai_socktype = SOCK_STREAM;
+       res = NULL;
        error = getaddrinfo(bp->hostname,
            bp->portname == NULL ? "http" : bp->portname,
            &hint, &res);
        if (error) {
+               if (res != NULL)
+                       freeaddrinfo(res);
                fprintf(stderr, "getaddrinfo: %s\n", 
                    gai_strerror(error));
                return;
@@ -138,6 +141,7 @@ vbe_rdp(int fd, short event __unused, void *arg __unused)
        if (vc->fd < 0) {
                vc->vbe->nconn--;
                free(vc);
+               VSL_stats->n_vbe_conn--;
        } else {
                vc->inuse = 0;
                event_add(&vc->ev, NULL);
@@ -172,6 +176,7 @@ vbe_rdf(int fd, short event __unused, void *arg)
        event_del(&vc->ev);
        close(vc->fd);
        free(vc);
+       VSL_stats->n_vbe_conn--;
 }
 
 /* Backend monitoring thread -----------------------------------------*/
@@ -220,6 +225,7 @@ VBE_GetFd(struct backend *bp, void **ptr, unsigned xid)
        if (vp == NULL) {
                vp = calloc(sizeof *vp, 1);
                assert(vp != NULL);
+               VSL_stats->n_vbe++;
                TAILQ_INIT(&vp->fconn);
                TAILQ_INIT(&vp->bconn);
                vp->ip = bp->ip;
@@ -235,6 +241,7 @@ VBE_GetFd(struct backend *bp, void **ptr, unsigned xid)
                AZ(pthread_mutex_unlock(&vbemtx));
        } else {
                vc = calloc(sizeof *vc, 1);
+               VSL_stats->n_vbe_conn++;
                assert(vc != NULL);
                vc->vbe = vp;
                vc->fd = -1;
index 6c9f5e1987208a8cdfa3663dc2e361cb34abad58..685b7483e089462759f653309d20104275a42fcc 100644 (file)
@@ -287,6 +287,7 @@ FetchSession(struct worker *w, struct sess *sp)
                cls = 0;
        sbuf_finish(w->sb);
        sp->obj->header = strdup(sbuf_data(w->sb));
+       VSL_stats->n_header++;
 
        vca_write_obj(w, sp);
 
index e2785cfb7554fa0446c0cb9818a0503076c80798..df193be4d32ea21e4d80e4c0aa30b68f9959f007 100644 (file)
@@ -33,6 +33,7 @@ HSH_Lookup(struct worker *w, struct http *h)
                assert(w->nobjhead != NULL);
                TAILQ_INIT(&w->nobjhead->objects);
                AZ(pthread_mutex_init(&w->nobjhead->mtx, NULL));
+               VSL_stats->n_objecthead++;
        }
        if (w->nobj == NULL) {
                w->nobj = calloc(sizeof *w->nobj, 1);
@@ -40,6 +41,7 @@ HSH_Lookup(struct worker *w, struct http *h)
                w->nobj->busy = 1;
                TAILQ_INIT(&w->nobj->store);
                AZ(pthread_cond_init(&w->nobj->cv, NULL));
+               VSL_stats->n_object++;
        }
 
        assert(http_GetURL(h, &b));
@@ -110,7 +112,10 @@ HSH_Deref(struct object *o)
        if (o == NULL)
                return;
 
-       free(o->header);
+       if (o->header != NULL) {
+               free(o->header);
+               VSL_stats->n_header--;
+       }
        AZ(pthread_cond_destroy(&o->cv));
 
        TAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
@@ -118,12 +123,14 @@ HSH_Deref(struct object *o)
                st->stevedore->free(st);
        }
        free(o);
+       VSL_stats->n_object--;
 
        /* Drop our ref on the objhead */
        if (hash->deref(oh))
                return;
        assert(TAILQ_EMPTY(&oh->objects));
        AZ(pthread_mutex_destroy(&oh->mtx));
+       VSL_stats->n_objecthead--;
        free(oh);
 }
 
index 914fa47276301a4f318f060d0a1e9bd01ba04349..7ff5a8c36308740beeb8dd3eaa123fb5455fdda0 100644 (file)
@@ -53,6 +53,7 @@ http_New(void)
 
        hp = calloc(sizeof *hp, 1);
        assert(hp != NULL);
+       VSL_stats->n_http++;
 
        hp->s = malloc(http_bufsize);
        assert(hp->s != NULL);
@@ -74,6 +75,7 @@ http_Delete(struct http *hp)
        free(hp->hdr);
        free(hp->s);
        free(hp);
+       VSL_stats->n_http--;
 }
 
 /*--------------------------------------------------------------------*/
@@ -369,10 +371,12 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
        unsigned l;
 
        assert(hp != NULL);
+       VSL(SLT_Debug, fd, "Recv t %u v %u", hp->t - hp->s, hp->v - hp->s);
        if (hp->t > hp->s && hp->t < hp->v) {
                l = hp->v - hp->t;
                memmove(hp->s, hp->t, l);
                hp->v = hp->s + l;
+               hp->t = hp->s;
                if (http_header_complete(hp)) {
                        func(arg, 1);
                        return;
index 90c276e73ea46ed9c66028574cf0ecbd6656a4b4..6bd9ba9acc6e12dcf8e069f49ac31a15cb3378f3 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/socket.h>
 
 #include "libvarnish.h"
+#include "shmlog.h"
 #include "cache.h"
 
 #define MINPAGES               128
@@ -284,6 +285,7 @@ alloc_smf(struct smf_sc *sc, size_t bytes)
        /* Split from front */
        sp2 = malloc(sizeof *sp2);
        assert(sp2 != NULL);
+       VSL_stats->n_smf++;
        *sp2 = *sp;
 
        sp->offset += bytes;
@@ -320,6 +322,7 @@ free_smf(struct smf *sp)
                TAILQ_REMOVE(&sc->order, sp2, order);
                TAILQ_REMOVE(&sc->free, sp2, status);
                free(sp2);
+               VSL_stats->n_smf--;
        }
 
        sp2 = TAILQ_PREV(sp, smfhead, order);
@@ -331,6 +334,7 @@ free_smf(struct smf *sp)
                sp2->age = sp->age;
                TAILQ_REMOVE(&sc->order, sp, order);
                free(sp);
+               VSL_stats->n_smf--;
                TAILQ_REMOVE(&sc->free, sp2, status);
                sp = sp2;
        }
@@ -359,6 +363,7 @@ trim_smf(struct smf *sp, size_t bytes)
        assert(bytes > 0);
        sp2 = malloc(sizeof *sp2);
        assert(sp2 != NULL);
+       VSL_stats->n_smf++;
        *sp2 = *sp;
 
        sp2->size -= bytes;
@@ -381,6 +386,7 @@ new_smf(struct smf_sc *sc, unsigned char *ptr, off_t off, size_t len)
 
        sp = calloc(sizeof *sp, 1);
        assert(sp != NULL);
+       VSL_stats->n_smf++;
 
        sp->sc = sc;
 
index 74948271ea8afa54634171579a02d481fe2f8ffc..87f39b8d4b9147f56e820b7b219a894f06ff9e2c 100644 (file)
@@ -9,3 +9,13 @@ MAC_STAT(cache_miss,           uint64_t, "u", "Cache misses")
 MAC_STAT(backend_conn,         uint64_t, "u", "Backend connections initiated")
 MAC_STAT(backend_recycle,      uint64_t, "u", "Backend connections recyles")
 
+MAC_STAT(n_sess,               uint64_t, "u", "N struct sess");
+MAC_STAT(n_object,             uint64_t, "u", "N struct object");
+MAC_STAT(n_objecthead,         uint64_t, "u", "N struct objecthead");
+MAC_STAT(n_header,             uint64_t, "u", "N struct header");
+MAC_STAT(n_smf,                        uint64_t, "u", "N struct smf");
+MAC_STAT(n_http,               uint64_t, "u", "N struct http");
+MAC_STAT(n_vbe,                        uint64_t, "u", "N struct vbe");
+MAC_STAT(n_vbe_conn,           uint64_t, "u", "N struct vbe_conn");
+
+