mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-26 16:52:25 +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:
@@ -21,15 +21,11 @@ func Prune(nodes report.Nodes) report.Nodes {
|
||||
// necessary for rendering nodes and edges stripped away. Specifically, that
|
||||
// means cutting out parts of the Node.
|
||||
func PruneNode(node report.Node) report.Node {
|
||||
prunedChildren := report.MakeNodeSet()
|
||||
node.Children.ForEach(func(child report.Node) {
|
||||
prunedChildren = prunedChildren.Add(PruneNode(child))
|
||||
})
|
||||
prunedNode := report.MakeNode(
|
||||
node.ID).
|
||||
WithTopology(node.Topology).
|
||||
WithAdjacent(node.Adjacency...).
|
||||
WithChildren(prunedChildren)
|
||||
WithChildren(node.ChildIDs)
|
||||
// Copy counters across, but with zero timestamp so they compare equal
|
||||
node.Latest.ForEach(func(k string, _ time.Time, v string) {
|
||||
if strings.HasPrefix(k, report.CounterPrefix) {
|
||||
|
||||
Reference in New Issue
Block a user