diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-13 12:14:45 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-16 18:22:13 +0900 |
commit | 40ce51137a1bc3733d36ea045daae067eef735f0 (patch) | |
tree | 0fdb1519f42b4fea6f8793b31dc0202326fe872b /table/destination.go | |
parent | b344eb3777e5088f0a97d585e81e546363ea4101 (diff) |
table: remove unnecessary copy of path attributes
the result of memory profile (500 route-server-clients each of them advertises
100 routes)
before:
(pprof) top5
9330.48MB of 9367.53MB total (99.60%)
Dropped 157 nodes (cum <= 46.84MB)
Showing top 10 nodes out of 17 (cum >= 9334.17MB)
flat flat% sum% cum cum%
6163.04MB 65.79% 65.79% 6163.04MB 65.79% github.com/osrg/gobgp/table.NewPath
1155.05MB 12.33% 78.12% 7302.59MB 77.96% github.com/osrg/gobgp/table.(*Path).Clone
986.31MB 10.53% 88.65% 1388.81MB 14.83% github.com/osrg/gobgp/table.(*AdjRib).Update
402.51MB 4.30% 92.95% 402.51MB 4.30% fmt.Sprintf
402.51MB 4.30% 97.24% 402.51MB 4.30% net.parseIPv4
after:
(pprof) top
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
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/destination.go')
-rw-r--r-- | table/destination.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/table/destination.go b/table/destination.go index 2577e7cb..d6f1f1de 100644 --- a/table/destination.go +++ b/table/destination.go @@ -141,7 +141,7 @@ func (dd *Destination) ToApiStruct(id string) *api.Destination { ret := make([]*api.Path, 0, len(arg)) first := true for _, p := range arg { - if p.filtered[id] == POLICY_DIRECTION_NONE { + if p.Filtered(id) == POLICY_DIRECTION_NONE { pp := p.ToApiStruct(id) if first { pp.Best = true @@ -181,7 +181,7 @@ func (dd *Destination) setNlri(nlri bgp.AddrPrefixInterface) { func (dd *Destination) GetKnownPathList(id string) []*Path { list := make([]*Path, 0, len(dd.knownPathList)) for _, p := range dd.knownPathList { - if p.filtered[id] == POLICY_DIRECTION_NONE { + if p.Filtered(id) == POLICY_DIRECTION_NONE { list = append(list, p) } } @@ -190,7 +190,7 @@ func (dd *Destination) GetKnownPathList(id string) []*Path { func (dd *Destination) GetBestPath(id string) *Path { for _, p := range dd.knownPathList { - if p.filtered[id] == POLICY_DIRECTION_NONE { + if p.Filtered(id) == POLICY_DIRECTION_NONE { return p } } @@ -199,7 +199,7 @@ func (dd *Destination) GetBestPath(id string) *Path { func (dd *Destination) oldBest(id string) *Path { for _, p := range dd.oldKnownPathList { - if p.filtered[id] == POLICY_DIRECTION_NONE { + if p.Filtered(id) == POLICY_DIRECTION_NONE { return p } } @@ -357,7 +357,7 @@ func (dest *Destination) implicitWithdraw() { for _, path := range dest.knownPathList { found := false for _, newPath := range dest.newPathList { - if newPath.NoImplicitWithdraw { + if newPath.NoImplicitWithdraw() { continue } // Here we just check if source is same and not check if path @@ -540,8 +540,8 @@ func compareByLocalPref(path1, path2 *Path) *Path { // // # Default local-pref values is 100 log.Debugf("enter compareByLocalPref") - _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF) - _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF) + attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF) + attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF) if attribute1 == nil || attribute2 == nil { return nil @@ -591,8 +591,8 @@ func compareByASPath(path1, path2 *Path) *Path { // Shortest as-path length is preferred. If both path have same lengths, // we return None. log.Debugf("enter compareByASPath") - _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) - _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) + attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) + attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) if attribute1 == nil || attribute2 == nil { log.WithFields(log.Fields{ @@ -622,8 +622,8 @@ func compareByOrigin(path1, path2 *Path) *Path { // IGP is preferred over EGP; EGP is preferred over Incomplete. // If both paths have same origin, we return None. log.Debugf("enter compareByOrigin") - _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN) - _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN) + attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN) + attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN) if attribute1 == nil || attribute2 == nil { log.WithFields(log.Fields{ @@ -660,7 +660,7 @@ func compareByMED(path1, path2 *Path) *Path { // like bgp always-compare-med log.Debugf("enter compareByMED") getMed := func(path *Path) uint32 { - _, attribute := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) + attribute := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC) if attribute == nil { return 0 } @@ -687,7 +687,7 @@ func compareByASNumber(path1, path2 *Path) *Path { //peers, return None. log.Debugf("enter compareByASNumber") - log.Debugf("compareByASNumber -- p1Asn: %d, p2Asn: %d", path1.source.AS, path2.source.AS) + log.Debugf("compareByASNumber -- p1Asn: %d, p2Asn: %d", path1.GetSource().AS, path2.GetSource().AS) // If one path is from ibgp peer and another is from ebgp peer, take the ebgp path if path1.IsIBGP() != path2.IsIBGP() { if path1.IsIBGP() { @@ -734,8 +734,8 @@ func compareByRouterID(path1, path2 *Path) (*Path, error) { } // At least one path is not coming from NC, so we get local bgp id. - id1 := binary.BigEndian.Uint32(path1.source.ID) - id2 := binary.BigEndian.Uint32(path2.source.ID) + id1 := binary.BigEndian.Uint32(path1.GetSource().ID) + id2 := binary.BigEndian.Uint32(path2.GetSource().ID) // If both router ids are same/equal we cannot decide. // This case is possible since router ids are arbitrary. |