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

easylogging++: faster access to logging #4840

Merged
merged 2 commits into from
Dec 12, 2018

Conversation

moneromooo-monero
Copy link
Collaborator

If someone has a better patch, feel free.

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now leaks a global base::Storage object (elStorage). This exists for the lifetime of the system anyway - intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

{
return getresetELPP(false);
if (!el::base::elStorage)
el::base::elStorage = new el::base::Storage(el::LogBuilderPtr(new el::base::DefaultLogBuilder()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The construction of this variable is no longer thread-safe. Do all the apps call a log function before starting threads? Is that an acceptable risk? Accessing the thread-safe atomic (the implicit static init bool) should be fairly quick since its read-only after construction (thus no cache destruction).

The logger has many other slow-downs worth looking at, the number of cycles here should be low compared to those other issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least one log is called rom a static object ctor (crypto::null_skey -> mlock -> get_page_size), so efore starting threads.
"allowed" is still showing a bit on the profile, I suspect just the locking, but that's still acceptable now. getresetELPP was just > 2%, whch seemed outrageous.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on a static object to be constructed is problematic - the process could be linked without the crypto lib. Additionally, I hope to provide a patch that removes that log before main because it is impossible to disable logging to console (useful for the light wallet server admin process which can be used by python apps or bash scripts etc).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW - this probably won't cause a problem, but I'm not sure how helpful the 2% in the profile is in this case - there are log statements everywhere so this function is going to get skewed due to all of those calls. How much on aggregate do some of these functions with log statements perform now? It should be a fairly small increase overall.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you're asking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're asking "is it slow because it's called a lot", then yes.

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.
Copy link
Contributor

@fluffypony fluffypony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

@fluffypony fluffypony merged commit 721aacd into monero-project:master Dec 12, 2018
fluffypony added a commit that referenced this pull request Dec 12, 2018
721aacd easylogging++: faster access to logging (moneromooo-monero)
7cc27b3 Revert "easylogging++: make the logger handle early/late logging" (moneromooo-monero)
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.

3 participants