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:
Bryan Boreham
2020-06-08 16:39:50 +00:00
parent b4a73b7f87
commit d76da767d8
13 changed files with 233 additions and 280 deletions

View File

@@ -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) {