Skip to content

Commit

Permalink
Stats for discard-timeout and wait-limit (#1159)
Browse files Browse the repository at this point in the history
* - Stats num.queries_discard_timeout and num.queries_wait_limit are used
  instead of the mesh dropped that of requests exceeded.
  • Loading branch information
wcawijngaards authored Nov 1, 2024
1 parent f5580f0 commit 75967e7
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions daemon/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,10 @@ print_stats(RES* ssl, const char* nm, struct ub_stats_info* s)
(unsigned long)s->svr.num_queries_cookie_client)) return 0;
if(!ssl_printf(ssl, "%s.num.queries_cookie_invalid"SQ"%lu\n", nm,
(unsigned long)s->svr.num_queries_cookie_invalid)) return 0;
if(!ssl_printf(ssl, "%s.num.queries_discard_timeout"SQ"%lu\n", nm,
(unsigned long)s->svr.num_queries_discard_timeout)) return 0;
if(!ssl_printf(ssl, "%s.num.queries_wait_limit"SQ"%lu\n", nm,
(unsigned long)s->svr.num_queries_wait_limit)) return 0;
if(!ssl_printf(ssl, "%s.num.cachehits"SQ"%lu\n", nm,
(unsigned long)(s->svr.num_queries
- s->svr.num_queries_missed_cache))) return 0;
Expand Down
7 changes: 7 additions & 0 deletions daemon/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset)
s->svr.rpz_action[i] += (long long)worker->env.mesh->rpz_action[i];
timehist_export(worker->env.mesh->histogram, s->svr.hist,
NUM_BUCKETS_HIST);
s->svr.num_queries_discard_timeout +=
(long long)worker->env.mesh->num_queries_discard_timeout;
s->svr.num_queries_wait_limit +=
(long long)worker->env.mesh->num_queries_wait_limit;
/* values from outside network */
s->svr.unwanted_replies = (long long)worker->back->unwanted_replies;
s->svr.qtcp_outgoing = (long long)worker->back->num_tcp_outgoing;
Expand Down Expand Up @@ -451,6 +455,9 @@ void server_stats_add(struct ub_stats_info* total, struct ub_stats_info* a)
total->svr.num_queries_cookie_valid += a->svr.num_queries_cookie_valid;
total->svr.num_queries_cookie_client += a->svr.num_queries_cookie_client;
total->svr.num_queries_cookie_invalid += a->svr.num_queries_cookie_invalid;
total->svr.num_queries_discard_timeout +=
a->svr.num_queries_discard_timeout;
total->svr.num_queries_wait_limit += a->svr.num_queries_wait_limit;
total->svr.num_queries_missed_cache += a->svr.num_queries_missed_cache;
total->svr.num_queries_prefetch += a->svr.num_queries_prefetch;
total->svr.num_queries_timed_out += a->svr.num_queries_timed_out;
Expand Down
12 changes: 12 additions & 0 deletions doc/unbound-control.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ number of queries with a client part only DNS Cookie by thread
.I threadX.num.queries_cookie_invalid
number of queries with an invalid DNS Cookie by thread
.TP
.I threadX.num.queries_discard_timeout
number of queries removed due to discard-timeout by thread
.TP
.I threadX.num.queries_wait_limit
number of queries removed due to wait-limit by thread
.TP
.I threadX.num.cachehits
number of queries that were successfully answered using a cache lookup
.TP
Expand Down Expand Up @@ -511,6 +517,12 @@ summed over threads.
.I total.num.queries_cookie_invalid
summed over threads.
.TP
.I total.num.queries_discard_timeout
summed over threads.
.TP
.I total.num.queries_wait_limit
summed over threads.
.TP
.I total.num.cachehits
summed over threads.
.TP
Expand Down
4 changes: 4 additions & 0 deletions libunbound/unbound.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ struct ub_server_stats {
long long mem_quic;
/** number of queries over (DNS over) QUIC */
long long qquic;
/** number of queries removed due to discard-timeout */
long long num_queries_discard_timeout;
/** number of queries removed due to wait-limit */
long long num_queries_wait_limit;
};

/**
Expand Down
10 changes: 7 additions & 3 deletions services/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ mesh_create(struct module_stack* stack, struct module_env* env)
mesh->stats_dropped = 0;
mesh->ans_expired = 0;
mesh->ans_cachedb = 0;
mesh->num_queries_discard_timeout = 0;
mesh->num_queries_wait_limit = 0;
mesh->max_reply_states = env->cfg->num_queries_per_thread;
mesh->max_forever_states = (mesh->max_reply_states+1)/2;
#ifndef S_SPLINT_S
Expand Down Expand Up @@ -424,7 +426,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
verbose(VERB_ALGO, "Too many queries waiting from the IP. "
"dropping incoming query.");
comm_point_drop_reply(rep);
mesh->stats_dropped++;
mesh->num_queries_wait_limit++;
return;
}
if(!unique)
Expand Down Expand Up @@ -1540,7 +1542,7 @@ void mesh_query_done(struct mesh_state* mstate)
http2_stream_remove_mesh_state(r->h2_stream);
comm_point_drop_reply(&r->query_reply);
mstate->reply_list = reply_list;
mstate->s.env->mesh->stats_dropped++;
mstate->s.env->mesh->num_queries_discard_timeout++;
continue;
}

Expand Down Expand Up @@ -2042,6 +2044,8 @@ mesh_stats_clear(struct mesh_area* mesh)
memset(&mesh->ans_rcode[0], 0, sizeof(size_t)*UB_STATS_RCODE_NUM);
memset(&mesh->rpz_action[0], 0, sizeof(size_t)*UB_STATS_RPZ_ACTION_NUM);
mesh->ans_nodata = 0;
mesh->num_queries_discard_timeout = 0;
mesh->num_queries_wait_limit = 0;
}

size_t
Expand Down Expand Up @@ -2270,7 +2274,7 @@ mesh_serve_expired_callback(void* arg)
http2_stream_remove_mesh_state(r->h2_stream);
comm_point_drop_reply(&r->query_reply);
mstate->reply_list = reply_list;
mstate->s.env->mesh->stats_dropped++;
mstate->s.env->mesh->num_queries_discard_timeout++;
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions services/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ struct mesh_area {
size_t ans_nodata;
/** (extended stats) type of applied RPZ action */
size_t rpz_action[UB_STATS_RPZ_ACTION_NUM];
/** stats, number of queries removed due to discard-timeout */
size_t num_queries_discard_timeout;
/** stats, number of queries removed due to wait-limit */
size_t num_queries_wait_limit;

/** backup of query if other operations recurse and need the
* network buffers */
Expand Down
3 changes: 3 additions & 0 deletions smallapp/unbound-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ static void pr_stats(const char* nm, struct ub_stats_info* s)
s->svr.num_queries_cookie_client);
PR_UL_NM("num.queries_cookie_invalid",
s->svr.num_queries_cookie_invalid);
PR_UL_NM("num.queries_discard_timeout",
s->svr.num_queries_discard_timeout);
PR_UL_NM("num.queries_wait_limit", s->svr.num_queries_wait_limit);
PR_UL_NM("num.cachehits",
s->svr.num_queries - s->svr.num_queries_missed_cache);
PR_UL_NM("num.cachemiss", s->svr.num_queries_missed_cache);
Expand Down

0 comments on commit 75967e7

Please sign in to comment.