Skip to content

Commit 2e852fa

Browse files
authored
Improve the performance of rcutils_logging_format_message. (#372)
In particular, the g_rcutils_logging_output_format_string can't really change after initialization time, so we don't need to reparse it every time. Instead, parse it once at the beginning and just maintain an array of callbacks to call to fill in the information as each log message comes in. In my testing, this reduces the cost of calling rcutils_logging_format_message by about 50% in all cases, from very short format strings to very long ones. Format strings with many, many token substitutions are still very inefficient. That's because once we go beyond the fixed 2048 buffer limit and start allocating memory, we only allocate small chunks of memory at a time. However, this won't come up in most normal situations (including the default format message), so we ignore this performance problem for now. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
1 parent c1623e7 commit 2e852fa

File tree

1 file changed

+381
-223
lines changed

1 file changed

+381
-223
lines changed

0 commit comments

Comments
 (0)