From 5389161162c3da2eae73484d6dab7a7c240e9e4e Mon Sep 17 00:00:00 2001 From: Juan Pablo Civile Date: Sat, 3 Aug 2019 23:01:16 -0300 Subject: [PATCH] routing: make log in findPath hot path use logClosure It generates heap allocations for it's params even if it won't end up using them. Reduces memory usage by 2mb --- routing/pathfind.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index 33c452f0b..46199e452 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -448,8 +448,11 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, fromVertex, toNode, amountToSend, ) - log.Tracef("path finding probability: fromnode=%v, tonode=%v, "+ - "probability=%v", fromVertex, toNode, edgeProbability) + log.Trace(newLogClosure(func() string { + return fmt.Sprintf("path finding probability: fromnode=%v,"+ + " tonode=%v, probability=%v", fromVertex, toNode, + edgeProbability) + })) // If the probability is zero, there is no point in trying. if edgeProbability == 0 {