From 1217992d9d1f5f6fb11be76269c698d0f13fcc64 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 4 Sep 2018 16:42:12 -0700 Subject: [PATCH] autopilot: optimize heavy loaded agent by fetching raw bytes for ChannelEdge In this commit, we implement an optimization to the autopilot agent to ensure that we don't spin and waste CPU when we either have a large graph, or a high max channel target for the agent. Before this commit, each time we went to read the state of a channel from disk, we would decompress the EC Point each time. However, for the case of the instal ChannlEdge struct to feed to the agent, we only actually need to obtain the pubkey, and can save the potentially expensive point decompression for each directional channel in the graph. --- autopilot/graph.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autopilot/graph.go b/autopilot/graph.go index 7f9cd4d4..9834c8b4 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -96,13 +96,12 @@ func (d dbNode) ForEachChannel(cb func(ChannelEdge) error) error { return nil } - pubkey, _ := ep.Node.PubKey() edge := ChannelEdge{ Channel: Channel{ ChanID: lnwire.NewShortChanIDFromInt(ep.ChannelID), Capacity: ei.Capacity, FundedAmt: ei.Capacity, - Node: NewNodeID(pubkey), + Node: NodeID(ep.Node.PubKeyBytes), }, Peer: dbNode{ tx: tx,