-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: debug enable addrman consistency checks #27300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
Though, I haven't checked how expensive those checks are. If they make the program unusable slow, I can see that someone would Nack this being on by default.
What about mempool checks?
src/addrman.h
Outdated
#ifdef DEBUG_ADDRMAN | ||
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{1}; | ||
#else | ||
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef DEBUG_ADDRMAN | |
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{1}; | |
#else | |
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0}; | |
#endif | |
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{ | |
#ifdef DEBUG_ADDRMAN | |
1 | |
#else | |
0 | |
#endif | |
}; |
style nit (feel free to ignore, if you don't like it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK - I've run with -checkaddrman=1
before, never found bitcoind to be unusably slow. Not sure about the mempool checks though.
Generally speaking, I think it's a bit strange that --enable-debug
mixes two different concepts:
1.) Compiler flags for attaching a debugger
2.) More (but costly) runtime checks (like -DDEBUG_LOCKORDER
currently, plus additionally custom checks for addrman / mempool etc.)
I don't think it's very common that people would want both 1 and 2 at the same time:
If I want to attach a debugger for better analysis of a specific part of the code, I'm not interested in checks for unrelated parts - if I want to run with more checks to find possible unknown bugs, I'm not interested in attaching a debugger.
So why do we have one flag for the two?
Maybe there can be a |
@mzumsande FYI this PR is equivalent to running with For me this manifests as saturating an entire core via a combination of the I have not profiled with perf as it is so obvious in top. I also agree that there are two debug scenarios (which are already mixed) being further mixed by this PR, i) enabling debugging symbols and ii) running the application in "debug mode". In a vacuum I would agree with @MarcoFalke in introducing an |
src/addrman.h
Outdated
@@ -27,7 +27,11 @@ class InvalidAddrManVersionError : public std::ios_base::failure | |||
class AddrManImpl; | |||
|
|||
/** Default for -checkaddrman */ | |||
#ifdef DEBUG_ADDRMAN | |||
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these checks are going to be enabled by default on some builds, shouldn't the default be much higher; eg 100 or 1000? Doing it on every call is useful for live debugging or small scale tests, but seems overkill for a node's runtime default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree, the performance hit is too much for any kind of normal operation.
I updated the branch with @MarcoFalke's suggestion along with a new debug option (which I called --enable-debug-checks
, and not --debug-slow
).
I'll run a few runtime tests on various values for the checks to see if I can find a sweet spot for the frequency, then update the doc commit and push an update here.
61e3f8a
to
7b32641
Compare
OK pushed an update based on feedback here, in #24709 and #27586.
|
When configured with --enable-debug run addrman consistency checks every 1000 operations by default. Running every 1000 operations minimises the CPU overhead on the node and keeps it viable to run a node in debug mode on mainnet.
When configured with --enable-debug run mempool consistency checks every 1000 operations by default.
7b32641
to
9c2f4ca
Compare
Is this still relevant, given that the issue was closed? |
Nope, I also agree with the conclusions from AJ in 24709 about just setting this as a runtime option, so will close this. |
The
--enable-debug
flag should default to enabling debug consistency checks. This PR enables addrman and mempool consistency checks at a rate of once per 1000 operations, by default when running in debug mode.To opt out of the checks when running a debug build specify the runtime
-checkmempool=0
and-checkaddrman=0
debug options, as described in developer-notes.mdOn my machine, configuring these checks to run every 1000 operations saw them run no more than once per minute (and often much less frequently), which did not introduce any significant overhead.
This PR does not include a
-checkblockindex
default consistency check for mainnet when running in debug mode.fixes #24709