]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/defines: added configurable SRTT limits and lowered probing rate
authorMarek Vavruša <mvavrusa@cloudflare.com>
Thu, 23 Aug 2018 00:37:01 +0000 (17:37 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
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:

lib/defines.h
lib/nsrep.c
lib/nsrep.h

index b16d0db49959a5d9f77bd88dd39cf0367a5cf6b1..79261a44011a7d569b22af2a82da24e38b8be19c 100644 (file)
@@ -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.
index 4153f8b77e72a5452b89a063a676c3b49cba83d1..55ed33873467126470d32e30d4ff4744817dce3c 100644 (file)
@@ -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;
index 67cff4ad7d691e2b10723fe79c759ebcb7d6e702..feb4de8cf05437f2061df40b16609dd79f19d014 100644 (file)
@@ -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,
 };
 
 /**