]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Stats for prefetch. unbound_munin_ plugin updated.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 7 Jan 2010 16:06:26 +0000 (16:06 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 7 Jan 2010 16:06:26 +0000 (16:06 +0000)
git-svn-id: file:///svn/unbound/trunk@1952 be551aaa-1e26-0410-a405-d3ace91eadb9

contrib/unbound_munin_
daemon/remote.c
daemon/stats.c
daemon/stats.h
daemon/worker.c
doc/Changelog
doc/unbound-control.8.in

index d38d5b7be56120738f6c249a97766a68b5348ce7..7da83c9929fa61d3f8bb726b7c3b19225007bed3 100755 (executable)
@@ -235,6 +235,7 @@ if test "$1" = "config" ; then
                done
                p_config "total.num.queries" "total queries from clients"
                p_config "total.num.cachehits" "cache hits"
+               p_config "total.num.prefetch" "cache prefetch"
                p_config "num.query.tcp" "TCP queries"
                p_config "num.query.ipv6" "IPv6 queries"
                p_config "unwanted.queries" "queries that failed acl"
@@ -423,8 +424,8 @@ hits)
        for x in thread0.num.queries thread1.num.queries thread2.num.queries \
                thread3.num.queries thread4.num.queries thread5.num.queries \
                thread6.num.queries thread7.num.queries total.num.queries \
-               total.num.cachehits num.query.tcp num.query.ipv6 \
-               unwanted.queries unwanted.replies; do
+               total.num.cachehits total.num.prefetch num.query.tcp \
+               num.query.ipv6 unwanted.queries unwanted.replies; do
                if grep "^"$x"=" $state >/dev/null 2>&1; then
                        print_qps $x
                fi
index cd0c4a429c9d70e125fb73d911b44399e9ece74f..b77e4198b6a14a7ef41ed9f3871144d21c95fac7 100644 (file)
@@ -599,12 +599,15 @@ print_stats(SSL* ssl, const char* nm, struct stats_info* s)
                        - s->svr.num_queries_missed_cache))) return 0;
        if(!ssl_printf(ssl, "%s.num.cachemiss"SQ"%u\n", nm, 
                (unsigned)s->svr.num_queries_missed_cache)) return 0;
+       if(!ssl_printf(ssl, "%s.num.prefetch"SQ"%u\n", nm, 
+               (unsigned)s->svr.num_queries_prefetch)) return 0;
        if(!ssl_printf(ssl, "%s.num.recursivereplies"SQ"%u\n", nm, 
                (unsigned)s->mesh_replies_sent)) return 0;
        if(!ssl_printf(ssl, "%s.requestlist.avg"SQ"%g\n", nm,
-               s->svr.num_queries_missed_cache?
+               (s->svr.num_queries_missed_cache+s->svr.num_queries_prefetch)?
                        (double)s->svr.sum_query_list_size/
-                       s->svr.num_queries_missed_cache : 0.0)) return 0;
+                       (s->svr.num_queries_missed_cache+
+                       s->svr.num_queries_prefetch) : 0.0)) return 0;
        if(!ssl_printf(ssl, "%s.requestlist.max"SQ"%u\n", nm,
                (unsigned)s->svr.max_query_list_size)) return 0;
        if(!ssl_printf(ssl, "%s.requestlist.overwritten"SQ"%u\n", nm,
index 2e0ebcd8826e2235d07bcc6708173ec59d72af24..b9474c7442910184ddb9ac559e37b3019b58d0ab 100644 (file)
@@ -79,20 +79,31 @@ void server_stats_querymiss(struct server_stats* stats, struct worker* worker)
                stats->max_query_list_size = worker->env.mesh->all.count;
 }
 
+void server_stats_prefetch(struct server_stats* stats, struct worker* worker)
+{
+       stats->num_queries_prefetch++;
+       /* changes the query list size so account that, like a querymiss */
+       stats->sum_query_list_size += worker->env.mesh->all.count;
+       if(worker->env.mesh->all.count > stats->max_query_list_size)
+               stats->max_query_list_size = worker->env.mesh->all.count;
+}
+
 void server_stats_log(struct server_stats* stats, struct worker* worker,
        int threadnum)
 {
        log_info("server stats for thread %d: %u queries, "
-               "%u answers from cache, %u recursions", 
+               "%u answers from cache, %u recursions, %u prefetch", 
                threadnum, (unsigned)stats->num_queries, 
                (unsigned)(stats->num_queries - 
                        stats->num_queries_missed_cache),
-               (unsigned)stats->num_queries_missed_cache);
+               (unsigned)stats->num_queries_missed_cache,
+               (unsigned)stats->num_queries_prefetch);
        log_info("server stats for thread %d: requestlist max %u avg %g "
                "exceeded %u", threadnum, (unsigned)stats->max_query_list_size,
-               stats->num_queries_missed_cache?
+               (stats->num_queries_missed_cache+stats->num_queries_prefetch)?
                        (double)stats->sum_query_list_size/
-                       stats->num_queries_missed_cache : 0.0,
+                       (stats->num_queries_missed_cache+
+                       stats->num_queries_prefetch) : 0.0,
                (unsigned)worker->env.mesh->stats_dropped);
 }
 
@@ -187,6 +198,7 @@ void server_stats_add(struct stats_info* total, struct stats_info* a)
 {
        total->svr.num_queries += a->svr.num_queries;
        total->svr.num_queries_missed_cache += a->svr.num_queries_missed_cache;
+       total->svr.num_queries_prefetch += a->svr.num_queries_prefetch;
        total->svr.sum_query_list_size += a->svr.sum_query_list_size;
        /* the max size reached is upped to higher of both */
        if(a->svr.max_query_list_size > total->svr.max_query_list_size)
index 1074e0b3281e1e1b26ea72fcf852abc71bf711c8..fa526d6180d6e5a87700b165356744050853c417 100644 (file)
@@ -64,6 +64,8 @@ struct server_stats {
        size_t num_queries;
        /** number of queries that had a cache-miss. */
        size_t num_queries_missed_cache;
+       /** number of prefetch queries - cachehits with prefetch */
+       size_t num_queries_prefetch;
 
        /**
         * Sum of the querylistsize of the worker for 
@@ -166,6 +168,9 @@ void server_stats_init(struct server_stats* stats, struct config_file* cfg);
 /** add query if it missed the cache */
 void server_stats_querymiss(struct server_stats* stats, struct worker* worker);
 
+/** add query if was cached and also resulted in a prefetch */
+void server_stats_prefetch(struct server_stats* stats, struct worker* worker);
+
 /** display the stats to the log */
 void server_stats_log(struct server_stats* stats, struct worker* worker,
        int threadnum);
index 58515dff804adc3925780fc0e632c28808d6486c..7b2d6216332eaa46daf8a85a966b30b43d6b8603 100644 (file)
@@ -597,8 +597,7 @@ reply_and_prefetch(struct worker* worker, struct query_info* qinfo,
        /* first send answer to client to keep its latency 
         * as small as a cachereply */
        comm_point_send_reply(repinfo);
-       /* account the prefetch (used to be part of the cache-reply count) */
-       /* TODO */
+       server_stats_prefetch(&worker->stats, worker);
        
        /* create the prefetch in the mesh as a normal lookup without
         * client addrs waiting, which has the cache blacklisted (to bypass
index a2f373da266c1819e8b11c074d2f6ace3eb64dc0..f4e6e662e42d94af995216e02f74bacd46b6fe94 100644 (file)
@@ -1,6 +1,8 @@
 7 January 2010: Wouter
        - Fixup python documentation (thanks Leo Vandewoestijne).
        - Work on cache prefetch feature.
+       - Stats for prefetch, in log print stats, unbound-control stats
+         and in unbound_munin plugin.
 
 6 January 2010: Wouter
        - iana portlist updated.
index ad402c40deb4d5332d2b3c39e4ab6d80782b1437..e3c0e0138f9ffea029f16f415fd95eccd347b24d 100644 (file)
@@ -186,6 +186,13 @@ number of queries that were successfully answered using a cache lookup
 .I threadX.num.cachemiss
 number of queries that needed recursive processing
 .TP
+.I threadX.num.prefetch
+number of cache prefetches performed.  This number is included in
+cachehits, as the original query had the unprefetched answer from cache,
+and resulted in recursive processing, taking a slot in the requestlist.
+Not part of the recursivereplies (or the histogram thereof) or cachemiss,
+as a cache response was sent.
+.TP
 .I threadX.num.recursivereplies
 The number of replies sent to queries that needed recursive processing. Could be smaller than threadX.num.cachemiss if due to timeouts no replies were sent for some queries.
 .TP
@@ -227,6 +234,9 @@ summed over threads.
 .I total.num.cachemiss
 summed over threads.
 .TP
+.I total.num.prefetch
+summed over threads.
+.TP
 .I total.num.recursivereplies
 summed over threads.
 .TP