-
Notifications
You must be signed in to change notification settings - Fork 38.7k
wallet: Remove boost from PeriodicFlush #18792
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: Remove boost from PeriodicFlush #18792
Conversation
|
Not sure how to test manually, but I have included a unit test |
|
Concept ACK. |
|
Concept ACK |
|
The main thing to review here is the change in behavior: |
fae3bd8 to
fa900e6
Compare
Me neither, but it seems avoidable by adding one more if-check. Done that. |
|
Shouldn't the check be at the beginning of the for loop instead of of |
fa900e6 to
faddf20
Compare
|
Thanks, fixed. |
faddf20 to
fa223c3
Compare
|
Rebased after silent merge conflict |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
jnewbery
left a comment
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.
Concept ACK. Can you add a description for this PR?
You say here: #18758 (comment) that these interruption points can't be used. Were they used at some point in the past and were broken? If so, have you been able to determine which commit broke them? If not, I don't think it's worth adding the extra shutdown handling in this PR. It could potentially be added in a future PR.
You can remove the #include <boost/thread.hpp> from walletdb.cpp and db.cpp.
src/wallet/wallet.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.
Why not use default member initialization in the header file?
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.
This wouldn't compile. Thanks C++
Done |
Sorry, that pull is still marked as draft and is not ready for review. The decision boils down to "Is the interruption point run in a Here, the scheduler is (still) a |
fa223c3 to
fabd1c9
Compare
|
Force pushed to address feedback by @jnewbery (remove boost include from db.cpp) |
I also suggested removing it from |
From a quick read of https://www.boost.org/doc/libs/1_53_0/doc/html/thread/thread_management.html#thread.thread_management.tutorial.interruption, it seems to me that the The only place that happens is the I haven't looked deeply enough into #18234 to figure out whether that's a regression. If not, I think we can just remove all of these interrupt points that no longer do anything. If it is a regression, then perhaps this PR should explicitly state that it's a bug fix. |
It looks like 306f71b tells the scheduler to stop after the current task is executed or before the execution starts (i.e. the scheduler is waiting for the next flush). The call is non-blocking when a task is currently executed. Consequently, the next line will interrupt all threads in the thread group, which will also interrupt the periodic flush action in case it is currently running. So I don't think the behaviour has changed in that commit, at least not in regard to flushing? Correct me if I am wrong. |
|
I start to wonder if it is worth to abort the periodic flush when flush(true) is called shortly after in |
That's a catch in |
No, you're right. I misunderstood what
Yes, it does seem unnecessary. We call then we interrupt the scheduler thread (which may cause us to interrupt a periodic flush), and then we flush again on shutdown: Making that middle flush interruptible does seem unnecessary. |
fabd1c9 to
e8a8e37
Compare
fanquake
left a comment
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.
ACK the change - however there's another boost::thread_interrupted& in walletdb.cpp:
bitcoin/src/wallet/walletdb.cpp
Lines 890 to 893 in 4430744
| } | |
| catch (const boost::thread_interrupted&) { | |
| throw; | |
| } |
I think it can also be removed, but if not, I'm not sure how we can drop the <boost/thread.hpp> include as unused in fa7b885.
FindWalletTx is only called by zapwallet, which is never called in a boost::thread
|
@fanquake Good catch. Added a commit with rationale to remove that as well. |
fanquake
left a comment
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.
ACK fa1c74f
fa1c74f wallet: Remove unused boost::thread_interrupted (MarcoFalke) fa7b885 walletdb: Remove unsed boost/thread (MarcoFalke) 5555d97 wallet: Make PeriodicFlush uninterruptible (MarcoFalke) Pull request description: The `boost::this_thread::interruption_point()` in the code base currently block the replacement of `boost::thread` with `std::thread`. [1] Remove them from the wallet because they are either unused or useless. The feature to interrupt a periodic flush is useless because all wallets have just been flushed https://github.com/bitcoin/bitcoin/blob/9ccaee1d5e2e4b79b0a7c29aadb41b97e4741332/src/init.cpp#L194 and another flush should be a noop. Also, they will be flushed again shortly after https://github.com/bitcoin/bitcoin/blob/9ccaee1d5e2e4b79b0a7c29aadb41b97e4741332/src/init.cpp#L285, so even if repeated flushes weren't a noop, doing 3 instead of 2 shouldn't matter too much at this point. Also, the wallet is flushed every two seconds in the worst case, so if this is an expensive operation, that period should be readjusted. (Or bdb should be removed altogether bitcoin#18916) [1] Replacement of `boost::thread` with `std::thread` should happen because: * The boost thread dependency is slow to compile * Boost thread is less maintained than the standard lib * Boost thread is mostly redundant to the standard lib * Global interruption points via exceptions are hard to keep track of during review and easy to get wrong during runtime (e.g. accidental `catch (...)`) ACKs for top commit: fanquake: ACK fa1c74f Tree-SHA512: b166619256de2ef4325480fa1367f68bc9371ad785ec503aed61eab41ba61f1a9807aab25451a24efda3db64855c9ba0025645b98bc58557bc3ec56c5b3297d0
Summary: ``` The boost::this_thread::interruption_point() in the code base currently block the replacement of boost::thread with std::thread. [1] Remove them from the wallet because they are either unused or useless. ``` Backport of core [[bitcoin/bitcoin#18792 | PR18792]]. Depends on D8615. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D8616
Co-authored-by: UdjinM6 <[email protected]>
Co-authored-by: UdjinM6 <[email protected]>
merge bitcoin#13671, bitcoin#17405, bitcoin#18786, bitcoin#18792, bitcoin#20067: Deboostification
The
boost::this_thread::interruption_point()in the code base currently block the replacement ofboost::threadwithstd::thread. [1]Remove them from the wallet because they are either unused or useless.
The feature to interrupt a periodic flush is useless because all wallets have just been flushed
bitcoin/src/init.cpp
Line 194 in 9ccaee1
bitcoin/src/init.cpp
Line 285 in 9ccaee1
[1] Replacement of
boost::threadwithstd::threadshould happen because:catch (...))