diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-16 16:40:05 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-16 18:25:35 +0900 |
commit | 6403c806634491b6cd6c3c90f61badf478fed9aa (patch) | |
tree | f557370a5c3ca739d644172140dd42af63cd1b00 /server/peer.go | |
parent | 0cf8045e994b653030b721c574614d46c1870cf1 (diff) |
server: reduce number of path.Clone() call to reduce memory footprint
the result of memory profile (500 route-server-clients each of them
advertises 100 routes)
before:
(pprof) top5
3913.02MB of 3978.69MB total (98.35%)
Dropped 148 nodes (cum <= 19.89MB)
Showing top 10 nodes out of 11 (cum >= 21MB)
flat flat% sum% cum cum%
2970.30MB 74.66% 74.66% 2975.80MB 74.79% github.com/osrg/gobgp/server.filterpath
810.09MB 20.36% 95.02% 810.59MB 20.37% github.com/osrg/gobgp/table.(*AdjRib).Update
115.60MB 2.91% 97.92% 119.10MB 2.99% github.com/osrg/gobgp/table.createUpdateMsgFromPath
10MB 0.25% 98.17% 1878.02MB 47.20% github.com/osrg/gobgp/server.(*BgpServer).propagateUpdate
4.50MB 0.11% 98.29% 144.60MB 3.63% github.com/osrg/gobgp/table.CreateUpdateMsgFromPaths
after:
(pprof) top5
1259.49MB of 1284.27MB total (98.07%)
Dropped 175 nodes (cum <= 6.42MB)
Showing top 10 nodes out of 26 (cum >= 36.51MB)
flat flat% sum% cum cum%
975.81MB 75.98% 75.98% 976.31MB 76.02% github.com/osrg/gobgp/table.(*AdjRib).Update
198.67MB 15.47% 91.45% 208.17MB 16.21% github.com/osrg/gobgp/table.createUpdateMsgFromPath
22MB 1.71% 93.16% 22MB 1.71% github.com/osrg/gobgp/packet.(*IPAddrPrefix).Serialize
20MB 1.56% 94.72% 707.19MB 55.07% github.com/osrg/gobgp/server.(*BgpServer).propagateUpdate
13.50MB 1.05% 95.77% 13.50MB 1.05% github.com/osrg/gobgp/table.NewPath
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/peer.go b/server/peer.go index c4e09617..ef08a4d8 100644 --- a/server/peer.go +++ b/server/peer.go @@ -105,13 +105,17 @@ func (peer *Peer) getAccepted(rfList []bgp.RouteFamily) []*table.Path { func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []*table.Path) { pathList := []*table.Path{} filtered := []*table.Path{} + options := &table.PolicyOptions{ + Neighbor: peer.fsm.peerInfo.Address, + } for _, path := range peer.localRib.GetBestPathList(peer.TableID(), rfList) { - p := peer.policy.ApplyPolicy(peer.TableID(), table.POLICY_DIRECTION_EXPORT, filterpath(peer, path), nil) + p := peer.policy.ApplyPolicy(peer.TableID(), table.POLICY_DIRECTION_EXPORT, filterpath(peer, path), options) if p == nil { filtered = append(filtered, path) continue } if !peer.isRouteServerClient() { + p = p.Clone(p.IsWithdraw) p.UpdatePathAttrs(&peer.gConf, &peer.conf) } pathList = append(pathList, p) |