From: Marek VavruĊĦa Date: Thu, 23 Aug 2018 00:37:01 +0000 (-0700) Subject: lib/defines: added configurable SRTT limits and lowered probing rate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12a06550f69a3cafa352467d401e3de932c2053a;p=thirdparty%2Fknot-resolver.git lib/defines: added configurable SRTT limits and lowered probing rate This adds configurable SRTT limits for various network environments. The probing rate is reduced from 10% to 1%, so that badly connected nameservers are not selected as often. This is apparent on zone cuts with a lot of nameservers, e.g. .com. With the probing rate set to 1% the average response time for 300 queries is almost 50% better: --- diff --git a/lib/defines.h b/lib/defines.h index b16d0db49..79261a440 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -68,6 +68,12 @@ static inline int KR_COLD kr_error(int x) { #ifndef KR_QUERY_NSRETRY_LIMIT #define KR_QUERY_NSRETRY_LIMIT 4 /* Maximum number of retries per query. */ #endif +#ifndef KR_MIN_NSRTT +#define KR_MIN_NSRTT 5 /* Minimum NS SRTT cap. */ +#endif +#ifndef KR_DEFAULT_NSRTT +#define KR_DEFAULT_NSRTT 250 /* Default/unknown NS SRTT value. */ +#endif /* * Defines. diff --git a/lib/nsrep.c b/lib/nsrep.c index 4153f8b77..55ed33873 100644 --- a/lib/nsrep.c +++ b/lib/nsrep.c @@ -256,9 +256,9 @@ static int eval_nsrep(const knot_dname_t *owner, const pack_t *addr_set, struct (score < KR_NS_LONG || qry->flags.NO_THROTTLE)) { update_nsrep_set(ns, owner, addr_choice, score); ns->reputation = reputation; - } else if ((kr_rand_uint(100) < 10) && + } else if ((kr_rand_uint(100) < 1) && (kr_rand_uint(KR_NS_MAX_SCORE) >= score)) { - /* With 10% chance probe server with a probability + /* With 1% chance probe server with a probability * given by its RTT / MAX_RTT. */ update_nsrep_set(ns, owner, addr_choice, score); ns->reputation = reputation; diff --git a/lib/nsrep.h b/lib/nsrep.h index 67cff4ad7..feb4de8cf 100644 --- a/lib/nsrep.h +++ b/lib/nsrep.h @@ -34,9 +34,9 @@ enum kr_ns_score { KR_NS_MAX_SCORE = KR_CONN_RTT_MAX, KR_NS_TIMEOUT = (95 * KR_NS_MAX_SCORE) / 100, KR_NS_LONG = (3 * KR_NS_TIMEOUT) / 4, - KR_NS_UNKNOWN = KR_NS_TIMEOUT / 2, + KR_NS_UNKNOWN = KR_DEFAULT_NSRTT, KR_NS_PENALTY = 100, - KR_NS_GLUED = 10 + KR_NS_GLUED = KR_MIN_NSRTT, }; /**