cocotbext-axi
cocotbext-axi copied to clipboard
Conditional logging
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?