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

runtime: logging performance improvement #4982

Merged
merged 1 commit into from Aug 7, 2021

Conversation

willcode
Copy link
Member

@willcode willcode commented Aug 5, 2021

Based on email discussion with Boris Marjanovic.

Logging is being overhauled on master branch, so this is being introduced directly to maint-3.9.

The logging macros always pass the "msg" param to the logger (currently
log4cpp). In the macros, "msg" can be an expression and it will be
evaluated, even if the log message would not be printed (based on log
level).

This commit adds checks to each macro to check whether the message will be
logged. Since this check is also done internally to log4cpp, some
duplication results, but it should be far less effort than evaluating
an arbitrary "msg".

Signed-off-by: Jeff Long willcode4@gmail.com

Based on email discussion with Boris Marjanovic.

The logging macros always pass the "msg" param to the logger (currently
log4cpp). In the macros, "msg" can be an expression and it will be
evaluated, even if the log message would not be printed (based on log
level).

This commit adds checks to each macro to make sure the message will be
logged. Since this check is also done internally to log4cpp, some
duplication results, but it should be far less effort than evaluating
an arbitrary "msg".

Signed-off-by: Jeff Long <willcode4@gmail.com>
Copy link

@bmarjanovic bmarjanovic left a comment

Choose a reason for hiding this comment

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

The changes look good. The new macros have been working correctly for me.
A possible (separate from this) improvement to show assert message on command line (cerr). That would require additional macro - something like

#ifdef NDEBUG
# define assertm(exp, msg)  ((void)(0))
#else
# define assertm(exp, msg)                \
  if (!exp) {                                          \
    std::cerr << "Assertion: " << msg;  \
    assert(exp);                                     \
  }                                  
#endif

@willcode willcode marked this pull request as ready for review August 7, 2021 02:04
Copy link
Contributor

@mormj mormj left a comment

Choose a reason for hiding this comment

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

LGTM

@willcode willcode merged commit 3757167 into gnuradio:maint-3.9 Aug 7, 2021
@willcode willcode deleted the log-performance branch August 7, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants