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

LOGCXX-546] Prevent serialization of a multi-threaded application #94

Merged

Conversation

swebb2066
Copy link
Contributor

@swebb2066 swebb2066 commented Jan 1, 2022

when using disabled logging statements.

throughputtests output after applying these changes:

**************************************************************
Benchmarking Single threaded: 1000000 messages
**************************************************************
Log4cxx NoFormat pattern: %m%n Elapsed: 4.866 secs 205,516/sec
Log4cxx DateOnly pattern: [%d] %m%n Elapsed: 4.875 secs 205,130/sec
Log4cxx DateClassLevel pattern: [%d] [%c] [%p] %m%n Elapsed: 4.898 secs 204,167/sec
Log4cxx Logging with FMT Elapsed: 2.437 secs 410,320/sec
Log4cxx Logging static string Elapsed: 3.409 secs 293,331/sec
Log4cxx Logging static string with FMT Elapsed: 2.759 secs 362,386/sec
Log4cxx Logging disabled debug Elapsed: 0.1323 secs 7,558,764/sec
Log4cxx Logging disabled trace Elapsed: 0.1336 secs 7,486,832/sec
Log4cxx Logging enabled debug Elapsed: 3.463 secs 288,802/sec
Log4cxx Logging enabled trace Elapsed: 3.463 secs 288,729/sec
**************************************************************
Benchmarking multithreaded threaded: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging with FMT MT Elapsed: 4.469 secs 223,767/sec
Log4cxx Logging with FMT MT Elapsed: 4.512 secs 221,653/sec
Log4cxx Logging with FMT MT Elapsed: 4.578 secs 218,420/sec
Log4cxx Logging with FMT MT Elapsed: 4.583 secs 218,199/sec
**************************************************************
Benchmarking multithreaded disabled: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging disabled MT Elapsed: 0.1453 secs 6,883,621/sec
Log4cxx Logging disabled MT Elapsed: 0.1457 secs 6,862,385/sec
Log4cxx Logging disabled MT Elapsed: 0.1458 secs 6,860,196/sec
Log4cxx Logging disabled MT Elapsed: 0.1459 secs 6,855,386/sec

@swebb2066
Copy link
Contributor Author

To determine the cost of Logger holding a weak pointer instead of a raw pointer as in this PR, I experimently changed m_priv->repository to a std::weak_ptr. The result shows calls to isDisabled() from multiple threads are some what serialized. The per thread throughput is less half the single thread throughput.

throughputtests output with Logger holding a weak pointer:

Benchmarking library only(no writing out):
**************************************************************
Benchmarking Single threaded: 1000000 messages
**************************************************************
Log4cxx NoFormat pattern: %m%n Elapsed: 5.001 secs 199,972/sec
Log4cxx DateOnly pattern: [%d] %m%n Elapsed: 5 secs 200,001/sec
Log4cxx DateClassLevel pattern: [%d] [%c] [%p] %m%n Elapsed: 5.01 secs 199,591/sec
Log4cxx Logging with FMT Elapsed: 2.576 secs 388,129/sec
Log4cxx Logging static string Elapsed: 3.279 secs 304,998/sec
Log4cxx Logging static string with FMT Elapsed: 2.807 secs 356,189/sec
Log4cxx Logging disabled debug Elapsed: 0.1941 secs 5,152,795/sec
Log4cxx Logging disabled trace Elapsed: 0.1938 secs 5,159,546/sec
Log4cxx Logging enabled debug Elapsed: 3.322 secs 301,064/sec
Log4cxx Logging enabled trace Elapsed: 3.295 secs 303,469/sec
**************************************************************
Benchmarking multithreaded threaded: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging with FMT MT Elapsed: 4.526 secs 220,932/sec
Log4cxx Logging with FMT MT Elapsed: 4.553 secs 219,640/sec
Log4cxx Logging with FMT MT Elapsed: 4.708 secs 212,424/sec
Log4cxx Logging with FMT MT Elapsed: 4.727 secs 211,554/sec
**************************************************************
Benchmarking multithreaded disabled: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging disabled MT Elapsed: 0.4405 secs 2,270,056/sec
Log4cxx Logging disabled MT Elapsed: 0.4408 secs 2,268,693/sec
Log4cxx Logging disabled MT Elapsed: 0.4505 secs 2,219,599/sec
Log4cxx Logging disabled MT Elapsed: 0.4569 secs 2,188,823/sec

And LOGCXX-322 is still a problem.

@swebb2066
Copy link
Contributor Author

I believe this also fixes https://issues.apache.org/jira/browse/LOGCXX-532

@swebb2066 swebb2066 merged commit 7981fab into apache:next_stable Jan 2, 2022
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