From 9ec8a354686bd159c631cb1e33ebe8caeab76102 Mon Sep 17 00:00:00 2001 From: livingentity <84099642+livingentity@users.noreply.github.com> Date: Sat, 19 Feb 2022 17:55:36 +0100 Subject: [PATCH] restore old logic/constants (#2045) * fix indices * Update serversInfo.go For safety go back to former logic, just generalized for lbStrategy, until someone comes up with an actual improvement. * restore old logic/constants --- dnscrypt-proxy/serversInfo.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnscrypt-proxy/serversInfo.go b/dnscrypt-proxy/serversInfo.go index 3e4b9c7d..12e40df3 100644 --- a/dnscrypt-proxy/serversInfo.go +++ b/dnscrypt-proxy/serversInfo.go @@ -24,7 +24,7 @@ import ( ) const ( - RTTEwmaDecay = 15.0 + RTTEwmaDecay = 10.0 ) type RegisteredServer struct { @@ -264,9 +264,9 @@ func (serversInfo *ServersInfo) estimatorUpdate() { serversInfo.inner[candidate], serversInfo.inner[currentActive] = serversInfo.inner[currentActive], serversInfo.inner[candidate] dlog.Debugf("New preferred candidate: %s (RTT: %d vs previous: %d)", serversInfo.inner[currentActive].Name, int(candidateRtt), int(currentActiveRtt)) partialSort = true - } else if candidateRtt > 0 && candidateRtt > serversInfo.inner[activeCount].rtt.Value() { + } else if candidateRtt > 0 && candidateRtt >= (serversInfo.inner[0].rtt.Value()+serversInfo.inner[activeCount-1].rtt.Value())/2.0*4.0 { if time.Since(serversInfo.inner[candidate].lastActionTS) > time.Duration(1*time.Minute) { - serversInfo.inner[candidate].rtt.Add(serversInfo.inner[activeCount].rtt.Value()) + serversInfo.inner[candidate].rtt.Add(candidateRtt/2.0) dlog.Debugf("Giving a new chance to candidate [%s], lowering its RTT from %d to %d (best: %d)", serversInfo.inner[candidate].Name, int(candidateRtt), int(serversInfo.inner[candidate].rtt.Value()), int(serversInfo.inner[0].rtt.Value())) partialSort = true }