Closed caguero closed 3 months ago
Not blocking, but a comment on why std::copy
may be slow: perhaps the type being copied is not trivially copiable? In theory this can be tested via a static_assert
with std::is_trivially_copyable
(that in theory may be a good thing to check even before using memcpy
).
CI seems to be broken on the ros2
branch. I'll be taking a look tomorrow.
https://github.com/Mergifyio backport jazzy
backport jazzy
🦟 Optimization
Summary
While testing ros <-> gz communication using the bridge I noticed that the bridge was talking quite a bit of time copying images from Gazebo to ROS. I found that the
std::copy
operation that we're doing is substantially slower than thememcpy
alternative. I think that in principle this shouldn't happen but the numbers are quite clear. Perhapsstd::copy
is doing something that doesn't use cache effectively...How to test it?
First, modify this code to see some stats:
Recompile and launch one of our examples that publish 320x240 images:
The default code shows:
Enable the
memcpy
, comment the old code and relaunch the example again. The new code shows:Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.