-
Notifications
You must be signed in to change notification settings - Fork 279
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
Use snprintf instead of stringstream to increase performance of lookupTransform() in error cases. #470
Conversation
…pTransform() in error cases.
Here's my rationale from a node that processes lots of laserscans which are quite fresh so they often need some time before their transform gets into the cache. This is a flamegraph where I circled all calls to Merging #469 could help a bit with this as most of the internal |
* Revert "rework Eigen functions namespace hack" (ros#436) * Fixed warnings in message_filter.h (ros#434) the variables are not used in function body and caused -Wunused-parameter to trigger with -Wall * Fix ambiguous call for tf2::convert on MSVC (ros#444) * rework ambiguous call on MSVC. Co-authored-by: Tully Foote <[email protected]> Co-authored-by: moooeeeep <[email protected]> Co-authored-by: Sean Yen <[email protected]>
Replaces the deprecated names {tf_frames, view_frames} -> tf2_frames
…n it in canTransform(). (ros#469)
Co-authored-by: Tully Foote <[email protected]>
…into peci1-speedup_lookuptransform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for filling this in. I have merged it with the upstream changes to make the message a little more verbose. Just waiting for CI
Manually rebased and merged in 52bff88 |
For some reason, the stringstream construction of tf2 exception messages is much slower than snprintf().
In some cases, there may be lots of these messages generated, thus I think it makes sense to save time here.
A simple substitution of the stringstream approach with snprintf brings a two- to three-fold speedup for the error cases.
Speed test with the additions from #469 (the updated speed_test is not included in this PR, but I used it to measure the performance gain):
noetic-devel:
This patch:
There's one change that might be reverted if needed - the removal if
<sstream>
include from time_cache.h. It was just no longer needed for tf2, so I removed it, but if you think it'd be an API break, it can be put back.There should also be discussion on the string length limit in buffer_core. I chose 1000. Whatever else can be used. I also tried a solution with dynamic allocation of memory for the string, but it looked ugly (but the performance was nearly the same).