HomePhabricator

log, sync: add LOCK logging category, apply it to lock contention

Description

log, sync: add LOCK logging category, apply it to lock contention

Summary:
This diff:

  • adds a LOCK logging category if DEBUG_LOCKCONTENTION is defined at compilation.
  • adds a timing macro in microseconds, LOG_TIME_MICROS_WITH_CATEGORY
  • updates BCLog::LogMsg() to omit irrelevant decimals for microseconds and skip unneeded code and math.
  • improves the lock contention logging, drops the all-caps, and displays the duration in microseconds
  • makes unexpected time type in BCLog::LogMsg() a compile-time error
  • add a paragraph of documentation to developer-notes.md

Lock contention logging in checkqueue_tests is disabled, as some of these tests are designed to be heavily contested to trigger race conditions or other issues. This created very large log files when run with DEBUG_LOCKCONTENTION defined.

This is a backport of core#22736, core#22904, core#23223 and core#24770

The first pull request implements the lock category, the other pull requests are important follow-ups (mixed with minor refactorings) fixing various regressions (bugs and suspected performance issues).

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
Co-authored-by: Martin Ankerl <martin.ankerl@gmail.com>

Test Plan:
ninja all check-all

Follow the instructions in the new documentation and check that the logging works:

cmake .. -GNinja -DCMAKE_CXX_FLAGS="-DDEBUG_LOCKCONTENTION"
ninja
src/bitcoind -h | grep -A8 "debug=<category>"
src/bitcoind -debug=lock

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Subscribers: sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D12049

Details

Provenance
Jon Atack <jon@atack.com>Authored on Aug 18 2021, 10:29
PiRKCommitted on Sep 28 2022, 06:04
PiRKPushed on Sep 28 2022, 06:04
Reviewer
Restricted Project
Differential Revision
D12049: log, sync: add LOCK logging category, apply it to lock contention
Parents
rABCca33e0ea0971: test: Fix intermittent issue in p2p_feefilter
Branches
Unknown
Tags
Unknown