From: Wouter Wijngaards Date: Thu, 7 Jan 2010 16:06:26 +0000 (+0000) Subject: Stats for prefetch. unbound_munin_ plugin updated. X-Git-Tag: release-1.4.2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1314b95ce73d3658912e48e864511811d385d3d8;p=thirdparty%2Funbound.git Stats for prefetch. unbound_munin_ plugin updated. git-svn-id: file:///svn/unbound/trunk@1952 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/contrib/unbound_munin_ b/contrib/unbound_munin_ index d38d5b7be..7da83c992 100755 --- a/contrib/unbound_munin_ +++ b/contrib/unbound_munin_ @@ -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 diff --git a/daemon/remote.c b/daemon/remote.c index cd0c4a429..b77e4198b 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -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, diff --git a/daemon/stats.c b/daemon/stats.c index 2e0ebcd88..b9474c744 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -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) diff --git a/daemon/stats.h b/daemon/stats.h index 1074e0b32..fa526d618 100644 --- a/daemon/stats.h +++ b/daemon/stats.h @@ -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); diff --git a/daemon/worker.c b/daemon/worker.c index 58515dff8..7b2d62163 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -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 diff --git a/doc/Changelog b/doc/Changelog index a2f373da2..f4e6e662e 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in index ad402c40d..e3c0e0138 100644 --- a/doc/unbound-control.8.in +++ b/doc/unbound-control.8.in @@ -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