Add -maxblocksintransit: tunable per-peer block-download window
The per-peer in-flight block window (MAX_BLOCKS_IN_TRANSIT_PER_PEER) was a hardcoded 16. On a single, high-latency peer during IBD the transfer is bandwidth-delay-product bound (window / RTT), so with tiny sub-checkpoint blocks the window, not bandwidth, is the ceiling — measured ~4x throughput going 16 -> 64 on a 350ms-RTT peer. Make it a runtime flag (default 16, clamped 1..4096), logged at startup. No behavior change at the default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1439,6 +1439,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
else if (nRandomXVerifyThreads > MAX_SCRIPTCHECK_THREADS)
|
||||
nRandomXVerifyThreads = MAX_SCRIPTCHECK_THREADS;
|
||||
|
||||
// Per-peer block-download window (see MAX_BLOCKS_IN_TRANSIT_PER_PEER). Raising this lifts
|
||||
// the bandwidth-delay-product ceiling on high-latency peers during IBD. Clamp to a sane range.
|
||||
MAX_BLOCKS_IN_TRANSIT_PER_PEER = GetArg("-maxblocksintransit", DEFAULT_MAX_BLOCKS_IN_TRANSIT_PER_PEER);
|
||||
if (MAX_BLOCKS_IN_TRANSIT_PER_PEER < 1)
|
||||
MAX_BLOCKS_IN_TRANSIT_PER_PEER = 1;
|
||||
else if (MAX_BLOCKS_IN_TRANSIT_PER_PEER > 4096)
|
||||
MAX_BLOCKS_IN_TRANSIT_PER_PEER = 4096;
|
||||
LogPrintf("Per-peer max blocks in transit: %d\n", MAX_BLOCKS_IN_TRANSIT_PER_PEER);
|
||||
|
||||
fServer = GetBoolArg("-server", false);
|
||||
//fprintf(stderr,"%s tik6\n", __FUNCTION__);
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ static int64_t nTimeBestReceived = 0;
|
||||
CWaitableCriticalSection csBestBlock;
|
||||
CConditionVariable cvBlockChange;
|
||||
int nScriptCheckThreads = 0;
|
||||
int MAX_BLOCKS_IN_TRANSIT_PER_PEER = DEFAULT_MAX_BLOCKS_IN_TRANSIT_PER_PEER;
|
||||
int nRandomXVerifyThreads = 0; // parallel RandomX pre-verification worker count (0 = inline only)
|
||||
bool fExperimentalMode = true;
|
||||
bool fImporting = false;
|
||||
|
||||
@@ -95,8 +95,13 @@ static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
|
||||
static const int MAX_SCRIPTCHECK_THREADS = 16;
|
||||
/** -par default (number of script-checking threads, 0 = auto) */
|
||||
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
|
||||
/** Number of blocks that can be requested at any given time from a single peer. */
|
||||
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
|
||||
/** Number of blocks that can be requested at any given time from a single peer.
|
||||
* Runtime-tunable via -maxblocksintransit. The default of 16 caps single-peer IBD
|
||||
* throughput at (window / RTT): on a high-latency peer with tiny (sub-checkpoint)
|
||||
* blocks the transfer is bandwidth-delay-product bound, so a larger window lifts the
|
||||
* ceiling at negligible bandwidth cost. */
|
||||
static const int DEFAULT_MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
|
||||
extern int MAX_BLOCKS_IN_TRANSIT_PER_PEER;
|
||||
/** Timeout in seconds during which a peer must stall block download progress before being disconnected. */
|
||||
static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
|
||||
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
|
||||
|
||||
Reference in New Issue
Block a user