Reduce cs_main locks during ConnectTip/SyncWithWallets#7946
Reduce cs_main locks during ConnectTip/SyncWithWallets#7946sipa merged 1 commit intobitcoin:masterfrom
Conversation
src/main.cpp
Outdated
There was a problem hiding this comment.
This is not correct, it needs to iterate through all the blocks that got connected, not just the new tip.
fdbee7d to
22d9380
Compare
|
As always when you want to improve the locking a little bit, the change gets quickly more invasive. Update serval things:
|
6416d91 to
086654e
Compare
|
ActivateBestChainStep reuses a vector for ConnectTip's txConflicted to combine results from multiple blocks. ConnectTip passes txConflicted to mempoool.removeForBlock every time. |
src/main.cpp
Outdated
There was a problem hiding this comment.
Could put the new loops below this comment with the other non-cs_main notifications
6fc0be6 to
e8ea3dd
Compare
|
You know what, I misread. |
|
Needs rebase. |
src/main.cpp
Outdated
e8ea3dd to
9471f32
Compare
|
Rebased, fixed sipas found issue and switched to |
src/main.cpp
Outdated
There was a problem hiding this comment.
Why a temporary variable, and not just pass vchConflicted to mempool.removeForBlock()? txConflictedCurrent is not used elsewhere.
There was a problem hiding this comment.
Without a temporary variable, mempool.removeForBlock would always work though the combined list txConflicted that was initialized here.
Although I'm not sure if this would be a problem, but at least it would slightly change current masters behavior.
There was a problem hiding this comment.
"Work through"? All that function does is append deleted CTransactions to it.
There was a problem hiding this comment.
Yes. Your right. Removed the temp. var.
9471f32 to
580a665
Compare
src/main.cpp
Outdated
There was a problem hiding this comment.
Sorry for changing my mind, but can you define a struct for this instead? Larger tuples don't really have good readability.
There was a problem hiding this comment.
IMO tuple is ideal for a such use case. It's only a temporary variable and its scope is very small. IMO an custom struct seems to be over complex.
There was a problem hiding this comment.
c++ needs collections.namedtuple :)
There was a problem hiding this comment.
There was a problem hiding this comment.
given the repeated use, maybe just typedef the std::tuple? tuple has some nice conveniences over a struct alternative.
580a665 to
fdf8a5e
Compare
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
This cs_main is unfortunate, but I guess we can get rid of it in a follow-up.
|
utACK fdf8a5efe03004f4a581ba41b87737a4e1f1ff44 |
|
utACK fdf8a5e |
|
utACK fdf8a5e, but the squashme commits need squashing |
fdf8a5e to
d31dd19
Compare
|
Squashed. |
This runs BlockConnectedDisconnected, TransactionAddedToMempool, SetBestChain, and Inventory on the background scheduler thread. This partially reverts bitcoin#9583, re-enabling some of the gains from bitcoin#7946. This does not, however, re-enable the gains achieved by repeatedly releasing cs_main between each transaction processed.
This runs BlockConnectedDisconnected, TransactionAddedToMempool, SetBestChain, and Inventory on the background scheduler thread. This partially reverts bitcoin#9583, re-enabling some of the gains from bitcoin#7946. This does not, however, re-enable the gains achieved by repeatedly releasing cs_main between each transaction processed.
This runs BlockConnectedDisconnected, TransactionAddedToMempool, SetBestChain, and Inventory on the background scheduler thread. This partially reverts bitcoin#9583, re-enabling some of the gains from bitcoin#7946. This does not, however, re-enable the gains achieved by repeatedly releasing cs_main between each transaction processed.
This runs BlockConnectedDisconnected, TransactionAddedToMempool, SetBestChain, and Inventory on the background scheduler thread. This partially reverts bitcoin#9583, re-enabling some of the gains from bitcoin#7946. This does not, however, re-enable the gains achieved by repeatedly releasing cs_main between each transaction processed.
This runs BlockConnectedDisconnected, TransactionAddedToMempool, SetBestChain, and Inventory on the background scheduler thread. This partially reverts bitcoin#9583, re-enabling some of the gains from bitcoin#7946. This does not, however, re-enable the gains achieved by repeatedly releasing cs_main between each transaction processed.
DisconnectTip and AcceptToMempool are still holding cs_main (not intended to improve this in this PR)