Skip to content

feat: Use spdlog logger#2372

Merged
mathbunnyru merged 12 commits intoXRPLF:developfrom
mathbunnyru:use_spdlog
Aug 11, 2025
Merged

feat: Use spdlog logger#2372
mathbunnyru merged 12 commits intoXRPLF:developfrom
mathbunnyru:use_spdlog

Conversation

@mathbunnyru
Copy link
Collaborator

@mathbunnyru mathbunnyru commented Jul 28, 2025

Fix: #2300

@mathbunnyru mathbunnyru marked this pull request as draft July 28, 2025 20:02
@mathbunnyru mathbunnyru force-pushed the use_spdlog branch 10 times, most recently from 840bf89 to 1a042b2 Compare August 4, 2025 13:16
@mathbunnyru mathbunnyru force-pushed the use_spdlog branch 6 times, most recently from 21d638b to 8fa840f Compare August 6, 2025 14:34
@mathbunnyru mathbunnyru marked this pull request as ready for review August 6, 2025 14:35
@codecov
Copy link

codecov bot commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 68.18182% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.62%. Comparing base (707427c) to head (b401e63).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/util/log/Logger.cpp 65.62% 25 Missing and 8 partials ⚠️
src/main/Main.cpp 0.00% 1 Missing ⚠️
src/util/TerminationHandler.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2372      +/-   ##
===========================================
+ Coverage    79.42%   79.62%   +0.19%     
===========================================
  Files          380      381       +1     
  Lines        15527    15555      +28     
  Branches      7824     7821       -3     
===========================================
+ Hits         12333    12386      +53     
+ Misses        1994     1963      -31     
- Partials      1200     1206       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mathbunnyru mathbunnyru force-pushed the use_spdlog branch 7 times, most recently from e3f2440 to 8ed7b3f Compare August 7, 2025 20:43
@mathbunnyru mathbunnyru force-pushed the use_spdlog branch 2 times, most recently from cbdd949 to 6b728e8 Compare August 8, 2025 11:59
@mathbunnyru
Copy link
Collaborator Author

Logger in Clio

I'm switching from boost::log to spdlog for logging in Clio.

Features (taken from spdlog GitHub)

  • Very fast.
  • Headers only or compiled
  • Feature-rich formatting, using the excellent fmt library.
  • Asynchronous mode (optional)
  • Custom formatting.
  • Multi/Single threaded loggers.
  • Various log targets:
    • Rotating log files.
    • Daily log files.
    • Console logging (colors supported).
    • syslog.
    • Windows event log.
    • Windows debugger (OutputDebugString(..)).
    • Log to Qt widgets.
    • Easily extendable with custom log targets.
  • Log filtering - log levels can be modified at runtime as well as compile time.
  • Support for loading log levels from argv or environment var.
  • Backtrace support - store debug messages in a ring buffer and display them later on demand.

Compile time in Clio

Compiler Library Parsing (frontend) Codegen & opts (backend)
apple-clang spdlog 1533.5 s 1839.0 s
apple-clang boost 1906.2 s 1979.3 s
clang spdlog 5216.3 s 4154.8 s
clang boost 5792.8 s 4056.5 s

bench comparison in Clio

Performance Comparison

Looking at the benchmarks (MessagesPerThread=500k):

  • Threads=1: TotalMessagesRate is 58 times faster on spdlog (737.257k/s vs 12.7956k/s)
  • Threads=2: TotalMessagesRate is 96 times faster on spdlog (1.78737M/s vs 18.6858k/s)
  • Threads=4: TotalMessagesRate is 25 times faster on spdlog (697.663k/s vs 27.5311k/s)
  • Threads=8: TotalMessagesRate is 13 times faster on spdlog (330.32k/s vs 25.0866k/s)

spdlog

Benchmark                                                      Time             CPU   Iterations UserCounters...
----------------------------------------------------------------------------------------------------------------
benchmarkConcurrentFileLogging/1/10000/manual_time          2.69 ms         1168 ms          246 MessagesPerThread=10k Threads=1 TotalMessagesRate=15.1272k/s
benchmarkConcurrentFileLogging/2/10000/manual_time          7.13 ms         1283 ms           95 MessagesPerThread=10k Threads=2 TotalMessagesRate=29.5165k/s
benchmarkConcurrentFileLogging/4/10000/manual_time          43.3 ms         1333 ms           16 MessagesPerThread=10k Threads=4 TotalMessagesRate=57.6788k/s
benchmarkConcurrentFileLogging/8/10000/manual_time           216 ms         1343 ms            3 MessagesPerThread=10k Threads=8 TotalMessagesRate=123.305k/s
benchmarkConcurrentFileLogging/1/100000/manual_time         32.1 ms         1364 ms           20 MessagesPerThread=100k Threads=1 TotalMessagesRate=155.609k/s
benchmarkConcurrentFileLogging/2/100000/manual_time          116 ms         1377 ms            6 MessagesPerThread=100k Threads=2 TotalMessagesRate=287.493k/s
benchmarkConcurrentFileLogging/4/100000/manual_time          518 ms         1381 ms            1 MessagesPerThread=100k Threads=4 TotalMessagesRate=771.698k/s
benchmarkConcurrentFileLogging/8/100000/manual_time         2427 ms         1383 ms            1 MessagesPerThread=100k Threads=8 TotalMessagesRate=329.602k/s
benchmarkConcurrentFileLogging/1/500000/manual_time          170 ms         1389 ms            4 MessagesPerThread=500k Threads=1 TotalMessagesRate=737.257k/s
benchmarkConcurrentFileLogging/2/500000/manual_time          559 ms         1393 ms            1 MessagesPerThread=500k Threads=2 TotalMessagesRate=1.78737M/s
benchmarkConcurrentFileLogging/4/500000/manual_time         2867 ms         1396 ms            1 MessagesPerThread=500k Threads=4 TotalMessagesRate=697.663k/s
benchmarkConcurrentFileLogging/8/500000/manual_time        12109 ms         1400 ms            1 MessagesPerThread=500k Threads=8 TotalMessagesRate=330.32k/s
benchmarkConcurrentFileLogging/1/1000000/manual_time         451 ms         1407 ms            2 MessagesPerThread=1M Threads=1 TotalMessagesRate=1.10966M/s
benchmarkConcurrentFileLogging/2/1000000/manual_time        2139 ms         1415 ms            1 MessagesPerThread=1M Threads=2 TotalMessagesRate=934.844k/s
benchmarkConcurrentFileLogging/4/1000000/manual_time        6635 ms         1419 ms            1 MessagesPerThread=1M Threads=4 TotalMessagesRate=602.884k/s
benchmarkConcurrentFileLogging/8/1000000/manual_time       25187 ms         1422 ms            1 MessagesPerThread=1M Threads=8 TotalMessagesRate=317.624k/s
benchmarkConcurrentFileLogging/1/10000000/manual_time       4088 ms         1425 ms            1 MessagesPerThread=10M Threads=1 TotalMessagesRate=2.44635M/s
benchmarkConcurrentFileLogging/2/10000000/manual_time      11849 ms         1428 ms            1 MessagesPerThread=10M Threads=2 TotalMessagesRate=1.68797M/s
benchmarkConcurrentFileLogging/4/10000000/manual_time      57133 ms         1431 ms            1 MessagesPerThread=10M Threads=4 TotalMessagesRate=700.124k/s
benchmarkConcurrentFileLogging/8/10000000/manual_time     243325 ms         1435 ms            1 MessagesPerThread=10M Threads=8 TotalMessagesRate=328.778k/s

boost::log

Benchmark                                                    Time             CPU   Iterations UserCounters...
--------------------------------------------------------------------------------------------------------------
benchmarkConcurrentFileLogging/1/10000/manual_time         173 ms         1020 ms           10 MessagesPerThread=10k Threads=1 TotalMessagesRate=5.78437k/s
benchmarkConcurrentFileLogging/2/10000/manual_time         554 ms         1023 ms            1 MessagesPerThread=10k Threads=2 TotalMessagesRate=36.086k/s
benchmarkConcurrentFileLogging/4/10000/manual_time         748 ms         1024 ms            1 MessagesPerThread=10k Threads=4 TotalMessagesRate=53.4501k/s
benchmarkConcurrentFileLogging/8/10000/manual_time        1909 ms         1025 ms            1 MessagesPerThread=10k Threads=8 TotalMessagesRate=41.8988k/s
benchmarkConcurrentFileLogging/1/100000/manual_time       5832 ms         1026 ms            1 MessagesPerThread=100k Threads=1 TotalMessagesRate=17.1476k/s
benchmarkConcurrentFileLogging/2/100000/manual_time       8174 ms         1027 ms            1 MessagesPerThread=100k Threads=2 TotalMessagesRate=24.4687k/s
benchmarkConcurrentFileLogging/4/100000/manual_time      10764 ms         1029 ms            1 MessagesPerThread=100k Threads=4 TotalMessagesRate=37.1601k/s
benchmarkConcurrentFileLogging/8/100000/manual_time      23994 ms         1033 ms            1 MessagesPerThread=100k Threads=8 TotalMessagesRate=33.3417k/s
benchmarkConcurrentFileLogging/1/500000/manual_time      39076 ms         1035 ms            1 MessagesPerThread=500k Threads=1 TotalMessagesRate=12.7956k/s
benchmarkConcurrentFileLogging/2/500000/manual_time      53517 ms         1039 ms            1 MessagesPerThread=500k Threads=2 TotalMessagesRate=18.6858k/s
benchmarkConcurrentFileLogging/4/500000/manual_time      72645 ms         1043 ms            1 MessagesPerThread=500k Threads=4 TotalMessagesRate=27.5311k/s
benchmarkConcurrentFileLogging/8/500000/manual_time     159448 ms         1048 ms            1 MessagesPerThread=500k Threads=8 TotalMessagesRate=25.0866k/s

@mathbunnyru mathbunnyru force-pushed the use_spdlog branch 3 times, most recently from e7102e8 to d0bceb5 Compare August 8, 2025 12:47
Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

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

Left some questions and suggestions. Overall this is great and a huge improvement 🙇 :rage1:

@mathbunnyru mathbunnyru requested a review from godexsoft August 11, 2025 10:34
godexsoft
godexsoft previously approved these changes Aug 11, 2025
Copy link
Collaborator

@kuznetsss kuznetsss left a comment

Choose a reason for hiding this comment

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

👍

@mathbunnyru mathbunnyru requested a review from kuznetsss August 11, 2025 16:55
@mathbunnyru mathbunnyru merged commit 9420c50 into XRPLF:develop Aug 11, 2025
63 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try spdlog logger

3 participants