ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
189 stars 275 forks source link

BufferCore wastes time in canTransform() creating error message that is never used #468

Open peci1 opened 4 years ago

peci1 commented 4 years ago

extrapolation_error_string https://github.com/ros/geometry2/blob/035522926403613d6f04f148cb18cc64d2544c19/tf2/src/buffer_core.cpp#L361

is only read when error_string is non-null: https://github.com/ros/geometry2/blob/035522926403613d6f04f148cb18cc64d2544c19/tf2/src/buffer_core.cpp#L461-L466

However, even when error_string is null, pointer to extrapolation_error_string is still passed to gather(), which means the stringstream operations are performed no matter what the value of error_string is.

And the string operations aren't exactly cheap (this is a flamegraph from a profiler, x axis is total time accumulated over all calls to the function):

Snímek obrazovky pořízený 2020-06-18 15-35-40

peci1 commented 4 years ago

Okay, this simple case is solved by #469. But there's also a great performance loss due to the error string construction in lookupTransform where you can't choose to not construct the strings. I'm just thinking about an interface that would allow to tell that the user is not interested in the error string, but just in the exception type...