Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented Apr 3, 2016

Currently, we're keeping a timeout for each requested block, starting from when it is requested, with a correction factor for the number of blocks in the queue.

That's unnecessarily complicated and inaccurate.

As peers process block requests in order, we can make the timeout for each block start counting only when all previous ones have been received, and have a correction based on the number of peers, rather than the total number of blocks.

@btcdrak
Copy link
Contributor

btcdrak commented Apr 3, 2016

Concept ACK

@laanwj laanwj added the P2P label Apr 4, 2016
@sipa sipa force-pushed the betterkicktimeout branch from 5f359ed to 5bc71fc Compare April 4, 2016 11:46
@sipa
Copy link
Member Author

sipa commented Apr 4, 2016

Updated to add a simple self consistency check.

queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
}
if (queuedBlock.nTimeDisconnect < nNow) {
if (nNow > state.nDownloadingSince + 500000 * consensusParams.nPowTargetSpacing * (4 + nPeersWithValidatedDownloads)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

state.nDownloadingSince + 500000 * consensusParams.nPowTargetSpacing * (4 + nPeersWithValidatedDownloads)

Could we name this constant variable? As what it represents isn't exactly clear IMHO.
Comment, variable, constant, whatever.

@sipa sipa force-pushed the betterkicktimeout branch from 5bc71fc to b18c125 Compare April 6, 2016 15:46
@sipa
Copy link
Member Author

sipa commented Apr 6, 2016

Rebased, and introduced constants for the timeouts.

@dcousens
Copy link
Contributor

dcousens commented Apr 7, 2016

utACK b18c125

@gmaxwell
Copy link
Contributor

gmaxwell commented Apr 7, 2016

Seems like an obvious improvement. Concept ACK.

@@ -106,6 +106,10 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
static const unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60;
/** Maximum feefilter broadcast delay after significant change. */
static const unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
/** Block download timeout base, expressed in millionths of the block interval */
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 2000000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do I understand this correctly that BLOCK_DOWNLOAD_TIMEOUT_BASE is thus 2000000*(10min/1000000), ie. 20minutes? In either case, it is worth more expressive comment IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the actual clock times to the comment.

sipa added 2 commits April 7, 2016 12:13
Currently, we're keeping a timeout for each requested block, starting
from when it is requested, with a correction factor for the number of
blocks in the queue.

That's unnecessarily complicated and inaccurate.

As peers process block requests in order, we can make the timeout for each
block start counting only when all previous ones have been received, and
have a correction based on the number of peers, rather than the total number
of blocks.
@sipa sipa force-pushed the betterkicktimeout branch from b18c125 to 0e24bbf Compare April 7, 2016 10:13
@laanwj laanwj merged commit 0e24bbf into bitcoin:master Apr 7, 2016
laanwj added a commit that referenced this pull request Apr 7, 2016
0e24bbf Self check after the last peer is removed (Pieter Wuille)
2d1d658 Track block download times per individual block (Pieter Wuille)
@laanwj
Copy link
Member

laanwj commented Apr 7, 2016

utACK 0e24bbf

laanwj pushed a commit that referenced this pull request Apr 7, 2016
Currently, we're keeping a timeout for each requested block, starting
from when it is requested, with a correction factor for the number of
blocks in the queue.

That's unnecessarily complicated and inaccurate.

As peers process block requests in order, we can make the timeout for each
block start counting only when all previous ones have been received, and
have a correction based on the number of peers, rather than the total number
of blocks.

Conflicts:
	src/main.cpp
	src/main.h

Self check after the last peer is removed

Github-Pull: #7804
Rebased-From: 2d1d658 0e24bbf
laanwj added a commit to laanwj/bitcoin that referenced this pull request Apr 7, 2016
Now that bitcoin#7804 fixed the timeout handling, reduce the block timeout from
20 minutes to 10 minutes. 20 minutes is overkill.
laanwj added a commit that referenced this pull request Apr 7, 2016
Now that #7804 fixed the timeout handling, reduce the block timeout from
20 minutes to 10 minutes. 20 minutes is overkill.

Conflicts:
	src/main.h

Github-Pull: #7832
Rebased-From: 62b9a55
@sdaftuar
Copy link
Member

post-merge utACK

zander pushed a commit to bitcoinclassic/bitcoinclassic that referenced this pull request May 23, 2016
Now that bitcoin#7804 fixed the timeout handling, reduce the block timeout from
20 minutes to 10 minutes. 20 minutes is overkill.
thokon00 pushed a commit to faircoin/faircoin that referenced this pull request Jun 28, 2016
Currently, we're keeping a timeout for each requested block, starting
from when it is requested, with a correction factor for the number of
blocks in the queue.

That's unnecessarily complicated and inaccurate.

As peers process block requests in order, we can make the timeout for each
block start counting only when all previous ones have been received, and
have a correction based on the number of peers, rather than the total number
of blocks.

Conflicts:
	src/main.cpp
	src/main.h

Self check after the last peer is removed

Github-Pull: bitcoin#7804
Rebased-From: 2d1d658 0e24bbf
thokon00 pushed a commit to faircoin/faircoin that referenced this pull request Jun 28, 2016
Now that bitcoin#7804 fixed the timeout handling, reduce the block timeout from
20 minutes to 10 minutes. 20 minutes is overkill.

Conflicts:
	src/main.h

Github-Pull: bitcoin#7832
Rebased-From: 62b9a55
@@ -212,6 +207,9 @@ namespace {

/** Dirty block file entries. */
set<int> setDirtyFileInfo;

/** Number of peers from which we're downloading blocks. */
int nPeersWithValidatedDownloads = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

why not simply nPeersProvidingBlocks? The use of the word 'validated' seems to imply it does more than the comment states.

}
if (state->vBlocksInFlight.begin() == itInFlight->second.second) {
// First block on the queue was received, update the start download time for the next one
state->nDownloadingSince = std::max(state->nDownloadingSince, GetTimeMicros());
Copy link
Contributor

Choose a reason for hiding this comment

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

When and why would it need to be a date in the future?

@@ -106,6 +106,10 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
static const unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60;
/** Maximum feefilter broadcast delay after significant change. */
static const unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
/** Block download timeout base, expressed in millionths of the block interval (i.e. 20 min) */
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 2000000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 20 minutes?

@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants