ipn/ipnlocal, wgengine/wgcfg/nmcfg: stop building peer lists on delta path
Processing a peer add/remove delta still materialized the full netmap (an O(n) slicesx.MapValues plus sort over all peers, at 10k+ peers in a large tailnet) twice per delta: once in UpdateNetmapDelta purely to hand the self node to Engine.SetSelfNode, and once in authReconfigLocked. Neither needs peers anymore. SetSelfNode gets the self node from the existing nodeBackend.Self accessor. authReconfigLocked only reads self-node fields (SelfNode, NodeKey, GetAddresses, HasCap) now that WireGuard peers ride the incremental route manager and per-peer config source, so it can use the peers-free NetMap accessor. That also makes nmcfg.WGCfg vestigial: since wgcfg.Config lost its Peers field, its peer walk existed only to emit the [v1] skip logs (expired peers, unselected exit nodes, unaccepted subnet routes), duplicating filtering the route manager already does. Delete the package and construct the two-field wgcfg.Config inline. The skip logs go away; if they're missed, the route manager can log them incrementally at upsert time instead of rescanning every peer on every reconfig. With this, the runtime.DidRange analysis (see the ts_rangehook test) shows a delta netmap update performing no O(n) range loops except updateRouteManagerExtras, and the delta phase of that test drops from 1.09s to 0.14s for 400 deltas at n=10000 (from 4.79s at the start of this effort, before the incremental route manager work). Updates #12542 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: Ia0e03ef9db0c988790b2c29de1f0505305e93f58
This commit is contained in:
committed by
Brad Fitzpatrick
parent
3515b009c2
commit
4660a961eb
@@ -397,12 +397,11 @@ func (m *Mutation) UpsertPeer(n tailcfg.NodeView) {
|
||||
// peerViewOf reduces a tailcfg.NodeView to the routing-relevant
|
||||
// peerView.
|
||||
//
|
||||
// It mirrors the peer and prefix filtering in nmcfg.WGCfg: peers we
|
||||
// cannot communicate with (expired, or predating both DERP and disco)
|
||||
// contribute no prefixes. They remain tracked by ID and key so that a
|
||||
// later update can make them routable again. AllowedIPs is the sole
|
||||
// source of prefixes; an address absent from AllowedIPs is not
|
||||
// routable. The self-vs-route split mirrors nmcfg's cidrIsSubnet:
|
||||
// Peers we cannot communicate with (expired, or predating both DERP
|
||||
// and disco) contribute no prefixes. They remain tracked by ID and key
|
||||
// so that a later update can make them routable again. AllowedIPs is
|
||||
// the sole source of prefixes; an address absent from AllowedIPs is
|
||||
// not routable. For the self-vs-route split,
|
||||
// single Tailscale IPs are never subnets, so a VIP service address
|
||||
// hosted by the peer lands in SelfAddrs and stays routable without
|
||||
// Prefs.RouteAll.
|
||||
@@ -662,8 +661,7 @@ func normalizePrefix(p netip.Prefix) netip.Prefix {
|
||||
// non-address bits set, mirroring the defensive check in
|
||||
// ipnlocal.peerRoutes. It includes the peer's extra allowed IPs,
|
||||
// except for peers that contribute no addresses or routes of their
|
||||
// own (expired or otherwise non-communicable peers, which mirrors
|
||||
// nmcfg.WGCfg dropping such peers entirely).
|
||||
// own (expired or otherwise non-communicable peers).
|
||||
func (rm *RouteManager) contribs(p peerView) map[netip.Prefix]contribKind {
|
||||
c := make(map[netip.Prefix]contribKind, len(p.SelfAddrs)+len(p.Routes))
|
||||
add := func(pfx netip.Prefix, kind contribKind) {
|
||||
|
||||
Reference in New Issue
Block a user