Late evaluation support for logging in the CEA-608 parser.#4939
Late evaluation support for logging in the CEA-608 parser.#4939
Conversation
This helps reduce CPU time spent parsing 608 captions.
|
@itsjamie hiw does this reduce cpu load? When you say it delays evaluation what does it mean? It seems like this is just passing call site one place down but it is not lazily evaluated in next io loop as far as I can understand. |
This saves CPU load because we don't need to actually calculate the log message if the verbosity level would mean it would never be printed to the console. By directly calling the function normally, and passing the string into the log message call, we need to generate that string every invocation rather than when it is actually needed to be printed.
So, I think on memory usage we only come out positive because the strings are relatively large. Correct that an even better implementation would be a singular bound function rather than an inline definition at each log call, because then we would pay for a single function definition. |
|
Thanks @itsjamie, this makes sense. |
|
Absolutely, removing logs from the actual build makes a lot of sense. But given it was a large impact, and an easy fix in this one particular case, I felt it was a decent contribution that could help everyone that is using the built distributable directly :) |
This PR will...
Reduce CPU time on low-powered devices where these logging calls were taking up a measurable amount of time in the overall profile.
~14.1% of time in a profile spanning multiple segment downloads was spent in
getDisplayedTexton a Samsung Tizen TV.Are there any points in the code the reviewer needs to double check?
Standard review.
I tried to limit the changes to the exact calls that would have the highest impact, so anything that required computation to calculate. I left ones that were just constructing new strings alone, because a deeper analysis on string heap collection versus dangling function references would need to be done to know which led to better performance, and ensure no leaks were introduced.
Checklist