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
gui: Throttle GUI update pace when -reindex #18121
Conversation
utACK |
Co-authored-by: Barry Deeney <mxaddict@codedmaster.com> Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Github-Pull: bitcoin#18121 Rebased-From: 56bf425
Thanks you for working on this! |
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.
Code review ACK 56bf425. This is a good minimal fix. It would be also be nice to have followup cleanup that passes the reindexing state directly to the handleNotifyBlockTip
/handleNotifyHeaderTip
handlers, so the GUI doesn't need to call back into the node in the middle of handling an event from the node. This would also make the initial sync and reindexing conditions more consistent, and maybe more efficient if there are a lot of notifications backed up in the queue, because throttling could still happen when reindexing finished but notifications from reindexing were still being processed.
src/qt/clientmodel.cpp
Outdated
@@ -243,7 +243,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig | |||
clientmodel->cachedBestHeaderTime = blockTime; | |||
} | |||
// if we are in-sync or if we notify a header update, update the UI regardless of last update time | |||
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { | |||
// If the command line option -reindex is specified, the GUI update pace is throttled down. |
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.
In commit "gui: Throttle GUI update pace when -reindex" (56bf425)
Comment is a little misleading because throttling doesn't happen just generally when -reindex
is specified, it does stop when the reindex is over.
Would suggest changing to: "During initial sync, block notifications, and header notifications from reindexing are both throttled."
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.
Done.
src/qt/clientmodel.cpp
Outdated
@@ -243,7 +243,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig | |||
clientmodel->cachedBestHeaderTime = blockTime; | |||
} | |||
// if we are in-sync or if we notify a header update, update the UI regardless of last update time | |||
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { | |||
// If the command line option -reindex is specified, the GUI update pace is throttled down. | |||
if ((fHeader && !clientmodel->node().getReindex()) || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { |
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.
In commit "gui: Throttle GUI update pace when -reindex" (56bf425)
I think it would be best to put !initialSync
condition first to be clear throttling only happens during initial sync.
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.
Done.
Co-authored-by: Barry Deeney <mxaddict@codedmaster.com> Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
56bf425
to
c9fe612
Compare
Updated 56bf425 -> c9fe612 (pr18121.01 -> pr18121.02, compare). @ryanofsky |
// if we are in-sync or if we notify a header update, update the UI regardless of last update time | ||
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { | ||
|
||
// During initial sync, block notifications, and header notifications from reindexing are both throttled. |
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 find this very confusing, and even if I look past the grammar error, probably outright wrong since header notifications are only throttled for reindex, not initial sync?
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.
IIUC, fReindex==true
implies initialSync==true
:
Lines 1281 to 1282 in 2bdc476
if (fImporting || fReindex) | |
return true; |
Anyway, mind suggesting a better wording?
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 find this very confusing, and even if I look past the grammar error, probably outright wrong since header notifications are only throttled for reindex, not initial sync?
This is pretty confusing, and I was probably trying to pack too much information in a short comment. There should be chances to clean this up in the future with followups from #18136 or #18121 (review)
Ideally the code would just be more direct and not need a comment stating what it does:
enum NotificationType { BLOCK_TIP_CHANGED, HEADER_TIP_CHANGED };
enum NotificationStatus { INIT_REINDEX, INIT_DOWNLOAD, POST_INIT };
void HandleNotification(NotificationType notification, NotificationStatus status) {
bool throttle = status == INIT_REINDEX || (status == INIT_DOWNLOAD && notification == BLOCK_TIP_CHANGED);
if (!throttle || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) ...
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.
Addressed in #18152
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. |
utACK c9fe612 |
c9fe612 gui: Throttle GUI update pace when -reindex (Hennadii Stepanov) Pull request description: This is grabbed from #17565. All **laanwj**'s and **ryanofsky**'s suggestions are implemented. With this PR, the GUI does not freeze when a user runs: ``` $ ./src/qt/bitcoin-qt -reindex ``` ACKs for top commit: jonasschnelli: utACK c9fe612 Tree-SHA512: c7be316cb73d3d286bdf8429a960f71777d13a73d059869a64e23ad276499252b561a3a5b9613c4c1ad58cc0de26283c1ec72be745c401f604eaa05f70bf7d64
- [0.19] wallet: Reset reused transactions cache bitcoin#18083 - 0.19: Backports bitcoin#17792 - psbt: handle unspendable psbts bitcoin#17524 - qt: Fix comparison function signature bitcoin#17634 - psbt: check that various indexes and amounts are within bounds bitcoin#17156 - [0.19] psbt: check that various indexes and amounts are within bounds bitcoin#18079 - [0.19] Final backports for 0.19.1 bitcoin#17988 - Bug: IsUsedDestination shouldn't use key id as script id for ScriptHash bitcoin#17924 - qt: Fix deprecated QCharRef usage bitcoin#18101 - gui: Throttle GUI update pace when -reindex bitcoin#18121 - gui: Fix race in WalletModel::pollBalanceChanged bitcoin#18123 - gui: Fix unintialized WalletView::progressDialog bitcoin#18062 - Bugfix: GUI: Hide the HD/encrypt icons earlier so they get re-shown if another wallet is open bitcoin#18007 - bug-fix macos: give free bytes to F_PREALLOCATE bitcoin#17887 - test: add missing #include to fix compiler errors bitcoin#17980 - zmq: Fix due to invalid argument and multiple notifiers bitcoin#17445
a0d0f1c refactor: Remove Node:: queries from GUI (Hennadii Stepanov) 06d519f qt: Add SynchronizationState enum to signal parameter (Hennadii Stepanov) 3c709aa refactor: Remove Node::getReindex() call from GUI (Hennadii Stepanov) 1dab574 refactor: Pass SynchronizationState enum to GUI (Hennadii Stepanov) 2bec309 refactor: Remove unused bool parameter in RPCNotifyBlockChange() (Hennadii Stepanov) 1df7701 refactor: Remove unused bool parameter in BlockNotifyGenesisWait() (Hennadii Stepanov) Pull request description: This PR is a followup of #18121 and: - addresses confusion about GUI notification throttling conditions (**luke-jr**'s [comment](#18121 (comment)), **ryanofsky**'s [comment](#18121 (comment))) - removes `isInitialBlockDownload()` call from the GUI back to the node (on macOS). See: **ryanofsky**'s [comment](#18121 (review)) ACKs for top commit: jonasschnelli: Core Review ACK a0d0f1c (modulo [question](#18152 (review))). ryanofsky: Code review ACK a0d0f1c. Only changes since last review were rebase and tweaking SynchronizationState enum declaration as suggested (thanks!) Tree-SHA512: b6a712a710666e763aeee0d5440de1391a4c6c8f7fa661888773e1ba59e9e0f83654ee384d4edc704031be7eb25616e5eca2a6e26058d3efb7f64c47f9ed7316
Summary: ``` With this PR, the GUI does not freeze when a user runs: $ ./src/qt/bitcoin-qt -reindex ``` Backport of core [[bitcoin/bitcoin#18121 | PR18121]]. Test Plan: ninja all check ./src/qt/bitcoin-qt -reindex Check the GUI sync progress no longer causes epileptic seizure to the user. Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D8323
c9fe612 gui: Throttle GUI update pace when -reindex (Hennadii Stepanov) Pull request description: This is grabbed from bitcoin#17565. All **laanwj**'s and **ryanofsky**'s suggestions are implemented. With this PR, the GUI does not freeze when a user runs: ``` $ ./src/qt/bitcoin-qt -reindex ``` ACKs for top commit: jonasschnelli: utACK c9fe612 Tree-SHA512: c7be316cb73d3d286bdf8429a960f71777d13a73d059869a64e23ad276499252b561a3a5b9613c4c1ad58cc0de26283c1ec72be745c401f604eaa05f70bf7d64
c9fe612 gui: Throttle GUI update pace when -reindex (Hennadii Stepanov) Pull request description: This is grabbed from bitcoin#17565. All **laanwj**'s and **ryanofsky**'s suggestions are implemented. With this PR, the GUI does not freeze when a user runs: ``` $ ./src/qt/bitcoin-qt -reindex ``` ACKs for top commit: jonasschnelli: utACK c9fe612 Tree-SHA512: c7be316cb73d3d286bdf8429a960f71777d13a73d059869a64e23ad276499252b561a3a5b9613c4c1ad58cc0de26283c1ec72be745c401f604eaa05f70bf7d64
c9fe612 gui: Throttle GUI update pace when -reindex (Hennadii Stepanov) Pull request description: This is grabbed from bitcoin#17565. All **laanwj**'s and **ryanofsky**'s suggestions are implemented. With this PR, the GUI does not freeze when a user runs: ``` $ ./src/qt/bitcoin-qt -reindex ``` ACKs for top commit: jonasschnelli: utACK c9fe612 Tree-SHA512: c7be316cb73d3d286bdf8429a960f71777d13a73d059869a64e23ad276499252b561a3a5b9613c4c1ad58cc0de26283c1ec72be745c401f604eaa05f70bf7d64
This is grabbed from #17565.
All laanwj's and ryanofsky's suggestions are implemented.
With this PR, the GUI does not freeze when a user runs: