You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to get a range of transactions by height, the code first gets every single transaction via txs, err := db.GetAllTXs() (by scanning through all 170k+ Factoid Blocks) and then loops through all transactions to filter out the ones with the desirable height. This is obviously not very efficient and caused the function GetRelatedTransactions to perform very poorly, taking an average of ~5seconds to execute on my pc.
The mutex remains locked as long as the function runs in the background and it's automatically scheduled to execute every 10 seconds, which prevented the "Transactions" page from loading as it waited for that mutex to be released.
This can be fixed by rewriting the GetTxRange function to only cycle from the head down to the desired height and grabbing the related transactions instead of all 170k+ factoid blocks, which drove down execution time to ~250ms on my pc.
I was tasked to investigate why the "Transactions" page is fairly slow to load, and I tracked down the error to the
GetTXRange
function:factom/wallet/txdatabase.go
Lines 207 to 216 in 27c6cd7
In order to get a range of transactions by height, the code first gets every single transaction via
txs, err := db.GetAllTXs()
(by scanning through all 170k+ Factoid Blocks) and then loops through all transactions to filter out the ones with the desirable height. This is obviously not very efficient and caused the functionGetRelatedTransactions
to perform very poorly, taking an average of ~5seconds to execute on my pc.This function locks a mutex.
https://github.com/FactomProject/enterprise-wallet/blob/7819099c274a1bedaa9d677371c0b29079931f2a/wallet/walletDB.go#L390-L391
The mutex remains locked as long as the function runs in the background and it's automatically scheduled to execute every 10 seconds, which prevented the "Transactions" page from loading as it waited for that mutex to be released.
This can be fixed by rewriting the
GetTxRange
function to only cycle from the head down to the desired height and grabbing the related transactions instead of all 170k+ factoid blocks, which drove down execution time to ~250ms on my pc.Proposed fix: WhoSoup@e0e9e5d
(note: the new code is substantially copy/pasted from
GetAllTxs
)The text was updated successfully, but these errors were encountered: