Repository navigation
Conversation
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Contributor
Author
|
I first mentioned this three years ago at #25203 (comment) and had originally included it in #28318 (comment) . This branch was also linked to in #34038 (comment) Obviously conflicts with #35322. |
ajtowns
force-pushed
the
202512-log-atomic
branch
from
May 22, 2026 03:12
b9a62d3 to
10e63db
Compare
This was referenced May 22, 2026
Merged
This was referenced May 30, 2026
Previously, trace logging for a category was enabled by saying "-debug=net -loglevel=net:trace" and saying "-loglevel=net:trace" (without "-debug" or "-debug=net") would silently do nothing. Simplify this so that "-debug=net" enables debug logging for net and "-trace=net" enables both debug and trace logging for net. Note that "-nodebug" and "-notrace" only disable previous "-debug=xxx" and "-trace=yyy" arguments, so "-debug=mempool -trace=net -nodebug" will cancel "-debug=mempool", but will still include both debug and trace logs for net.
Also changes the output format, to distinguish debug/trace levels. Provides `-deprecatedrpc=logging` if old output format is needed. Co-Authored-By: stickies-v <[email protected]>
Since we have reduced how much log levels can be configured (error, warning and info are always logged; and only debug and trace levels can be disabled), we only need two bits per category to store the information. We can do this with two atomic ints, one for whether -debug is enabled, and the other for whether -trace is enabled. This allows `WillLogCategoryLevel` to avoid taking a mutex, potentially allowing for better performance in the event that multiple threads are running many LogDebug(..) statements over categories that do not have -debug enabled (or LogTrace/-trace).
Add m_any_print_callbacks as a cache for !m_print_callbacks.empty(), and make m_buffered atomic. Makes the Log functions almost completely free when logging is completely disabled (though unlike for LogDebug when the category is disabled, arguments are still evaluated).
…gLevel(str, level)
LogCategoriesString and LogLevelsString don't need access to an object, so make them static.
Simplifies the util/log.h API so that log enablement does not require indirection and `ShouldDebugLog` and `ShouldTraceLog` can be fully inlined at logging call sites. The category bitmasks become constinit atomic globals, so any usage is valid from any context, including dynamic initialization of other static variables, and avoids any dependency on the exact implementation of `util::log::Log()`. The redundant `BCLog::Logger::Should*Log` functions are removed.
ajtowns
force-pushed
the
202512-log-atomic
branch
from
October 23, 2026 07:46
10e63db to
36586ec
Compare
This was referenced Oct 28, 2026
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Followup of #28318, #34038, and #34806 to simplify and optimize the logging-disabled path for
LogTrace().Removes the global log level (
m_log_level) and the unordered_map from category to level (m_category_log_levels) in favour of a singleatomic<uint64_t> m_trace_categories, and reducesShouldDebugLogandShouldTraceLogto lock-free checks on a single atomic. Also makesEnabled()lock-free, to waste a little less time in the case where debugging is completely disabled.Does a bit of clean up as well:
m_file_pathand provides accessors