Skip to content

Commit 9ec8a35

Browse files
author
livingentity
authored
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
1 parent ac6abfb commit 9ec8a35

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

dnscrypt-proxy/serversInfo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
const (
27-
RTTEwmaDecay = 15.0
27+
RTTEwmaDecay = 10.0
2828
)
2929

3030
type RegisteredServer struct {
@@ -264,9 +264,9 @@ func (serversInfo *ServersInfo) estimatorUpdate() {
264264
serversInfo.inner[candidate], serversInfo.inner[currentActive] = serversInfo.inner[currentActive], serversInfo.inner[candidate]
265265
dlog.Debugf("New preferred candidate: %s (RTT: %d vs previous: %d)", serversInfo.inner[currentActive].Name, int(candidateRtt), int(currentActiveRtt))
266266
partialSort = true
267-
} else if candidateRtt > 0 && candidateRtt > serversInfo.inner[activeCount].rtt.Value() {
267+
} else if candidateRtt > 0 && candidateRtt >= (serversInfo.inner[0].rtt.Value()+serversInfo.inner[activeCount-1].rtt.Value())/2.0*4.0 {
268268
if time.Since(serversInfo.inner[candidate].lastActionTS) > time.Duration(1*time.Minute) {
269-
serversInfo.inner[candidate].rtt.Add(serversInfo.inner[activeCount].rtt.Value())
269+
serversInfo.inner[candidate].rtt.Add(candidateRtt/2.0)
270270
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()))
271271
partialSort = true
272272
}

0 commit comments

Comments
 (0)