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:
moneromooo-monero
2018-11-11 21:34:37 +00:00
parent 7cc27b367e
commit 721aacd88e
3 changed files with 19 additions and 2 deletions
+4 -2
View File
@@ -552,7 +552,7 @@ typedef std::ostream ostream_t;
typedef unsigned int EnumType;
typedef unsigned short VerboseLevel;
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<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
typedef std::shared_ptr<LoggerRegistrationCallback> LoggerRegistrationCallbackPtr;
@@ -2734,6 +2734,8 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
return it->second;
}
static el::base::type::StoragePointer &getELPP();
private:
base::RegisteredHitCounters* m_registeredHitCounters;
base::RegisteredLoggers* m_registeredLoggers;
@@ -2768,7 +2770,7 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
}
};
extern ELPP_EXPORT base::type::StoragePointer elStorage;
#define ELPP el::base::elStorage
#define ELPP el::base::Storage::getELPP()
class DefaultLogDispatchCallback : public LogDispatchCallback {
protected:
void handle(const LogDispatchData* data);