-
Notifications
You must be signed in to change notification settings - Fork 993
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
Wallet Performance enhancements - cache commit + transaction fetching logic #2375
Conversation
Taking a look now. @yeastplume how comfortable are you with these changes going in pre-mainnet vs. post-mainnet? |
I think it's best to get this one in before mainnet, given that the performance increase relies on the cached commit being available at output creation time. The wallet tests have grown to be fairly comprehensive, so I'd be very surprised if this introduced anything odd (though of course that can never be ruled out). |
wallet/src/lmdb_wallet.rs
Outdated
@@ -199,6 +199,17 @@ where | |||
&mut self.w2n_client | |||
} | |||
|
|||
/// return the commit, if enabled, None otherwise | |||
fn cached_commit(&mut self, amount: u64, id: &Identifier) -> Result<Option<String>, Error> { |
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.
Is this maybe mis-named or am I misunderstanding what is going on here?
Its not actually cached in here?
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.
I think this looks fine.
One minor comment.
👍
Thanks for the review! renamed that function to try and make it a bit more clear |
Some performance enhancements that should greatly improve speed of larger wallet sets:
I'd removed the cached commit from the database as it was making the logic more complicated, however it also ends up slowing everything down if all commits have to be re-calculated all the time (such as during a
grin wallet outputs
. To add this 'cache' back in a more sensible way, I've simply added it to the stored WalletOutput struct as an optional field, that can be populated when an output is being created.Because this leads to slightly worse privacy by having the commit in the database, (though no worse then when I removed the cache earlier,) I've added a flag to the wallet config to turn off commit caching (i.e. store None in the commit field of the WalletOutput'. You can elect to turn off commit caching at the expense of a performance hit.
Also simplified transaction retrieval logic to avoid looping through iterator many times and speeding up the check for whether an output needs to be updated from the server (via checking the TX log)