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

Add if check before calculating strings for log_debug #3963

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

adamkewley
Copy link
Contributor

@adamkewley adamkewley commented Nov 12, 2024

Fixes issue N/A

Noticed that debug logging takes a bit of CPU during assembly - even if the log is disabled. Turns out, it's because log_debug etc. aren't macros and, therefore, fully evaluate all arguments before forwarding to the logger. If the logger doesn't need to sink the resulting message, then the evaluation is wasted.

Brief summary of changes

  • Check if the log level is Debug before computing quantities that may appear in a debug log message

Testing I've completed

  • None

Looking for feedback on...

CHANGELOG.md (choose one)

  • no need to update because tiny change

This change is Reviewable

Copy link
Member

@nickbianco nickbianco left a comment

Choose a reason for hiding this comment

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

:lgtm:

Good find @adamkewley! Ideally these log statements would be more computationally transparent, but not sure how to make that happen without converting them to macros as you suggested.

@nickbianco nickbianco merged commit d24c451 into main Nov 12, 2024
12 checks passed
@nickbianco nickbianco deleted the fix_dont-debug-log-unless-necessary branch November 12, 2024 18:10
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.

2 participants