mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
optimization: store just IDs of child nodes
IDs are a lot smaller, hence quicker to manage. Any time we want to refer back to the full node we look it up in its topology. (This relies on nobody trying to store a rendered node as a child).
This commit is contained in:
@@ -161,8 +161,7 @@ type joinResults struct {
|
||||
func newJoinResults(inputNodes report.Nodes) joinResults {
|
||||
nodes := make(report.Nodes, len(inputNodes))
|
||||
for id, n := range inputNodes {
|
||||
n.Adjacency = nil // result() assumes all nodes start with no adjacencies
|
||||
n.Children = n.Children.Copy() // so we can do unsafe adds
|
||||
n.Adjacency = nil // result() assumes all nodes start with no adjacencies
|
||||
nodes[id] = n
|
||||
}
|
||||
return joinResults{nodes: nodes, mapped: map[string]string{}, multi: map[string][]string{}}
|
||||
@@ -193,7 +192,7 @@ func (ret *joinResults) addUnmappedChild(m report.Node, id string, topology stri
|
||||
if !exists {
|
||||
result = report.MakeNode(id).WithTopology(topology)
|
||||
}
|
||||
result.Children.UnsafeAdd(m)
|
||||
result = result.WithChildID(m.ID)
|
||||
if m.Topology != report.Endpoint { // optimisation: we never look at endpoint counts
|
||||
result = result.AddCounter(m.Topology, 1)
|
||||
}
|
||||
@@ -212,7 +211,7 @@ func (ret *joinResults) addChild(m report.Node, id string, topology string) {
|
||||
func (ret *joinResults) addChildAndChildren(m report.Node, id string, topology string) {
|
||||
ret.addUnmappedChild(m, id, topology)
|
||||
result := ret.nodes[id]
|
||||
result.Children.UnsafeMerge(m.Children)
|
||||
result = result.WithChildren(m.ChildIDs)
|
||||
ret.nodes[id] = result
|
||||
ret.mapChild(m.ID, id)
|
||||
}
|
||||
@@ -221,7 +220,6 @@ func (ret *joinResults) addChildAndChildren(m report.Node, id string, topology s
|
||||
func (ret *joinResults) passThrough(n report.Node) {
|
||||
n.Adjacency = nil // result() assumes all nodes start with no adjacencies
|
||||
ret.nodes[n.ID] = n
|
||||
n.Children = n.Children.Copy() // so we can do unsafe adds
|
||||
ret.mapChild(n.ID, n.ID)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user