Files
tailscale/derp/derpserver
Mike O'Driscoll 55751c3d6d derp/derpserver: add server-level not-here cache for absent peer drops
Add a sync.Map cache on the Server that tracks destination keys not
connected to this server. When a packet arrives for a cached absent
destination, the payload is discarded via bufio.Reader.Discard without
allocating a buffer, taking the server mutex, or looking up the client
map. Cache entries expire after a configurable TTL (10s) and are
invalidated in registerClient when a peer connects.

Move the cache check into recvPacket so handleFrameSendPacket does not
need to duplicate the frame validation and key reading logic. When the
cache is hit, recvPacket returns nil contents and the caller returns
early.

Increase peerGoneLim from 3/sec to 50/sec per client. The not-here
cache now provides per-destination rate limiting, so the per-client
limiter serves only as a safety backstop against clients sending to
many unique absent destinations.

```
name                                      old ns/op  new ns/op  delta
HandleFrameSendPacketAbsent/same_key      570        131        -77%
HandleFrameSendPacketAbsent/unique_keys   559        145        -74%
(0 B/op, 0 allocs/op on cache hits; was 280 B/op, 8 allocs/op)
```

Updates #38509
2026-03-27 10:51:32 -04:00
..