mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-25 00:42:27 +00:00
easylogging++: faster access to logging
Turns out getting the global shared_ptr hits the profile, and passing it around still keeps it at close to ~1% CPU, which is too much for mostly silent logging. Leak the object instead, which is even safer for late logging.
This commit is contained in:
parent
7cc27b367e
commit
721aacd88e
3 changed files with 19 additions and 2 deletions
|
@ -17,3 +17,12 @@
|
||||||
fun:maybe_unlock_and_signal_one<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >
|
fun:maybe_unlock_and_signal_one<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
we leak the logger, for performance reasons in on-the-fly init
|
||||||
|
Memcheck:Leak
|
||||||
|
match-leak-kinds: definite
|
||||||
|
fun:_Znwm
|
||||||
|
fun:_ZN2el4base7Storage7getELPPEv
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
6
external/easylogging++/easylogging++.cc
vendored
6
external/easylogging++/easylogging++.cc
vendored
|
@ -2191,6 +2191,12 @@ void VRegistry::setFromArgs(const base::utils::CommandLineArgs* commandLineArgs)
|
||||||
# define ELPP_DEFAULT_LOGGING_FLAGS 0x0
|
# define ELPP_DEFAULT_LOGGING_FLAGS 0x0
|
||||||
#endif // !defined(ELPP_DEFAULT_LOGGING_FLAGS)
|
#endif // !defined(ELPP_DEFAULT_LOGGING_FLAGS)
|
||||||
// Storage
|
// Storage
|
||||||
|
el::base::type::StoragePointer &el::base::Storage::getELPP()
|
||||||
|
{
|
||||||
|
if (!el::base::elStorage)
|
||||||
|
el::base::elStorage = new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()));
|
||||||
|
return el::base::elStorage;
|
||||||
|
}
|
||||||
#if ELPP_ASYNC_LOGGING
|
#if ELPP_ASYNC_LOGGING
|
||||||
Storage::Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker) :
|
Storage::Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker) :
|
||||||
#else
|
#else
|
||||||
|
|
6
external/easylogging++/easylogging++.h
vendored
6
external/easylogging++/easylogging++.h
vendored
|
@ -552,7 +552,7 @@ typedef std::ostream ostream_t;
|
||||||
typedef unsigned int EnumType;
|
typedef unsigned int EnumType;
|
||||||
typedef unsigned short VerboseLevel;
|
typedef unsigned short VerboseLevel;
|
||||||
typedef unsigned long int LineNumber;
|
typedef unsigned long int LineNumber;
|
||||||
typedef std::shared_ptr<base::Storage> StoragePointer;
|
typedef base::Storage *StoragePointer;
|
||||||
typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
|
typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
|
||||||
typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
|
typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
|
||||||
typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
|
typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
|
||||||
|
@ -2734,6 +2734,8 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static el::base::type::StoragePointer &getELPP();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
base::RegisteredHitCounters* m_registeredHitCounters;
|
base::RegisteredHitCounters* m_registeredHitCounters;
|
||||||
base::RegisteredLoggers* m_registeredLoggers;
|
base::RegisteredLoggers* m_registeredLoggers;
|
||||||
|
@ -2768,7 +2770,7 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
extern ELPP_EXPORT base::type::StoragePointer elStorage;
|
extern ELPP_EXPORT base::type::StoragePointer elStorage;
|
||||||
#define ELPP el::base::elStorage
|
#define ELPP el::base::Storage::getELPP()
|
||||||
class DefaultLogDispatchCallback : public LogDispatchCallback {
|
class DefaultLogDispatchCallback : public LogDispatchCallback {
|
||||||
protected:
|
protected:
|
||||||
void handle(const LogDispatchData* data);
|
void handle(const LogDispatchData* data);
|
||||||
|
|
Loading…
Reference in a new issue