Skip to content

Conversation

@pstratem
Copy link
Contributor

@pstratem pstratem commented Jun 6, 2016

This is the last method to pass a CWalletDB

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious: what is the reason to not keep a instance variable (within CWallet) that holds walletdb object? What are the benefits of constantly opening/instantiating the CWalletDB?

Copy link
Member

@laanwj laanwj Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope is used to manage the lifetime of the (database) transaction.

So having a single CWalletDB object would change semantics significantly. Some people have had this idea before but it was always rejected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonasschnelli I will eventually get to that point, but it's going to take a significant amount of work to get there.

@sipa
Copy link
Member

sipa commented Jun 7, 2016

I think the persistent CWalletDb object here is just there to prevent a flush to disk in between every added transaction, for performance reasons. Based on earlier pull requests by @pstratem around this, I think he intends to re-introduce a single CWalletDb* inside CWallet rather than reopening one all the time, after cleaning things up. Perhaps that will need to be done in the same PR, though?

@dcousens
Copy link
Contributor

dcousens commented Jun 7, 2016

Perhaps that will need to be done in the same PR, though?

I think provided it is done before a release, there is no issue.

@maflcko
Copy link
Member

maflcko commented Jun 7, 2016

I think there is no advantage merging this small refactoring early. Might as well just add the second commit to address @jonasschnelli s and @sipa s feedback.

@jonasschnelli
Copy link
Contributor

Regardless of the persistent CWalletDB * I think this PR has value (refactoring). But I guess we should not change the ReadKeyValue/AddToWallet in that way that it instantiate a new CWalletDB on each wallet transaction load from the wallet.dat (which this PR currently does).

@laanwj
Copy link
Member

laanwj commented Jun 7, 2016

A refactoring shouldn't result in behavioral changes. I'd rather stick with ugly code somewhat longer than introduce a temporary (but serious) performance regression.

@dcousens
Copy link
Contributor

dcousens commented Jun 7, 2016

introduce a temporary (but serious) performance regression.

At least then you'll have users reminding you 😆

@pstratem
Copy link
Contributor Author

pstratem commented Jun 8, 2016

I've split up AddToWallet into AddToWallet and LoadToWallet around the fFromLoadWallet flag.

This addresses the performance @jonasschnelli noticed and improves the API.

@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from b456663 to 175dcdc Compare June 8, 2016 04:41
@pstratem
Copy link
Contributor Author

pstratem commented Jun 8, 2016

I swapped the order of the commits such that there's no performance issue at any point.

22fa63e74150139c7c71108ee46ed87d31a4a2f3c171d16c34530f76ecc79f82

@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from 175dcdc to 2a20b89 Compare June 8, 2016 09:53
@pstratem
Copy link
Contributor Author

pstratem commented Jun 8, 2016

import hashlib;hashlib.sha256("there is still a performance issue").hexdigest()

there isn't actually

@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from 2a20b89 to 072571c Compare June 8, 2016 23:34
@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from 072571c to 44d5267 Compare June 16, 2016 01:17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the non-file-backend state is only used in UnitTests, right? We should also consider dropping it completely (in a later PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll be able to easily remove it once more of the logic is encapsulated.

@jonasschnelli
Copy link
Contributor

utACK 44d5267bfcd8abae5f0ae2a0f4052fc5a88acd2e

@maflcko
Copy link
Member

maflcko commented Jun 17, 2016

utACK 44d5267

@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from 44d5267 to 6246add Compare July 19, 2016 21:35
@pstratem pstratem changed the title Remove CWalletDB* parameter from CWallet::AddToWallet [Wallet] Remove CWalletDB* parameter from CWallet::AddToWallet Jul 20, 2016
@instagibbs
Copy link
Member

instagibbs commented Jul 21, 2016

tACK 6246add89a46523526a57b66bb87daf9413c69d7

@maflcko
Copy link
Member

maflcko commented Jul 21, 2016

Seems 6246add is just a plain rebase of 44d5267

re-utACK 6246add

@pstratem
Copy link
Contributor Author

@MarcoFalke indeed it is

@jonasschnelli
Copy link
Contributor

Looks good now!
Extensive Code Review ACK (6246add89a46523526a57b66bb87daf9413c69d7), nit: maybe squash commit.

@pstratem
Copy link
Contributor Author

@jonasschnelli I'd rather not squash, each commit is logically independent.

Copy link
Member

@laanwj laanwj Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go

Edit: Note that the parameters under which walletdb are opened change here - it used to be specifically overriding the flush to false, but after this change, the walletdb will be opened inside AddToWallet with default parameters.
What is the impact of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this can go. I'll run a benchmark of master and this pr doing a rescan with a wallet that has an enormous number of transactions and keys.

@sipa
Copy link
Member

sipa commented Jul 29, 2016

utACK c04225e7fdb9651ae2f97ed0e3f9601205ea858b

@pstratem pstratem force-pushed the 2016-06-06-cwallet-addtowallet-remove-cwalletdb branch from 3c6a33e to 5723bb4 Compare July 30, 2016 00:05
@pstratem
Copy link
Contributor Author

@laanwj I was having trouble getting consistent benchmark results from -rescan (+-30 seconds on runs taking 160-200 seconds).

So I just added an fFlushOnClose parameter so it's now clearly doing the same thing as before the change.

@sipa
Copy link
Member

sipa commented Jul 30, 2016

reutACK 5723bb4

@pstratem
Copy link
Contributor Author

Indeed I generally agree, but I was already squashing adding the
fFlushOnClose flag.

Whenever possible I strongly prefer that each commit produces a complete
working build.

On Jul 31, 2016 3:56 AM, "MarcoFalke" [email protected] wrote:

indeed it is

I prefer no rebase when it is not necessary. Reviewers always have to
reconstruct the history locally each time a rebase is done.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#8152 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAl4Q5FO3twJijzI_pOno3iNIKzaHvLfks5qbH8-gaJpZM4IvJOB
.

@maflcko
Copy link
Member

maflcko commented Jul 31, 2016

With rebase I meant changing the commit which the pull is based on,
not squashing.

reACK 5723bb4

@sipa sipa merged commit 5723bb4 into bitcoin:master Aug 1, 2016
sipa added a commit that referenced this pull request Aug 1, 2016
…Wallet

5723bb4 Remove unused pwalletdb from CWallet::AddToWallet (Patrick Strateman)
867f842 Remove CWalletDB* parameter from CWallet::AddToWallet (Patrick Strateman)
00f09c9 Split CWallet::AddToWallet into AddToWallet and LoadToWallet. (Patrick Strateman)
codablock pushed a commit to codablock/dash that referenced this pull request Jan 8, 2018
…::AddToWallet

5723bb4 Remove unused pwalletdb from CWallet::AddToWallet (Patrick Strateman)
867f842 Remove CWalletDB* parameter from CWallet::AddToWallet (Patrick Strateman)
00f09c9 Split CWallet::AddToWallet into AddToWallet and LoadToWallet. (Patrick Strateman)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…::AddToWallet

5723bb4 Remove unused pwalletdb from CWallet::AddToWallet (Patrick Strateman)
867f842 Remove CWalletDB* parameter from CWallet::AddToWallet (Patrick Strateman)
00f09c9 Split CWallet::AddToWallet into AddToWallet and LoadToWallet. (Patrick Strateman)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants