Track block download times per individual block #7804

pull sipa wants to merge 2 commits into bitcoin:master from sipa:betterkicktimeout changing 2 files +40 −31
  1. sipa commented at 8:23 PM on April 3, 2016: member

    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.

  2. btcdrak commented at 8:44 PM on April 3, 2016: contributor

    Concept ACK

  3. laanwj added the label P2P on Apr 4, 2016
  4. sipa force-pushed on Apr 4, 2016
  5. sipa commented at 12:34 PM on April 4, 2016: member

    Updated to add a simple self consistency check.

  6. in src/main.cpp:None in 5bc71fc345 outdated
    5844 | -            if (queuedBlock.nTimeDisconnect > nTimeoutIfRequestedNow) {
    5845 | -                LogPrint("net", "Reducing block download timeout for peer=%d block=%s, orig=%d new=%d\n", pto->id, queuedBlock.hash.ToString(), queuedBlock.nTimeDisconnect, nTimeoutIfRequestedNow);
    5846 | -                queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
    5847 | -            }
    5848 | -            if (queuedBlock.nTimeDisconnect < nNow) {
    5849 | +            if (nNow > state.nDownloadingSince + 500000 * consensusParams.nPowTargetSpacing * (4 + nPeersWithValidatedDownloads)) {
    


    dcousens commented at 12:55 AM on April 5, 2016:
    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.

  7. in src/main.cpp:None in 5bc71fc345 outdated
     194 | @@ -195,15 +195,10 @@ namespace {
     195 |      struct QueuedBlock {
     196 |          uint256 hash;
     197 |          CBlockIndex *pindex;  //! Optional.
     198 | -        int64_t nTime;  //! Time of "getdata" request in microseconds.
    


    MarcoFalke commented at 5:20 PM on April 5, 2016:

    Needs merge conflict solved in this line, I guess.

  8. sipa force-pushed on Apr 6, 2016
  9. sipa commented at 3:47 PM on April 6, 2016: member

    Rebased, and introduced constants for the timeouts.

  10. dcousens commented at 3:11 AM on April 7, 2016: contributor

    utACK b18c125

  11. gmaxwell commented at 9:14 AM on April 7, 2016: contributor

    Seems like an obvious improvement. Concept ACK.

  12. Track block download times per individual block
    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.
    2d1d6581ec
  13. Self check after the last peer is removed 0e24bbf679
  14. in src/main.h:None in b18c1259b7 outdated
     105 | @@ -106,6 +106,10 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
     106 |  static const unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60;
     107 |  /** Maximum feefilter broadcast delay after significant change. */
     108 |  static const unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
     109 | +/** Block download timeout base, expressed in millionths of the block interval */
     110 | +static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 2000000;
    


    paveljanik commented at 9:24 AM on April 7, 2016:

    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.


    sipa commented at 10:13 AM on April 7, 2016:

    Added the actual clock times to the comment.

  15. sipa force-pushed on Apr 7, 2016
  16. laanwj merged this on Apr 7, 2016
  17. laanwj closed this on Apr 7, 2016

  18. laanwj referenced this in commit 1ddf0cee67 on Apr 7, 2016
  19. laanwj commented at 11:07 AM on April 7, 2016: member

    utACK 0e24bbf

  20. laanwj referenced this in commit 90f1d246d3 on Apr 7, 2016
  21. laanwj referenced this in commit 00bb3322db on Apr 7, 2016
  22. laanwj referenced this in commit 62b9a557fc on Apr 7, 2016
  23. laanwj referenced this in commit 4c3a00d35c on Apr 7, 2016
  24. sdaftuar commented at 3:58 PM on April 11, 2016: member

    post-merge utACK

  25. zander referenced this in commit c7dfbadd2e on May 23, 2016
  26. makevoid referenced this in commit 6d660de957 on Jun 13, 2016
  27. thokon00 referenced this in commit d0478ee740 on Jun 28, 2016
  28. thokon00 referenced this in commit e96b534ca1 on Jun 28, 2016
  29. nomnombtc referenced this in commit 3251c27e51 on Nov 11, 2016
  30. nomnombtc referenced this in commit 0f096b5db3 on Nov 11, 2016
  31. in src/main.cpp:None in 0e24bbf679
     206 | @@ -212,6 +207,9 @@ namespace {
     207 |  
     208 |      /** Dirty block file entries. */
     209 |      set<int> setDirtyFileInfo;
     210 | +
     211 | +    /** Number of peers from which we're downloading blocks. */
     212 | +    int nPeersWithValidatedDownloads = 0;
    


    rebroad commented at 3:27 AM on December 7, 2016:

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

  32. in src/main.cpp:None in 0e24bbf679
     359 | +            // Last validated block on the queue was received.
     360 | +            nPeersWithValidatedDownloads--;
     361 | +        }
     362 | +        if (state->vBlocksInFlight.begin() == itInFlight->second.second) {
     363 | +            // First block on the queue was received, update the start download time for the next one
     364 | +            state->nDownloadingSince = std::max(state->nDownloadingSince, GetTimeMicros());
    


    rebroad commented at 3:31 AM on December 7, 2016:

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

  33. in src/main.h:None in 0e24bbf679
     105 | @@ -106,6 +106,10 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
     106 |  static const unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60;
     107 |  /** Maximum feefilter broadcast delay after significant change. */
     108 |  static const unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
     109 | +/** Block download timeout base, expressed in millionths of the block interval (i.e. 20 min) */
     110 | +static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 2000000;
    


    rebroad commented at 3:38 AM on December 7, 2016:

    Why 20 minutes?

  34. MarkLTZ referenced this in commit 65034b9220 on Apr 28, 2019
  35. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me