-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Optimisation: Store transaction list order in memory rather than compute it every need #6851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
People are already complaining about memory usage of the wallet. How much will this make it worse? |
|
I would guess maybe 40 bytes per transaction. I am running some tests to compare. The current code is very poor for zapwallettxes because it will re-sort the entire wallet transactions, every time it adds a new one. |
|
With a wallet containing 10184 transactions, I did not observe any measurable memory overhead to the cache. |
src/wallet/walletdb.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use a better method name? Maybe
_WriteAccountingEntry(const CAccountingEntry& acentry) //should only be called from the CWallet|
Nice! utACK. |
|
concept ACK, light utACK Also, I feel like any memory overhead required would already exist instantaneously at the call site anyway, this just persists the requirement for the lifetime of the application instead? edit: To clarify, this doesn't really require any extra memory, except in that it is now persistent across the applications lifetime, not just when needed. |
|
Needs rebase |
|
@luke-jr rebase please |
5873cc8 to
b99e085
Compare
|
Rebased |
|
Increased memory from 1.5GB on master to 1.8GB $ ./src/bitcoin-cli -testnet getwalletinfo |
|
@pstratem Pull request 6850 will improve zapwallet / rescan time similarly with no memory increase. However, this pull request will be good for AddToWallets when near the tip, where there is intermittent CPU spiking when the indexes are recreated. IMO, this pull request is needed even with the memory increase, but 6850 is less controversial. |
|
Rescan on wallet containing 14WCrzmqVCD7Thf79vutWTB6y1hUc8pP19 (maybe about 53k transactions) went from 23 minutes to 10 minutes. |
|
oh my numbers there were for the whole rescan, if I limit the benchmark to just the chunk of the blockchain that have transactions... it goes from 843 seconds to 35 seconds from 63/sec to 1541/sec; or 24x faster. |
|
On a wallet with 410k transactions in it, this repeatably decreases memory usage by ~5MB from 822MB to 816MB. I think it's fair to say that any increase is negligible. |
|
@gmaxwell I would expect any memory increase to be within "measurement error" tolerances, i.e. not significant. This is essentially just storing another index (or two?). It's great that your measurements seem to agree. And the previous code which ultimately recreated the indexes on each AddToWallet is simply bad. |
b99e085 to
b8a8cf2
Compare
…ute it every need Huge performance improvement (450%) for zapwallettxes
b8a8cf2 to
3e7c891
Compare
|
ACK. |
3e7c891 Optimisation: Store transaction list order in memory rather than compute it every need (Luke Dashjr)
[Backport] bitcoin/bitcoin#13825 kill accounts This is a backport of the following commits: - from bitcoin/bitcoin#13825 - pick bitcoin/bitcoin@c9c32e6 - from bitcoin/bitcoin#14023 - pick bitcoin/bitcoin@f0dc850 - from bitcoin/bitcoin#13566 - pick bitcoin/bitcoin@702ae1e - pick bitcoin/bitcoin@cf15761 - pick bitcoin/bitcoin@0f3d6e9 - pick bitcoin/bitcoin@7110c83 - pick bitcoin/bitcoin@ef7bc88 - pick bitcoin/bitcoin@4279da4 - pick bitcoin/bitcoin@c410f41 - from bitcoin/bitcoin#9614 - pick bitcoin/bitcoin@02d9f50 - pick bitcoin/bitcoin@82b7dc3 - from bitcoin/bitcoin#8061 - pick bitcoin/bitcoin@ecb9741 - from bitcoin/bitcoin#6851 - pick bitcoin/bitcoin@3e7c89196c - from bitcoin/bitcoin#8828 - pick bitcoin/bitcoin@86029e7 - from bitcoin/bitcoin#8696 - just the first two commits, as AccountingEntry is going away - pick bitcoin/bitcoin@d2e678d - pick bitcoin/bitcoin@59adc86 - from bitcoin/bitcoin#8028 - pick bitcoin/bitcoin@0fd5997
Huge performance improvement (450%) for zapwallettxes.
Also improves performance for RPC listtransactions.
(For comparison, removing smart-time entirely is only 340%)