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

Conditional logging #75

Open
ollie-etl opened this issue Dec 1, 2023 · 0 comments
Open

Conditional logging #75

ollie-etl opened this issue Dec 1, 2023 · 0 comments

Comments

@ollie-etl
Copy link

Currently, Axis Frames (and presumably the other busses, I don't use them much), has a log statement in like this

self.log.info("TX frame: %s", frame)

However, regardless of log level, the log message is created, which isn't free. I've found that that checking the currently logging level prior to generating the log can lead to 3x sim speed ups. I have many, large data transfers occurring on wide busses.

if self.log.isEnabledFor(logging.DEBUG):
    self.log.debug("TX frame: %s", frame)
elif self.log.isEnabledFor(logging.INFO):
    self.log.info("TX frame: %s", frame.info())

The other improvement is to move the verbose dump into debug level, and provide a summary for info level, which doesn't include the data and tuser fields. I find this makes the logs significantly easier to work with. For instance, the verbose log output of my run will crash my terminal, presumably with out of memory errors, as they easily exceed 100k lines.

I'm happy to PR this, if there is interest and entusiam around this optimisation / API change?

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

No branches or pull requests

1 participant