Skip to content

Commit 28bf53f

Browse files
committed
wgengine/magicsock: reduce disco ping heartbeat aggressiveness a bit
Bigger changes coming later, but this should improve things a bit in the meantime. Rationale: * 2 minutes -> 45 seconds: 2 minutes was overkill and never considered phones/battery at the time. It was totally arbitrary. 45 seconds is also arbitrary but is less than 2 minutes. * heartbeat from 2 seconds to 3 seconds: in practice this meant two packets per second (2 pings and 2 pongs every 2 seconds) because the other side was also pinging us every 2 seconds on their own. That's just overkill. (see tailscale#540 too) So in the worst case before: when we sent a single packet (say: a DNS packet), we ended up sending 61 packets over 2 minutes: the 1 DNS query and then then 60 disco pings (2 minutes / 2 seconds) & received the same (1 DNS response + 60 pongs). Now it's 15. In 1.22 we plan to remove this whole timer-based heartbeat mechanism entirely. The 5 seconds to 6.5 seconds change is just stretching out that interval so you can still miss two heartbeats (other 3 + 3 seconds would be greater than 5 seconds). This means that if your peer moves without telling you, you can have a path out for 6.5 seconds now instead of 5 seconds before disco finds a new one. That will also improve in 1.22 when we start doing UDP+DERP at the same time when confidence starts to go down on a UDP path. Updates tailscale#3363 Change-Id: Ic2314bbdaf42edcdd7103014b775db9cf4facb47 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent c8b63a4 commit 28bf53f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

wgengine/magicsock/magicsock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,19 +3274,19 @@ const (
32743274
// try to keep an established endpoint peering alive.
32753275
// It's also the idle time at which we stop doing STUN queries to
32763276
// keep NAT mappings alive.
3277-
sessionActiveTimeout = 2 * time.Minute
3277+
sessionActiveTimeout = 45 * time.Second
32783278

32793279
// upgradeInterval is how often we try to upgrade to a better path
32803280
// even if we have some non-DERP route that works.
32813281
upgradeInterval = 1 * time.Minute
32823282

32833283
// heartbeatInterval is how often pings to the best UDP address
32843284
// are sent.
3285-
heartbeatInterval = 2 * time.Second
3285+
heartbeatInterval = 3 * time.Second
32863286

32873287
// trustUDPAddrDuration is how long we trust a UDP address as the exclusive
32883288
// path (without using DERP) without having heard a Pong reply.
3289-
trustUDPAddrDuration = 5 * time.Second
3289+
trustUDPAddrDuration = 6500 * time.Millisecond
32903290

32913291
// goodEnoughLatency is the latency at or under which we don't
32923292
// try to upgrade to a better path.

0 commit comments

Comments
 (0)