From fc8dae49e41b7f2130edbea8532f2a058222e2a3 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Fri, 6 Feb 2015 20:04:57 -0500 Subject: [PATCH] Make profiling easier to follow with static dispatch. For example, when performing a heap profile, this: . . 125: fetchFunc := db.FetchUnSpentTxByShaList . . 126: if includeSpent { . . 127: fetchFunc = db.FetchTxByShaList . . 128: } . 9.11MB 129: txReplyList := fetchFunc(txList) Now becomes this: . . 125: var txReplyList []*database.TxListReply . . 126: if includeSpent { . . 127: txReplyList = db.FetchTxByShaList(txList) . . 128: } else { . 8.75MB 129: txReplyList = db.FetchUnSpentTxByShaList(txList) . . 130: } And it's clear where the majority of our allocations are coming from. --- blockchain/txlookup.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blockchain/txlookup.go b/blockchain/txlookup.go index f0e37170..8f367bfa 100644 --- a/blockchain/txlookup.go +++ b/blockchain/txlookup.go @@ -122,11 +122,12 @@ func fetchTxStoreMain(db database.Db, txSet map[wire.ShaHash]struct{}, includeSp // will return the information from the point of view of the end of the // main chain. Choose whether or not to include fully spent // transactions depending on the passed flag. - fetchFunc := db.FetchUnSpentTxByShaList + var txReplyList []*database.TxListReply if includeSpent { - fetchFunc = db.FetchTxByShaList + txReplyList = db.FetchTxByShaList(txList) + } else { + txReplyList = db.FetchUnSpentTxByShaList(txList) } - txReplyList := fetchFunc(txList) for _, txReply := range txReplyList { // Lookup the existing results entry to modify. Skip // this reply if there is no corresponding entry in