[Qt] Add option to pause/resume block downloads #9502

Open
wants to merge 8 commits into
from

Conversation

Projects
None yet
Member

jonasschnelli commented Jan 10, 2017

This, almost UI only change, will add a Pause/Resume button to the modal overlay to pause/resume block downloads during IBD.

This is an effective way to pause/resume IBD during a time when the computers resources are required somewhere else.

bildschirmfoto 2017-01-10 um 18 34 09

jonasschnelli added the GUI label Jan 10, 2017

Contributor

paveljanik commented Jan 10, 2017

Isn't network toggle button usable in this case? If it is not, let's fix it instead...

Member

jonasschnelli commented Jan 10, 2017

I extracted this from my SPV branch. Especially there, it is very useful to pause IBD and continue with SPV during a time where you don't want to use all available resources on verification.

But also without SPV, I think this can be useful (pause IBD and not loose broadcast capabilities, fetch headers but not the blocks)...

Member

luke-jr commented Jan 10, 2017

IMO it would be too confusing to be worth it without "SPV" mode, but probably should go in after the latter is.

Member

MarcoFalke commented Jan 10, 2017

Member

luke-jr commented Jan 10, 2017

The "Pause" button won't be visible in normal cases.

Member

jonasschnelli commented Jan 10, 2017

Isn't network toggle button usable in this case? If it is not, let's fix it instead...

Imo those are different features, but I agree that the GUI should not
"diverge" in regard to presenting features. The toggle network
functionality should be removed from the network icon and a proper
button should be put beside the new "Pause" button?

Yes. These are internally two completely different features. Expose to the users, these have similar effects.

The "Pause" button won't be visible in normal cases.

Yes. The modal overlay is currently only accessible during IBD. Though, we could extend it to support a state where the chain is in-sync and show it when someone click on the network statusbar icon.

src/net_processing.h
@@ -14,6 +14,10 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals);
/** Unregister a network node */
void UnregisterNodeSignals(CNodeSignals& nodeSignals);
+/** if disabled, blocks will not be requested automatically, usefull for low-resources-available mode */
@kallewoof

kallewoof Feb 28, 2017

Contributor

Typo: usefull (one L)

src/qt/clientmodel.h
@@ -81,6 +81,10 @@ class ClientModel : public QObject
QString formatClientStartupTime() const;
QString dataDir() const;
+ // get/set state about autorequesting-blocks during IBD
+ bool isAutorequestBlocks() const;
@kallewoof

kallewoof Feb 28, 2017

Contributor

Nit: isAutorequestingBlocks (add ing). The setAutorequestBlocks below is fine as is, though.

laanwj added this to the 0.15.0 milestone Mar 14, 2017

Owner

laanwj commented Mar 14, 2017

Added 0.15 milestone

Member

jonasschnelli commented Mar 17, 2017

Rebased.

src/net_processing.h
@@ -23,6 +23,10 @@ void RegisterNodeSignals(CNodeSignals& nodeSignals);
/** Unregister a network node */
void UnregisterNodeSignals(CNodeSignals& nodeSignals);
+/** if disabled, blocks will not be requested automatically, usefull for low-resources-available mode */
+static const bool DEFAULT_AUTOMATIC_BLOCK_REQUESTS = true;
+extern std::atomic<bool> fAutoRequestBlocks;
@laanwj

laanwj Apr 19, 2017

Owner

Instead of exporting this variable (whose definition is an implementation detail) from net_processing.h I'd prefer a setter/getter, e.g. SetAutoRequestBlocks(bool) GetAutoRequestBlocks()

@jonasschnelli

jonasschnelli Apr 19, 2017

Member

Agree. Will change...

src/qt/clientmodel.cpp
@@ -233,6 +234,22 @@ QString ClientModel::dataDir() const
return GUIUtil::boostPathToQString(GetDataDir());
}
+bool ClientModel::isAutorequestBlocks() const
@laanwj

laanwj Apr 19, 2017

Owner

isAutorequestBlocks is a bit of a strange name; isAutoRequestingBlocks maybe?

Owner

laanwj commented Apr 19, 2017

When re-enabling AutoRequestBlocks, what 'kicks off' the block requesting process again? Setting the flag will make it request blocks the next time FindNextBlocksToDownload is called; is that good enough? I suppose it is, because SendMessages is called periodically (every 100 ms?).

Member

jonasschnelli commented Apr 20, 2017

Overhauled the PR and addresses @laanwj points.

Also, I added the info "Blocks requested from peers" (blocks in flight). This may be important because pause will not result in disconnecting peers. Already requested blocks will be downloaded (and verified) in the "pause" state.

If blocks are in flight and the pause has been triggered, there is now a special info label Wait to finish current downloads.

Contributor

paveljanik commented Apr 20, 2017

Well, I have to change my previous opinion. I think this can be useful.

Concept ACK

Will test soon.

Contributor

paveljanik commented Apr 25, 2017

Needs rebase.

Contributor

ryanofsky commented May 1, 2017

ACK e952b67

Code looks good. On the UI feature, two minor comments:

  • Pausing the download throws off "Estimated time left till synced." It would be better pausing didn't affect estimated time.
  • Pause/Resume button really sticks out where it's currently placed. Maybe it would make more sense next to the progress bar or near the hide button.
Owner

sipa commented May 1, 2017

Needs rebase.

Member

jonasschnelli commented May 11, 2017

Rebased.

Contributor

paveljanik commented May 15, 2017

Testing this again.

ACK fc84323

I think this could be even more usable if it can be called once fully in sync with the network. But I can't display the overlay then...

Owner

laanwj commented May 24, 2017

I think this could be even more usable if it can be called once fully in sync with the network. But I can't display the overlay then...

Hm I vaguely remember I added that functionality once, you should be able to bring up the overlay by the secret trick of clicking on the sync icon.

Contributor

paveljanik commented May 24, 2017

@laanwj But the sync icon (you mean the triangle with an exclamation mark inside?) is not displayed when you are "in sync" with the network.

Member

jonasschnelli commented May 24, 2017 edited

I think this could be even more usable if it can be called once fully in sync with the network. But I can't display the overlay then...

There are four ways how the modal-overlay can be opened:
-> auto-opens when in IBD/sync
-> Click on the warning icons next to the balance
-> Click on the progress bar during IBD/sync
-> Click on the sync icon in the status bar

Though I agree with you, there is no option how to open it once you are in sync... which could be useful, but independent to this PR.

Owner

laanwj commented May 24, 2017

@paveljanik Oh, though it also worked with the checkmark that takes its place.

Member

jonasschnelli commented May 24, 2017

@paveljanik Oh, though it also worked with the checkmark that takes its place.

Yes. We should probably allow that.

Contributor

sdaftuar commented Jun 1, 2017

Concept ACK. (I haven't reviewed the qt code at all, but I did look over the net_processing changes.)

What is the intended behavior if the user turns off block download after being synced or nearly synced? I believe this PR only disables the parallel fetch logic, and not the direct fetch -- so block download could conceivably be disabled by the user, but blocks could still be requested as they are announced. (Maybe this is hard to accomplish, if the modal overlay is not accessible when bitcoind is close to synced, but my recollection is that the modal overlay becomes visible whenever the headers chain is out of sync, which can happen even after leaving IBD, does that sound right?)

Perhaps the ability to disable block download should disappear if we're close to caught up, eg if CanDirectFetch() is true?

Additionally, perhaps if we've disabled block download, we should also disable transaction download.

jonasschnelli added some commits Jan 10, 2017

@jonasschnelli jonasschnelli Add fAutoRequestBlocks to disabled/enable the verification progress 1e165bf
@jonasschnelli jonasschnelli [Qt] update header-syncing progress when not processing a block b30c8a1
@jonasschnelli jonasschnelli [Qt] Add option to pause/resume block downloads 5702c49
@jonasschnelli jonasschnelli Rename autorequest blocks methods 0ac2217
@jonasschnelli jonasschnelli Add setter/getter for fAutoRequestBlocks f7e8ef4
@jonasschnelli jonasschnelli Show block in flight b072636
@jonasschnelli jonasschnelli Show special info when autodownload is disabled but blocks are in flight 17e1dab
@jonasschnelli jonasschnelli Disable "pause downloading blocks" when we can fetch blocks directly f1b057f
Member

jonasschnelli commented Jun 29, 2017

Rebased and addressed the CanDirectFetch() issue @sdaftuar mentioned.

The current implementation avoids exposing net_processing.cpp's CanDirectFetch() for the reasons a) it does always use chainActive (lock) and b) to avoid another core-layer dependency.

I'm not doing to tackle the transaction download in the PR (main scope is disabling block download).

Contributor

achow101 commented Jul 12, 2017

ACK

I have tested this on a node that was a few weeks behind and I was able to pause the block download multiple times while it was syncing. I noticed that even when paused, UpdateTip is still happening for hundreds of blocks after what the GUI said still needed to be downloaded. I assume this is because it still processes all of the blocks that have been downloaded and the downloading happens faster than the processing. The UpdateTip lines do stop after a while which I assume is because all downloaded blocks have been processed.

Owner

sipa commented Jul 12, 2017

I assume this is because it still processes all of the blocks that have been downloaded and the downloading happens faster than the processing.

Yes, that's expected. We download multiple blocks in parallel, ahead of the next one to connect. I expect that this PR also keeps processing the ones that were in flight at the time blocks downloads are disabled.

@@ -334,6 +354,33 @@ QLabel { color: rgb(40,40,40); }</string>
<number>10</number>
</property>
<item>
@promag

promag Jul 17, 2017

Contributor

Nit, can't comment there, but remove leftMargin above to be consistent.

@@ -334,6 +354,33 @@ QLabel { color: rgb(40,40,40); }</string>
<number>10</number>
</property>
<item>
+ <widget class="QPushButton" name="pauseResumeVerification">
@promag

promag Jul 17, 2017

Contributor

Nit, rename toggleDownloadButton.

+
+void ModalOverlay::updatePauseState(bool pauseActive)
+{
+ ui->labelNumberBlocksRequested->setText((pauseActive ? "Finish downloading blocks": "Blocks requested from peers"));
@promag

promag Jul 17, 2017

Contributor

Don't see the need to change label, maybe a generic Downloading: %d blocks?

+{
+ ui->labelNumberBlocksRequested->setText((pauseActive ? "Finish downloading blocks": "Blocks requested from peers"));
+ ui->pauseResumeVerification->setText((pauseActive ? "Resume downloading blocks ": "Pause downloading blocks"));
+ ui->infoLabel->setText((pauseActive && getAmountOfBlocksInFlight() > 0 ? "Wait to finish current downloads...": ""));
@promag

promag Jul 17, 2017

Contributor

I don't know if you plan to show other messages for this label, but if not then toggle visibility like above?

@promag

promag Jul 17, 2017

Contributor

Also, when paused, nBlocksInFlight doesn't always decrease to zero.

@laanwj laanwj modified the milestone: 0.16.0, 0.15.0 Jul 18, 2017

Owner

laanwj commented Jul 18, 2017

This has missed the 0.15 feature freeze, moving to 0.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment