Skip to content

Conversation

jonatack
Copy link
Member

@jonatack jonatack commented Sep 3, 2021

This patch:

  • updates the logging/timer.h::Timer class to allow not repeating the log message on completion
  • adds a LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE macro that prints the descriptive message when logging the start but not when logging the completion
  • updates the checkaddrman logging to log the duration, and renames the function like the -checkaddrman configuration option in order to prefix every log message with CheckAddrman instead of the longer, less pleasant, and different-from-checkaddrman ForceCheckAddrman (the Doxygen documentation on the function already makes clear that it is unaffected by m_consistency_check_ratio).

before

2021-09-21T18:42:50Z [opencon] Addrman checks started: new 64864, tried 1690, total 66554
2021-09-21T18:42:50Z [opencon] Addrman checks completed successfully

after

2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)

To test, build and run bitcoind with -debug=addrman -checkaddrman=<n> for a value of n in the range of, say, 10 to 40.

@practicalswift
Copy link
Contributor

Concept ACK

2 similar comments
@theStack
Copy link
Contributor

theStack commented Sep 5, 2021

Concept ACK

@laanwj
Copy link
Member

laanwj commented Sep 9, 2021

Concept ACK

@jonatack jonatack force-pushed the improve-checkaddrman-logging branch from 0b2d839 to b3b4a92 Compare September 9, 2021 17:53
@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 11, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@jonatack
Copy link
Member Author

Rebased and updated following the merges of #22734 and #22831.

@@ -91,6 +100,8 @@ class Timer
BCLog::Timer<std::chrono::microseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, log_category)
#define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \
BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, log_category)
#define LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(end_msg, log_category) \
BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, log_category, /* msg_on_completion=*/false)
Copy link
Member

Choose a reason for hiding this comment

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

unrelated idea:

The following log could also be improved with this new macro:

src/validation.cpp:                LogPrintf("[snapshot] flushing coins cache (%.2f MB)... ", /* Continued */

Copy link
Member

Choose a reason for hiding this comment

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

@jonatack Let me know if you want to work on this, otherwise I might pick it up

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Marco, will have a look and comment here.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, thanks for the ping!

Copy link
Member Author

Choose a reason for hiding this comment

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

@jonatack
Copy link
Member Author

Rebased.

that prints the descriptive message when logging the start
but not when logging the completion.
and update the function name to CheckAddrman (drop "Force") for
nicer log output as it is prefixed to each of these log messages:

2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)

The existing Doxygen documentation on the function already makes
clear that it is unaffected by m_consistency_check_ratio.
@jonatack jonatack force-pushed the improve-checkaddrman-logging branch from 1920f63 to 22b44fc Compare October 5, 2021 16:38
@jonatack
Copy link
Member Author

jonatack commented Oct 5, 2021

Rebased!

@laanwj
Copy link
Member

laanwj commented Nov 10, 2021

Code review ACK 22b44fc

2021-11-10T16:20:35Z CheckAddrman: new 9305, tried 322, total 9627 started
2021-11-10T16:20:35Z CheckAddrman: completed (21.53ms)

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Nov 10, 2021
…uration in milliseconds

22b44fc p2p: improve checkaddrman logging with duration in milliseconds (Jon Atack)
ec65bed log, timer: add LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE macro (Jon Atack)
325da75 log, timer: allow not repeating log message on completion (Jon Atack)

Pull request description:

  This patch:
  - updates the `logging/timer.h::Timer` class to allow not repeating the log message on completion
  - adds a `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro that prints the descriptive message when logging the start but not when logging the completion
  - updates the checkaddrman logging to log the duration, and renames the function like the `-checkaddrman` configuration option in order to prefix every log message with `CheckAddrman` instead of the longer, less pleasant, and different-from-checkaddrman `ForceCheckAddrman` (the Doxygen documentation on the function already makes clear that it is unaffected by `m_consistency_check_ratio`).

  before
  ```
  2021-09-21T18:42:50Z [opencon] Addrman checks started: new 64864, tried 1690, total 66554
  2021-09-21T18:42:50Z [opencon] Addrman checks completed successfully
  ```

  after
  ```
  2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
  2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)
  ```

  To test, build and run bitcoind with `-debug=addrman -checkaddrman=<n>` for a value of `n` in the range of, say, 10 to 40.

ACKs for top commit:
  laanwj:
    Code review ACK 22b44fc

Tree-SHA512: 658c0dfaaa9d07092e2418f2d05007c58cc35be6593f22b3c592ce793334a885dd92dacc46bdeddc9d37939cf11174660a094c07c0fa117fbb282953aa45a94d
@maflcko maflcko removed the P2P label Nov 10, 2021
@maflcko
Copy link
Member

maflcko commented Nov 10, 2021

Merged

@maflcko maflcko closed this Nov 10, 2021
@jonatack jonatack deleted the improve-checkaddrman-logging branch November 10, 2021 17:03
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 10, 2021
…in milliseconds

22b44fc p2p: improve checkaddrman logging with duration in milliseconds (Jon Atack)
ec65bed log, timer: add LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE macro (Jon Atack)
325da75 log, timer: allow not repeating log message on completion (Jon Atack)

Pull request description:

  This patch:
  - updates the `logging/timer.h::Timer` class to allow not repeating the log message on completion
  - adds a `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro that prints the descriptive message when logging the start but not when logging the completion
  - updates the checkaddrman logging to log the duration, and renames the function like the `-checkaddrman` configuration option in order to prefix every log message with `CheckAddrman` instead of the longer, less pleasant, and different-from-checkaddrman `ForceCheckAddrman` (the Doxygen documentation on the function already makes clear that it is unaffected by `m_consistency_check_ratio`).

  before
  ```
  2021-09-21T18:42:50Z [opencon] Addrman checks started: new 64864, tried 1690, total 66554
  2021-09-21T18:42:50Z [opencon] Addrman checks completed successfully
  ```

  after
  ```
  2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
  2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)
  ```

  To test, build and run bitcoind with `-debug=addrman -checkaddrman=<n>` for a value of `n` in the range of, say, 10 to 40.

ACKs for top commit:
  laanwj:
    Code review ACK 22b44fc

Tree-SHA512: 658c0dfaaa9d07092e2418f2d05007c58cc35be6593f22b3c592ce793334a885dd92dacc46bdeddc9d37939cf11174660a094c07c0fa117fbb282953aa45a94d
maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Dec 13, 2021
…nstateManager snapshot persistance

50209a4 validation, doc: remove TODO comment (Jon Atack)
8e37fa8 validation, log: improve logging in FlushSnapshotToDisk() (Jon Atack)
271252c validation, log: extract FlushSnapshotToDisk() function (Jon Atack)

Pull request description:

  Use the `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro to improve the logging of ChainstateManager snapshot persistance, log task start and completion separately and no longer manually track the duration, as suggested by Marco Falke in bitcoin/bitcoin#22872 (comment).

  Extract the flushing into one function, which clarifies the logic, extends the improved logging to both flushing call sites, and allows logging the prefix `FlushSnapshotToDisk`, which is similar to `FlushStateToDisk`.

  before
  ```
  [snapshot] flushing coins cache (0 MB)... done (0.00ms)

  [snapshot] flushing snapshot chainstate to disk
  ```
  after
  ```
  FlushSnapshotToDisk: flushing coins cache (0 MB) started
  ...
  FlushSnapshotToDisk: completed (0.00ms)

  FlushSnapshotToDisk: saving snapshot chainstate (0 MB) started
  ...
  FlushSnapshotToDisk: completed (0.00ms)
  ```
  The logging can be observed in the output of
  ```
  ./src/test/test_bitcoin -t validation_chainstate_tests -- DEBUG_LOG_OUT
  ```

Top commit has no ACKs.

Tree-SHA512: 5d954cd8c7455f8625152a43663a237f04717bb834aed62925a56e17c711fca6ccfc03783970b6b0bde44f64617d804b423a7048287c06ee816db36247acf272
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 13, 2021
…nager snapshot persistance

50209a4 validation, doc: remove TODO comment (Jon Atack)
8e37fa8 validation, log: improve logging in FlushSnapshotToDisk() (Jon Atack)
271252c validation, log: extract FlushSnapshotToDisk() function (Jon Atack)

Pull request description:

  Use the `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro to improve the logging of ChainstateManager snapshot persistance, log task start and completion separately and no longer manually track the duration, as suggested by Marco Falke in bitcoin#22872 (comment).

  Extract the flushing into one function, which clarifies the logic, extends the improved logging to both flushing call sites, and allows logging the prefix `FlushSnapshotToDisk`, which is similar to `FlushStateToDisk`.

  before
  ```
  [snapshot] flushing coins cache (0 MB)... done (0.00ms)

  [snapshot] flushing snapshot chainstate to disk
  ```
  after
  ```
  FlushSnapshotToDisk: flushing coins cache (0 MB) started
  ...
  FlushSnapshotToDisk: completed (0.00ms)

  FlushSnapshotToDisk: saving snapshot chainstate (0 MB) started
  ...
  FlushSnapshotToDisk: completed (0.00ms)
  ```
  The logging can be observed in the output of
  ```
  ./src/test/test_bitcoin -t validation_chainstate_tests -- DEBUG_LOG_OUT
  ```

Top commit has no ACKs.

Tree-SHA512: 5d954cd8c7455f8625152a43663a237f04717bb834aed62925a56e17c711fca6ccfc03783970b6b0bde44f64617d804b423a7048287c06ee816db36247acf272
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 11, 2022
Summary:
> log, timer: allow not repeating log message on completion

> log, timer: add LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE macro
>
> that prints the descriptive message when logging the start
> but not when logging the completion.

> p2p: improve checkaddrman logging with duration in milliseconds
>
> and update the function name to CheckAddrman (drop "Force") for
> nicer log output as it is prefixed to each of these log messages:
>
> 2021-09-21T18:42:50Z [opencon] CheckAddrman: new 64864, tried 1690, total 66554 started
> 2021-09-21T18:42:50Z [opencon] CheckAddrman: completed (76.21ms)
>
> The existing Doxygen documentation on the function already makes
> clear that it is unaffected by m_consistency_check_ratio.
>

This is a backport of [[bitcoin/bitcoin#22872 | core#22872]]

Test Plan:
`ninja all check-all`

`src/bitcoind  -debug=addrman -checkaddrman=10`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12469
@bitcoin bitcoin locked and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants