]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: don't include connection setup for TCP and TLS in RTT
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 31 Jul 2018 22:07:58 +0000 (15:07 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
Currently the handshake time is included in the RTT, so TCP and TLS
retries/forwards makes upstreams look bad compared to UDP, and
discourage connection reuse as other "faster" origins end up
with lower score, so they would be preferred.

This commit excludes wait and handshake time, so only the actual
message exchange time is included in the RTT calculation.

daemon/worker.c

index 9f17164738e807fe4f344d271b5ac66000e03753..476d4e187728b92b8ed06d9e5a53fa19e200826a 100644 (file)
@@ -1098,6 +1098,17 @@ static int session_tls_hs_cb(struct session *session, int status)
                }
        }
 
+       /* Reset the query start time to exclude connection establishment time,
+        * otherwise server would appear slower on every reconnect / TCP retry.
+        * The sessions support query multiplexing and keepalive, so the connection time
+        * is amortized over multiple queries.
+        */
+       for (size_t i = 0; i < session->waiting.len; ++i) {
+               struct qr_task *task = session->waiting.at[i];
+               struct kr_query *query = kr_rplan_last(kr_resolve_plan(&task->ctx->req));
+               query->timestamp_mono = kr_now();
+       }
+
        ret = worker_add_tcp_connected(worker, &peer->ip, session);
        if (deletion_res == kr_ok() && ret == kr_ok()) {
                ret = session_next_waiting_send(session);