mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
some basic stats.
git-svn-id: file:///svn/unbound/trunk@271 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
756cb86964
commit
7132e54ffa
6 changed files with 158 additions and 1 deletions
|
|
@ -57,7 +57,7 @@ UNITTEST_SRC=$(wildcard testcode/unit*.c) testcode/readhex.c $(COMMON_SRC)
|
||||||
UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o)) $(COMPAT_OBJ)
|
UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o)) $(COMPAT_OBJ)
|
||||||
DAEMON_SRC=$(wildcard daemon/*.c) $(COMMON_SRC)
|
DAEMON_SRC=$(wildcard daemon/*.c) $(COMMON_SRC)
|
||||||
DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o)) $(COMPAT_OBJ)
|
DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o)) $(COMPAT_OBJ)
|
||||||
TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c daemon/daemon.c testcode/replay.c testcode/fake_event.c $(filter-out util/netevent.c services/listen_dnsport.c services/outside_network.c, $(COMMON_SRC))
|
TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c daemon/daemon.c daemon/stats.c testcode/replay.c testcode/fake_event.c $(filter-out util/netevent.c services/listen_dnsport.c services/outside_network.c, $(COMMON_SRC))
|
||||||
TESTBOUND_OBJ=$(addprefix $(BUILD),$(TESTBOUND_SRC:.c=.o)) $(COMPAT_OBJ)
|
TESTBOUND_OBJ=$(addprefix $(BUILD),$(TESTBOUND_SRC:.c=.o)) $(COMPAT_OBJ)
|
||||||
LOCKVERIFY_SRC=testcode/lock_verify.c $(COMMON_SRC)
|
LOCKVERIFY_SRC=testcode/lock_verify.c $(COMMON_SRC)
|
||||||
LOCKVERIFY_OBJ=$(addprefix $(BUILD),$(LOCKVERIFY_SRC:.c=.o)) $(COMPAT_OBJ)
|
LOCKVERIFY_OBJ=$(addprefix $(BUILD),$(LOCKVERIFY_SRC:.c=.o)) $(COMPAT_OBJ)
|
||||||
|
|
|
||||||
71
daemon/stats.c
Normal file
71
daemon/stats.c
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* daemon/stats.c - collect runtime performance indicators.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is open source.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of the NLNET LABS nor the names of its contributors may
|
||||||
|
* be used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* This file describes the data structure used to collect runtime performance
|
||||||
|
* numbers. These 'statistics' may be of interest to the operator.
|
||||||
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
#include "daemon/stats.h"
|
||||||
|
#include "daemon/worker.h"
|
||||||
|
|
||||||
|
void server_stats_init(struct server_stats* stats)
|
||||||
|
{
|
||||||
|
memset(stats, 0, sizeof(stats));
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_stats_querymiss(struct server_stats* stats, struct worker* worker)
|
||||||
|
{
|
||||||
|
stats->num_queries_missed_cache++;
|
||||||
|
stats->sum_query_list_size += worker->num_requests;
|
||||||
|
if(worker->num_requests > stats->max_query_list_size)
|
||||||
|
stats->max_query_list_size = worker->num_requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
void server_stats_log(struct server_stats* stats, int threadnum)
|
||||||
|
{
|
||||||
|
log_info("server stats for thread %d: %u queries, %u from cache",
|
||||||
|
threadnum, (unsigned)stats->num_queries,
|
||||||
|
(unsigned)(stats->num_queries -
|
||||||
|
stats->num_queries_missed_cache));
|
||||||
|
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?
|
||||||
|
(double)stats->sum_query_list_size/
|
||||||
|
stats->num_queries_missed_cache:0.0,
|
||||||
|
(unsigned)stats->num_query_list_exceeded);
|
||||||
|
}
|
||||||
77
daemon/stats.h
Normal file
77
daemon/stats.h
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* daemon/stats.h - collect runtime performance indicators.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is open source.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of the NLNET LABS nor the names of its contributors may
|
||||||
|
* be used to endorse or promote products derived from this software without
|
||||||
|
* specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* This file describes the data structure used to collect runtime performance
|
||||||
|
* numbers. These 'statistics' may be of interest to the operator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DAEMON_STATS_H
|
||||||
|
#define DAEMON_STATS_H
|
||||||
|
struct worker;
|
||||||
|
|
||||||
|
/** per worker statistics */
|
||||||
|
struct server_stats {
|
||||||
|
/** number of queries from clients received. */
|
||||||
|
size_t num_queries;
|
||||||
|
/** number of queries that had a cache-miss. */
|
||||||
|
size_t num_queries_missed_cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sum of the querylistsize of the worker for
|
||||||
|
* every query that missed cache. To calculate average.
|
||||||
|
*/
|
||||||
|
size_t sum_query_list_size;
|
||||||
|
/** max value of query list size reached. */
|
||||||
|
size_t max_query_list_size;
|
||||||
|
/** number of times that the query_list_size was insufficient */
|
||||||
|
size_t num_query_list_exceeded;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize server stats to 0.
|
||||||
|
* @param stats: what to init (this is alloced by the caller).
|
||||||
|
*/
|
||||||
|
void server_stats_init(struct server_stats* stats);
|
||||||
|
|
||||||
|
/** add query if it missed the cache */
|
||||||
|
void server_stats_querymiss(struct server_stats* stats, struct worker* worker);
|
||||||
|
|
||||||
|
/** display the stats to the log */
|
||||||
|
void server_stats_log(struct server_stats* stats, int threadnum);
|
||||||
|
|
||||||
|
#endif /* DAEMON_STATS_H */
|
||||||
|
|
@ -284,6 +284,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
comm_point_drop_reply(repinfo);
|
comm_point_drop_reply(repinfo);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
worker->stats.num_queries++;
|
||||||
/* see if query is in the cache */
|
/* see if query is in the cache */
|
||||||
if(!query_info_parse(&qinfo, c->buffer)) {
|
if(!query_info_parse(&qinfo, c->buffer)) {
|
||||||
LDNS_QR_SET(ldns_buffer_begin(c->buffer));
|
LDNS_QR_SET(ldns_buffer_begin(c->buffer));
|
||||||
|
|
@ -303,6 +304,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ldns_buffer_rewind(c->buffer);
|
ldns_buffer_rewind(c->buffer);
|
||||||
|
server_stats_querymiss(&worker->stats, worker);
|
||||||
/* perform memory allocation(s) */
|
/* perform memory allocation(s) */
|
||||||
if(!query_info_allocqname(&qinfo)) {
|
if(!query_info_allocqname(&qinfo)) {
|
||||||
comm_point_drop_reply(repinfo);
|
comm_point_drop_reply(repinfo);
|
||||||
|
|
@ -315,6 +317,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
that started before we performed listen_pushback */
|
that started before we performed listen_pushback */
|
||||||
verbose(VERB_DETAIL, "worker: too many incoming requests "
|
verbose(VERB_DETAIL, "worker: too many incoming requests "
|
||||||
"active. dropping incoming query.");
|
"active. dropping incoming query.");
|
||||||
|
worker->stats.num_query_list_exceeded++;
|
||||||
comm_point_drop_reply(repinfo);
|
comm_point_drop_reply(repinfo);
|
||||||
query_info_clear(&qinfo);
|
query_info_clear(&qinfo);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -525,6 +528,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
|
||||||
fatal_exit("could not set forwarder address");
|
fatal_exit("could not set forwarder address");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
server_stats_init(&worker->stats);
|
||||||
alloc_init(&worker->alloc, &worker->daemon->superalloc,
|
alloc_init(&worker->alloc, &worker->daemon->superalloc,
|
||||||
worker->thread_num);
|
worker->thread_num);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -541,6 +545,7 @@ worker_delete(struct worker* worker)
|
||||||
{
|
{
|
||||||
if(!worker)
|
if(!worker)
|
||||||
return;
|
return;
|
||||||
|
server_stats_log(&worker->stats, worker->thread_num);
|
||||||
reqs_delete(worker);
|
reqs_delete(worker);
|
||||||
listen_delete(worker->front);
|
listen_delete(worker->front);
|
||||||
outside_network_delete(worker->back);
|
outside_network_delete(worker->back);
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
#include "util/locks.h"
|
#include "util/locks.h"
|
||||||
#include "util/alloc.h"
|
#include "util/alloc.h"
|
||||||
#include "util/data/msgreply.h"
|
#include "util/data/msgreply.h"
|
||||||
|
#include "daemon/stats.h"
|
||||||
struct listen_dnsport;
|
struct listen_dnsport;
|
||||||
struct outside_network;
|
struct outside_network;
|
||||||
struct config_file;
|
struct config_file;
|
||||||
|
|
@ -130,6 +131,8 @@ struct worker {
|
||||||
int need_to_restart;
|
int need_to_restart;
|
||||||
/** allocation cache for this thread */
|
/** allocation cache for this thread */
|
||||||
struct alloc_cache alloc;
|
struct alloc_cache alloc;
|
||||||
|
/** per thread statistics */
|
||||||
|
struct server_stats stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
- decompress query section, extremely lenient acceptance.
|
- decompress query section, extremely lenient acceptance.
|
||||||
But only for answers from other servers, not for plain queries.
|
But only for answers from other servers, not for plain queries.
|
||||||
- compression and decompression test cases.
|
- compression and decompression test cases.
|
||||||
|
- some stats added.
|
||||||
|
|
||||||
27 April 2007: Wouter
|
27 April 2007: Wouter
|
||||||
- removed iov usage, it is not good for dns message encoding.
|
- removed iov usage, it is not good for dns message encoding.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue