Skip to content

Commit 118b55c

Browse files
committed
Merge bitcoin/bitcoin#30790: bench: Remove redundant logging benchmarks
fadbcd5 bench: Remove redundant logging benchmarks (MarcoFalke) fa8dd95 bench: Use LogInfo instead of the deprecated alias LogPrintf (MarcoFalke) Pull request description: `LogPrint*ThreadNames` is redundant with `LogWith(out)ThreadNames`, because they all measure toggling the thread names (and check that it has no effect on performance). Fix it by removing the redundant ones. This also allows to drop a deprecated logging alias. ACKs for top commit: stickies-v: ACK fadbcd5 Tree-SHA512: 4fe137f374aa4ee1aa0e1da4a1f9839c0e52c23dbb93198ecafee98de39d311cc47304bba4191f3807aa00c51b1eae543e3f270f03d341c84910e5e341a1d475
2 parents c0cbe26 + fadbcd5 commit 118b55c

File tree

4 files changed

+7
-41
lines changed

4 files changed

+7
-41
lines changed

src/bench/logging.cpp

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ static void Logging(benchmark::Bench& bench, const std::vector<const char*>& ext
2828
bench.run([&] { log(); });
2929
}
3030

31-
static void LogPrintLevelWithThreadNames(benchmark::Bench& bench)
32-
{
33-
Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] {
34-
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
35-
}
36-
37-
static void LogPrintLevelWithoutThreadNames(benchmark::Bench& bench)
38-
{
39-
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] {
40-
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "%s\n", "test"); });
41-
}
42-
4331
static void LogWithDebug(benchmark::Bench& bench)
4432
{
4533
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
@@ -50,45 +38,27 @@ static void LogWithoutDebug(benchmark::Bench& bench)
5038
Logging(bench, {"-logthreadnames=0", "-debug=0"}, [] { LogDebug(BCLog::NET, "%s\n", "test"); });
5139
}
5240

53-
static void LogPrintfCategoryWithThreadNames(benchmark::Bench& bench)
54-
{
55-
Logging(bench, {"-logthreadnames=1", "-debug=net"}, [] {
56-
LogPrintfCategory(BCLog::NET, "%s\n", "test");
57-
});
58-
}
59-
60-
static void LogPrintfCategoryWithoutThreadNames(benchmark::Bench& bench)
61-
{
62-
Logging(bench, {"-logthreadnames=0", "-debug=net"}, [] {
63-
LogPrintfCategory(BCLog::NET, "%s\n", "test");
64-
});
65-
}
66-
67-
static void LogPrintfWithThreadNames(benchmark::Bench& bench)
41+
static void LogWithThreadNames(benchmark::Bench& bench)
6842
{
69-
Logging(bench, {"-logthreadnames=1"}, [] { LogPrintf("%s\n", "test"); });
43+
Logging(bench, {"-logthreadnames=1"}, [] { LogInfo("%s\n", "test"); });
7044
}
7145

72-
static void LogPrintfWithoutThreadNames(benchmark::Bench& bench)
46+
static void LogWithoutThreadNames(benchmark::Bench& bench)
7347
{
74-
Logging(bench, {"-logthreadnames=0"}, [] { LogPrintf("%s\n", "test"); });
48+
Logging(bench, {"-logthreadnames=0"}, [] { LogInfo("%s\n", "test"); });
7549
}
7650

7751
static void LogWithoutWriteToFile(benchmark::Bench& bench)
7852
{
7953
// Disable writing the log to a file, as used for unit tests and fuzzing in `MakeNoLogFileContext`.
8054
Logging(bench, {"-nodebuglogfile", "-debug=1"}, [] {
81-
LogPrintf("%s\n", "test");
55+
LogInfo("%s\n", "test");
8256
LogDebug(BCLog::NET, "%s\n", "test");
8357
});
8458
}
8559

86-
BENCHMARK(LogPrintLevelWithThreadNames, benchmark::PriorityLevel::HIGH);
87-
BENCHMARK(LogPrintLevelWithoutThreadNames, benchmark::PriorityLevel::HIGH);
8860
BENCHMARK(LogWithDebug, benchmark::PriorityLevel::HIGH);
8961
BENCHMARK(LogWithoutDebug, benchmark::PriorityLevel::HIGH);
90-
BENCHMARK(LogPrintfCategoryWithThreadNames, benchmark::PriorityLevel::HIGH);
91-
BENCHMARK(LogPrintfCategoryWithoutThreadNames, benchmark::PriorityLevel::HIGH);
92-
BENCHMARK(LogPrintfWithThreadNames, benchmark::PriorityLevel::HIGH);
93-
BENCHMARK(LogPrintfWithoutThreadNames, benchmark::PriorityLevel::HIGH);
62+
BENCHMARK(LogWithThreadNames, benchmark::PriorityLevel::HIGH);
63+
BENCHMARK(LogWithoutThreadNames, benchmark::PriorityLevel::HIGH);
9464
BENCHMARK(LogWithoutWriteToFile, benchmark::PriorityLevel::HIGH);

src/logging.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ static inline void LogPrintf_(std::string_view logging_function, std::string_vie
273273

274274
// Deprecated unconditional logging.
275275
#define LogPrintf(...) LogInfo(__VA_ARGS__)
276-
#define LogPrintfCategory(category, ...) LogPrintLevel_(category, BCLog::Level::Info, __VA_ARGS__)
277276

278277
// Use a macro instead of a function for conditional logging to prevent
279278
// evaluating arguments when logging for the category is not enabled.

src/test/logging_tests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
116116
LogPrintLevel(BCLog::NET, BCLog::Level::Info, "foo8: %s\n", "bar8");
117117
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "foo9: %s\n", "bar9");
118118
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "foo10: %s\n", "bar10");
119-
LogPrintfCategory(BCLog::VALIDATION, "foo11: %s\n", "bar11");
120119
std::ifstream file{tmp_log_path};
121120
std::vector<std::string> log_lines;
122121
for (std::string log; std::getline(file, log);) {
@@ -128,7 +127,6 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacrosDeprecated, LogSetup)
128127
"[net:info] foo8: bar8",
129128
"[net:warning] foo9: bar9",
130129
"[net:error] foo10: bar10",
131-
"[validation:info] foo11: bar11",
132130
};
133131
BOOST_CHECK_EQUAL_COLLECTIONS(log_lines.begin(), log_lines.end(), expected.begin(), expected.end());
134132
}

test/lint/lint-format-strings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
'LogDebug,1',
2727
'LogTrace,1',
2828
'LogPrintf,0',
29-
'LogPrintfCategory,1',
3029
'LogPrintLevel,2',
3130
'printf,0',
3231
'snprintf,2',

0 commit comments

Comments
 (0)