Skip to content

Commit

Permalink
Merge #1231: [Wallet] IsEquivalentTo commented, removing an extra rou…
Browse files Browse the repository at this point in the history
…nd of ser+hash calculation.

24fb46d [Wallet] IsEquivalentTo commented for now to not add an extra round of serialization + hash calculation in every read transaction in the wallet startup. (furszy)

Pull request description:

  To explain the reason that forced me to hunt this for over a week..

  In huge wallets (+100k txs wallets) the 4.0 startup time is taking +30 minutes. Which is crazy long and sounded much more as a regression over 3.4 which was taking less than 10 minutes.

  Root cause:

  After some time (and improvements over different areas #1217), found that the `IsEquivalentTo` method is adding an extra round of serialization + hash calculation on every transaction that is loaded into the wallet. Which gets really, time-wise, expensive in big wallets for a small benefit.

  Test:

  Environment:
  - Wallet with 419,633 db records.
  - MacOS i7, 16gb ram.

  Pre-PR transactions load time:

  30 minutes and i got bored and killed the process..

  Post-PR transactions load time:

  34.369 seconds.

  For now, decided to just comment it to be able to release 4.0.1 as soon as possible with all of the improvements.

  The final, future, goal of course it's not this one, we need to backport the whole `loadToWallet` flow from upstream + introduce our own changes there.

  Just a first initial step solving the regression.

ACKs for top commit:
  Fuzzbawls:
    ACK 24fb46d
  random-zebra:
    ACK 24fb46d and merging...

Tree-SHA512: bd4b7b34b60eabf9ebe555312bbb26373430057bff07d1ee1d0bc137004dd47bfbf3d263e146113e347b3a767b4e01376fdf3b2984abd4b321d188ac91cfa391
  • Loading branch information
random-zebra authored and Liquid369 committed Jan 2, 2020
1 parent 4a9a04e commit 9b6b524
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ void CWallet::SyncMetaData(pair<TxSpends::iterator, TxSpends::iterator> range)
CWalletTx* copyTo = &mapWallet[hash];
if (copyFrom == copyTo) continue;
assert(copyFrom && "Oldest wallet transaction in range assumed to have been found.");
if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
//if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
copyTo->mapValue = copyFrom->mapValue;
copyTo->vOrderForm = copyFrom->vOrderForm;
// fTimeReceivedIsTxTime not copied on purpose
Expand Down

0 comments on commit 9b6b524

Please sign in to comment.