[ 
https://issues.apache.org/jira/browse/LOGCXX-546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17465460#comment-17465460
 ] 

Dr Stephen L S Webb commented on LOGCXX-546:
--------------------------------------------

The results from throughput showing the problem (disabled rate for each of 
multiple threads should be close to the single thread rate) are:

Benchmarking library only(no writing out):
**************************************************************
Benchmarking Single threaded: 1000000 messages
**************************************************************
Log4cxx NoFormat pattern: %m%n Elapsed: 0.9181 secs 1,089,168/sec
Log4cxx DateOnly pattern: [%d] %m%n Elapsed: 0.8941 secs 1,118,448/sec
Log4cxx DateClassLevel pattern: [%d] [%c] [%p] %m%n Elapsed: 0.8908 secs 
1,122,597/sec
Log4cxx Logging with FMT Elapsed: 0.4779 secs 2,092,464/sec
Log4cxx Logging static string Elapsed: 0.4279 secs 2,337,184/sec
Log4cxx Logging static string with FMT Elapsed: 0.4834 secs 2,068,577/sec
Log4cxx Logging disabled debug Elapsed: 0.04615 secs 21,670,312/sec
Log4cxx Logging disabled trace Elapsed: 0.04780 secs 20,921,870/sec
Log4cxx Logging enabled debug Elapsed: 0.4301 secs 2,325,013/sec
Log4cxx Logging enabled trace Elapsed: 0.4288 secs 2,332,359/sec
**************************************************************
Benchmarking multithreaded threaded: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging with FMT MT Elapsed: 2.869 secs 348,524/sec
Log4cxx Logging with FMT MT Elapsed: 2.937 secs 340,445/sec
Log4cxx Logging with FMT MT Elapsed: 2.956 secs 338,264/sec
Log4cxx Logging with FMT MT Elapsed: 2.968 secs 336,947/sec
**************************************************************
Benchmarking multithreaded disabled: 1000000 messages/thread, 4 threads
**************************************************************
Log4cxx Logging disabled MT Elapsed: 0.3615 secs 2,766,610/sec
Log4cxx Logging disabled MT Elapsed: 0.3884 secs 2,574,516/sec
Log4cxx Logging disabled MT Elapsed: 0.4346 secs 2,300,853/sec
Log4cxx Logging disabled MT Elapsed: 0.4362 secs 2,292,636/sec


> Multi threaded applications run at single threaded speed
> --------------------------------------------------------
>
>                 Key: LOGCXX-546
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-546
>             Project: Log4cxx
>          Issue Type: Bug
>    Affects Versions: 0.12.0
>            Reporter: Dr Stephen L S Webb
>            Priority: Major
>
> The benchmark https://github.com/apache/logging-log4cxx/pull/87 shows the 
> rate of log4cxx calls to a disabled logger is greatly reduced when multiple 
> threads are active.
> In version 11.0 the call rate to a disabled logger when multiple threads are 
> active is similar to when only a single thread is active.
> Accessing repository using rep = repository.lock() in Logger::isDisabled() 
> causes all threads to be serialized when they test if their logger is enabled.
> I suggest Hierarchy hold std::weak_ptr for the Loggers instead of 
> std::shared_ptr in LoggerMap and for the root logger. 
> Options:
> 1. Logger could hold a raw pointer to the LoggerRepository. The 
> LoggerRepository destructor should then do
> {code:java}
> for (auto& item : this->loggers)
> {
>   if (auto pLogger = item.second.lock())
>     pLogger->resetRepository();
> }{code}
> Logger can then test for a NULL repositiory instead of lock() on the weak 
> pointer.
> 2. Logger could hold a shared pointer to the LoggerRepository. 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to