Add log output during initial header sync #15615

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2019/03/hdr_sync changing 1 files +6 −0
  1. jonasschnelli commented at 7:00 PM on March 17, 2019: contributor

    The non debug log output is completely quiet during the header sync. I see two main reasons to add infos about the state of the initial header sync...

    • users may think the node did fail to start sync
    • it's a little complicate to check if your getting throttled during header sync (repeatedly calling getchaintips or similar)
  2. jonasschnelli added the label Utils/log/libs on Mar 17, 2019
  3. in src/validation.cpp:3438 in 736e6de6a5 outdated
    3434 | @@ -3435,6 +3435,9 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
    3435 |          }
    3436 |      }
    3437 |      NotifyHeaderTip();
    3438 | +    if (IsInitialBlockDownload() && *ppindex && pindexBestHeader) {
    


    MarcoFalke commented at 7:25 PM on March 17, 2019:

    ppindex is nullptr for some calls


    promag commented at 7:25 PM on March 17, 2019:

    Isn't cs_main required for pindexBestHeader?


    jonasschnelli commented at 7:46 PM on March 17, 2019:

    Hhhmp.. fixed.


    jonasschnelli commented at 7:46 PM on March 17, 2019:

    Fixed.

  4. jonasschnelli force-pushed on Mar 17, 2019
  5. jonasschnelli force-pushed on Mar 17, 2019
  6. promag commented at 11:52 PM on March 17, 2019: member

    Tested ACK 4e74875. Sample output with -testnet:

    2019-03-17T23:49:45Z Synchronizing blockheaders, height: 1153998 (~92.96%)
    2019-03-17T23:49:45Z more getheaders (1153998) to end to peer=0 (startheight:1485065)
    2019-03-17T23:49:45Z sending getheaders (1061 bytes) peer=0
    2019-03-17T23:49:45Z received: headers (162003 bytes) peer=0
    2019-03-17T23:49:45Z Synchronizing blockheaders, height: 1155998 (~93.13%)
    2019-03-17T23:49:45Z more getheaders (1155998) to end to peer=0 (startheight:1485065)
    2019-03-17T23:49:45Z sending getheaders (1061 bytes) peer=0
    2019-03-17T23:49:46Z received: headers (162003 bytes) peer=0
    2019-03-17T23:49:46Z Synchronizing blockheaders, height: 1157998 (~93.23%)
    2019-03-17T23:49:46Z more getheaders (1157998) to end to peer=0 (startheight:1485065)
    2019-03-17T23:49:46Z sending getheaders (1061 bytes) peer=0
    2019-03-17T23:49:46Z received: headers (162003 bytes) peer=0
    2019-03-17T23:49:46Z Synchronizing blockheaders, height: 1159998 (~93.25%)
    2019-03-17T23:49:46Z more getheaders (1159998) to end to peer=0 (startheight:1485065)
    2019-03-17T23:49:46Z sending getheaders (1061 bytes) peer=0
    2019-03-17T23:49:46Z received: headers (162003 bytes) peer=0
    2019-03-17T23:49:46Z Synchronizing blockheaders, height: 1161998 (~93.26%)
    2019-03-17T23:49:46Z more getheaders (1161998) to end to peer=0 (startheight:1485065)
    2019-03-17T23:49:46Z sending getheaders (1061 bytes) peer=0
    2019-03-17T23:49:46Z received: headers (162003 bytes) peer=0
    2019-03-17T23:49:46Z Synchronizing blockheaders, height: 1163998 (~93.27%)
    2019-03-17T23:49:46Z more getheaders (1163998) to end to peer=0 (startheight:1485065)
    
  7. practicalswift commented at 10:31 AM on March 18, 2019: contributor

    Can we find a way to make it so that the non-debug output is non-quiet but not spammy?

    I'm afraid the total number of logged lines would be substantial if merged as is. This in turn would educe the signal-to-noise ratio and reduce the value of the log.

    Logging too much to the non-debug log is almost as bad as logging too little :-)

  8. jonasschnelli commented at 10:54 AM on March 18, 2019: contributor

    Can we find a way to make it so that the non-debug output is non-quiet but not spammy?

    I don't think its spammy... At current height, it logs around 284 lines for the header sync... seems acceptable compared to >567000 lines from UpdateTip during IBD.

  9. practicalswift commented at 10:57 AM on March 18, 2019: contributor

    @jonasschnelli I'm not very fond of the UpdateTip logging during IBD either :-)

    Can you think of a smart way to reduce the number of logged lines while achieving the stated goals?

    Let's not forget that this is the logging meeting a first-time bitcoind user: let's give a nice first usability impression :-)

  10. in src/validation.cpp:3333 in 4e748752d7 outdated
    3434 | @@ -3435,6 +3435,12 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
    3435 |          }
    3436 |      }
    3437 |      NotifyHeaderTip();
    3438 | +    {
    3439 | +        LOCK(cs_main);
    3440 | +        if (IsInitialBlockDownload() && ppindex && *ppindex && pindexBestHeader) {
    3441 | +            LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
    


    practicalswift commented at 1:16 PM on March 21, 2019:
                static int last_logged_block_header_height = 0;
                if (last_logged_block_header_height == 0 || (*ppindex)->nHeight - last_logged_block_header_height >= 100000) {
                    LogPrintf("Synchronizing block headers: height=%d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
                    last_logged_block_header_height = (*ppindex)->nHeight;
                }
    

    promag commented at 1:27 PM on March 21, 2019:

    Why?


    practicalswift commented at 1:59 PM on March 21, 2019:

    @promag See previous discussion in this PR regarding user-friendly logging.


    promag commented at 11:10 AM on March 24, 2019:

    These are logs and come at a good pace, I'd merge this as it is.

  11. practicalswift changes_requested
  12. in src/validation.cpp:3440 in 4e748752d7 outdated
    3434 | @@ -3435,6 +3435,12 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
    3435 |          }
    3436 |      }
    3437 |      NotifyHeaderTip();
    3438 | +    {
    3439 | +        LOCK(cs_main);
    3440 | +        if (IsInitialBlockDownload() && ppindex && *ppindex && pindexBestHeader) {
    


    MarcoFalke commented at 2:32 PM on March 24, 2019:

    Could add a comment why you are checking for pindexBestHeader, which is unused below.


    jonasschnelli commented at 6:31 PM on May 9, 2019:

    It's a relict and not necessary. Removed it just now.

  13. sipa commented at 11:37 PM on March 25, 2019: member

    Let's not forget that this is the logging meeting a first-time bitcoind user: let's give a nice first usability impression

    It's called a debug log. I don't think the criterion to optimize for is usability, but a tradeoff between disk usage and ability to diagnose problems (by an expert user or developer).

  14. practicalswift commented at 9:06 AM on March 26, 2019: contributor

    @sipa Clarification: When talking about usability I was referring the "write to standard output for immediate consumption" aspect of LogPrintf(…) and not the "write to debug.log on disk for later consumption" aspect.

    Generally I think we print too much debug information to standard output resulting in a low signal-to-noise ratio for the end-user invoking bitcoind.

    Perhaps this could be solved by having two different log levels for LogPrintf where both log levels get written to debug.log but only the higher log level gets written to standard output.

  15. jonasschnelli force-pushed on May 9, 2019
  16. laanwj commented at 2:24 PM on June 13, 2019: member

    Concept ACK, I think it's better to log something. Could add logic to log only every so many %, but this is a good start.

    It does fail to build here, might need rebase for recent changes:

    /.../bitcoin/src/validation.cpp: In function ‘bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>&, CValidationState&, const CChainParams&, const CBlockIndex**, CBlockHeader*)’:
    /.../bitcoin/src/validation.cpp:3332:13: error: ‘IsInitialBlockDownload’ was not declared in this scope
             if (IsInitialBlockDownload() && ppindex && *ppindex) {
                 ^~~~~~~~~~~~~~~~~~~~~~
    
  17. Add log output during initial header sync d75e704ac0
  18. jonasschnelli force-pushed on Jun 13, 2019
  19. jonasschnelli commented at 2:39 PM on June 13, 2019: contributor

    Thanks @laanwj! Fixed.

  20. fanquake commented at 7:46 AM on June 14, 2019: member

    Concept ACK https://github.com/bitcoin/bitcoin/pull/15615/commits/d75e704ac08fb43320e3ebcdde0d2a5392fdec9f

    Agree with @sipa:

    It's called a debug log. I don't think the criterion to optimize for is usability, but a tradeoff between disk usage and ability to diagnose problems (by an expert user or developer).

    Tested on top of master (7524376a81a1955f4da4adb23005f2122b18a270) using -testnet -debug=net:

    143:2019-06-14T07:28:12Z Synchronizing blockheaders, height: 2000 (~0.54%)
    159:2019-06-14T07:28:13Z Synchronizing blockheaders, height: 4000 (~1.07%)
    167:2019-06-14T07:28:14Z Synchronizing blockheaders, height: 6000 (~1.59%)
    194:2019-06-14T07:28:15Z Synchronizing blockheaders, height: 8000 (~2.11%)
    201:2019-06-14T07:28:15Z Synchronizing blockheaders, height: 10000 (~2.63%)
    206:2019-06-14T07:28:16Z Synchronizing blockheaders, height: 12000 (~3.14%)
    213:2019-06-14T07:28:16Z Synchronizing blockheaders, height: 14000 (~3.64%)
    231:2019-06-14T07:28:17Z Synchronizing blockheaders, height: 16000 (~4.17%)
    248:2019-06-14T07:28:17Z Synchronizing blockheaders, height: 18000 (~4.75%)
    273:2019-06-14T07:28:18Z Synchronizing blockheaders, height: 20000 (~5.27%)
    ......
    1239:2019-06-14T07:28:55Z Synchronizing blockheaders, height: 268000 (~50.83%)
    1243:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 254000 (~48.93%)
    1247:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 260000 (~49.57%)
    1251:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 258000 (~49.34%)
    1255:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 270000 (~51.15%)
    1259:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 270000 (~51.15%)
    1263:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 258000 (~49.34%)
    1267:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 256000 (~49.13%)
    1271:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 258000 (~49.34%)
    1275:2019-06-14T07:28:56Z Synchronizing blockheaders, height: 272000 (~51.57%)
    ......
    350831:2019-06-14T07:34:51Z Synchronizing blockheaders, height: 1532000 (~99.94%)
    352022:2019-06-14T07:34:51Z Synchronizing blockheaders, height: 1534000 (~99.94%)
    353240:2019-06-14T07:34:52Z Synchronizing blockheaders, height: 1536000 (~99.94%)
    354471:2019-06-14T07:34:53Z Synchronizing blockheaders, height: 1538000 (~99.94%)
    355709:2019-06-14T07:34:53Z Synchronizing blockheaders, height: 1540000 (~99.95%)
    357365:2019-06-14T07:34:54Z Synchronizing blockheaders, height: 1542000 (~99.97%)
    358206:2019-06-14T07:34:55Z Synchronizing blockheaders, height: 1543389 (~100.00%)
    609974:2019-06-14T07:37:43Z Synchronizing blockheaders, height: 1543389 (~100.00%)
    

    The full debug.log grep for Synchronizing blockheaders is available here.

  21. practicalswift commented at 9:09 AM on June 14, 2019: contributor

    @fanquake

    Again: the problem is not what we're writing to disk. The problem is that this will also be written to standard output.

    I'm afraid such verbose logging will flood the console and effectively hide any important non- blockheaders issues.

    I'm not convinced this will be a net win if merged as is: sure, we'll have plenty of information about any blockheaders issue at the cost of very low signal-to-noise for all other issues.

    I agree that it is problematic that we're completely quiet during the header sync, but I'm not at all convinced that the only sane alternative to the status quo is the other extreme: to flood everything we know about it :-)

  22. jonasschnelli commented at 10:43 AM on June 14, 2019: contributor

    @practicalswift: We are speaking around 280 lines mainly happening once before the initial IBD (later probably due to falling out of sync, but much less lines). I don't think this is noise rather it's a great help to figure out what's going on in general and if you are slowed down during a single-peer header sync.

  23. practicalswift commented at 12:56 PM on June 14, 2019: contributor

    @jonasschnelli Sorry: my last comment was written under the incorrect assumption that the number of lines that would be printed was ~5000 judging from @fanquake's posted gist. I read the output as 5000 lines written at a speed of 10 lines/second during the first ten minutes of operation. I now understand that this is incorrect :-)

    I guess 280 lines is a bit more than I'd like personally but it is way better than the 5000 lines I thought. Anyways I understand that the consensus opinion is to go with current version, so I won't argue further. Let's go with this and tweak later if necessary :-)

    utACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f

  24. laanwj approved
  25. laanwj commented at 1:47 PM on August 29, 2019: member

    Tested ACK d75e704ac08fb43320e3ebcdde0d2a5392fdec9f

  26. laanwj referenced this in commit 1f8378508a on Aug 29, 2019
  27. laanwj merged this on Aug 29, 2019
  28. laanwj closed this on Aug 29, 2019

  29. sidhujag referenced this in commit 5ff5f9455f on Aug 29, 2019
  30. MarcoFalke referenced this in commit 8e00a68552 on Sep 3, 2019
  31. sidhujag referenced this in commit b3459434c9 on Sep 3, 2019
  32. jasonbcox referenced this in commit 526bdd96cf on Sep 28, 2020
  33. jasonbcox referenced this in commit 8a397ebe78 on Sep 30, 2020
  34. PastaPastaPasta referenced this in commit 0a4bba0401 on Jun 27, 2021
  35. PastaPastaPasta referenced this in commit 5fb8f405e2 on Jun 28, 2021
  36. PastaPastaPasta referenced this in commit 11c4d3e0e0 on Jun 29, 2021
  37. PastaPastaPasta referenced this in commit 3f75bd9732 on Sep 11, 2021
  38. PastaPastaPasta referenced this in commit d3d43ff019 on Sep 11, 2021
  39. PastaPastaPasta referenced this in commit 81c331bd09 on Sep 12, 2021
  40. PastaPastaPasta referenced this in commit 7f6b214a27 on Sep 12, 2021
  41. kittywhiskers referenced this in commit 55c9535ffd on Nov 3, 2021
  42. humbleDasher referenced this in commit 07af856ef1 on Nov 13, 2021
  43. humbleDasher referenced this in commit 2996f593ef on Nov 13, 2021
  44. pravblockc referenced this in commit a9abebcfa0 on Nov 18, 2021
  45. pravblockc referenced this in commit 0b4f279949 on Nov 18, 2021
  46. DrahtBot locked this on Dec 16, 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 15:15 UTC

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