You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Dr Stephen L S Webb (Jira)" <lo...@logging.apache.org> on 2021/12/26 21:16:00 UTC

[jira] [Updated] (LOGCXX-546) Multi threaded applications run at single threaded speed

     [ https://issues.apache.org/jira/browse/LOGCXX-546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dr Stephen L S Webb updated LOGCXX-546:
---------------------------------------
    Description: 
he 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 singl 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. 


  was:
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. 

Logger can 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


> 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
>
> he 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 singl 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)