Skip to content
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

Improve throughput when using disabled logging statements #88

Closed
wants to merge 1 commit into from

Conversation

swebb2066
Copy link
Contributor

@swebb2066 swebb2066 commented Dec 27, 2021

Change the pointer to the Hierarchy from a std::weak_ptr to a raw pointer to avoid the lock() in Logger::isDisabled() functions.

Also disconnects the Logger from the Hierarchy when the Hierarchy is destroyed.

throughputtests output using these changes:

**************************************************************
Benchmarking Single threaded: 1000000 messages
**************************************************************
Log4cxx NoFormat pattern: %m%n Elapsed: 2.557 secs 391,157/sec
Log4cxx DateOnly pattern: [%d] %m%n Elapsed: 2.552 secs 391,836/sec
Log4cxx DateClassLevel pattern: [%d] [%c] [%p] %m%n Elapsed: 2.572 secs 388,729/sec
Log4cxx Logging with FMT Elapsed: 1.909 secs 523,721/sec
Log4cxx Logging static string Elapsed: 2.062 secs 485,083/sec
Log4cxx Logging static string with FMT Elapsed: 2.096 secs 476,990/sec
Log4cxx Logging disabled debug Elapsed: 0.08675 secs 11,527,275/sec
Log4cxx Logging disabled trace Elapsed: 0.08727 secs 11,459,057/sec
Log4cxx Logging enabled debug Elapsed: 2.059 secs 485,615/sec
Log4cxx Logging enabled trace Elapsed: 2.098 secs 476,611/sec
**************************************************************
Benchmarking multithreaded threaded: 1000000 messages/thread, 4 threads
**************************************************************
log4cxx: No appender could be found for logger (bench_logger).
log4cxx: Please initialize the log4cxx system properly.
Log4cxx Logging with FMT MT Elapsed: 3.734 secs 267,813/sec
Log4cxx Logging with FMT MT Elapsed: 3.739 secs 267,426/sec
Log4cxx Logging with FMT MT Elapsed: 3.759 secs 266,043/sec
Log4cxx Logging with FMT MT Elapsed: 3.762 secs 265,849/sec
**************************************************************
Benchmarking multithreaded disabled: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging disabled MT Elapsed: 0.2366 secs 4,227,422/sec
Log4cxx Logging disabled MT Elapsed: 0.2459 secs 4,066,714/sec
Log4cxx Logging disabled MT Elapsed: 0.2496 secs 4,006,421/sec
Log4cxx Logging disabled MT Elapsed: 0.2552 secs 3,918,440/sec

throughputtests output prior to these changes:

**************************************************************
Benchmarking Single threaded: 1000000 messages
**************************************************************
Log4cxx NoFormat pattern: %m%n Elapsed: 2.828 secs 353,625/sec
Log4cxx DateOnly pattern: [%d] %m%n Elapsed: 2.767 secs 361,350/sec
Log4cxx DateClassLevel pattern: [%d] [%c] [%p] %m%n Elapsed: 2.81 secs 355,882/sec
Log4cxx Logging with FMT Elapsed: 2.088 secs 478,949/sec
Log4cxx Logging static string Elapsed: 2.217 secs 451,045/sec
Log4cxx Logging static string with FMT Elapsed: 2.302 secs 434,344/sec
Log4cxx Logging disabled debug Elapsed: 0.1867 secs 5,357,277/sec
Log4cxx Logging disabled trace Elapsed: 0.186 secs 5,375,506/sec
Log4cxx Logging enabled debug Elapsed: 2.261 secs 442,245/sec
Log4cxx Logging enabled trace Elapsed: 2.263 secs 441,886/sec
**************************************************************
Benchmarking multithreaded threaded: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging with FMT MT Elapsed: 4.097 secs 244,063/sec
Log4cxx Logging with FMT MT Elapsed: 4.105 secs 243,617/sec
Log4cxx Logging with FMT MT Elapsed: 4.132 secs 242,014/sec
Log4cxx Logging with FMT MT Elapsed: 4.132 secs 242,005/sec
**************************************************************
Benchmarking multithreaded disabled: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging disabled MT Elapsed: 0.6538 secs 1,529,611/sec
Log4cxx Logging disabled MT Elapsed: 0.6681 secs 1,496,778/sec
Log4cxx Logging disabled MT Elapsed: 0.6699 secs 1,492,832/sec
Log4cxx Logging disabled MT Elapsed: 0.6702 secs 1,492,142/sec

@swebb2066
Copy link
Contributor Author

Superceded by #90

@swebb2066 swebb2066 deleted the disabled_throughput_fix branch January 2, 2022 22:12
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.

None yet

2 participants