Repository navigation
Call conversion functions directly - #10
Conversation
| if(WIN32) | ||
| target_link_libraries(${_target_name_lib} "${_pkg_base}/Lib/${_pkg_filename}.lib") | ||
| else() | ||
| target_link_libraries(${_target_name_lib} "${_pkg_base}/lib/lib${_pkg_filename}.so") |
There was a problem hiding this comment.
On macos the generated libraries have the .dylib extension and not .so. This seems to be the reason it fails to build
mikaelarguedas
left a comment
There was a problem hiding this comment.
thanks @martins-mozeiko got the improvement!
The code looks good to me overall, there are 2 main things to fixup before rerunning CI:
- library extension for macos
- generate a single "*_python" library per package
More details below
| add_dependencies( | ||
| ${_target_name_lib} | ||
| ${rosidl_generate_interfaces_TARGET}${_target_suffix} | ||
| ${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c |
There was a problem hiding this comment.
Is the dependency on the typesupport_c lib needed for the new libraries?
There was a problem hiding this comment.
Along the same lines, if we don't need to depend on specific typesupport, we may also be able to generate a single _python_ library instead of 1 per typesupport
There was a problem hiding this comment.
Ok I gave that a shot at 7fbb832 and it seems to work fine with a single python library per package
| # define IMPORT_API __declspec(dllimport) | ||
| #else | ||
| # define IMPORT_API | ||
| #endif |
There was a problem hiding this comment.
As a header containing visibility macros in included on the next line (#include <rosidl_generator_c/visibility_control.h>), I'd recommend using the macros deinfed in that file instead of redefining new ones here.
The same logic could be applied to the other template below
|
@martins-mozeiko Is there any update in this? |
This makes generated convert to and from function to call C functions direclty instead of going through Python capsule API. Conversion functions are placed in separate libraries that link to each other. Python module libraries links to these new libraries. See #9 for more details.
|
I've added changes requested - now it uses dylib extension on macOS (I have not Mac available currently, so I cannot test it), and it uses visibility macros from I've also integrated changes from Mikael and rebased all commits on top of master. Tried building & running demo_nodes_py talker/listener - it works fine on Windows & Linux. |
Code has been updated, needs new review
|
Thanks @martins-mozeiko for iterating.
It looks like this change fails the linter tests on CI, you should be able to test the changes by running I pushed some fixups:
With fixups (remainung rcl test failure expected and tracked at ros2/rmw_fastrtps#226): |
I didnt get a chance to test the performances improvements either. Do you happen to have more data in that matter? |
|
Change looks good to me 👍 @dirk-thomas do you want to provide a second review on this ? or should I merge as is ? |
dirk-thomas
left a comment
There was a problem hiding this comment.
Beside the one comment about naming the new functions I think it would be good to reproduce the performance impact (since that is the whole reason for this patch).
I agree that having numbers regarding the performance improvement would be valuable. However, I think we agree that the new approach is cleaner / preferable to the current one regardless of the exact measured performance gain.
I agree that would be are better naming pattern. Though this PR doesn't change the function names that are already implemented using this scheme. I am fine renaming them in here but would not be opposed in doing it in a follow-up as it's not strictly in the scope of this PR |
|
Renamed the functions in 18d2af1 |
|
@martins-mozeiko when you get a chance, can you please test the latest state of this PR and provide feedback on the (hopefully) time improvements compared to master? |
|
I'll try to do make some comparison. The issue is that difference is mostly visible only on weaker platforms like Pi. On powerful desktop I don't remember if I saw significant change (but I can recheck). And building for Pi using system we have here takes 4+ hours (arm qemu in docker). And I need to do two builds with and without patch. Also builds we have works only for ardent, I'll need to check how can I upgrade it to bouncy & colcon. So it'll take a while, but I'll look into it next week. |
|
I've made a following test - publisher sends geometry_msgs/PoseArray messages pretty much as fast as it can. And subscribe counts how long does it take to receive 100 messages. Here is publisher.py code: And here is subscriber.py code: Running this on Raspberry Pi 3 with ROS2 built from master gives me ~63 seconds. After applying this pull request the time decreases to ~37 seconds. |
|
Thanks @martins-mozeiko for testing and the example 👍 Tried a similar thing on amd64 with a few changes:
Without this patch With this patch: Codesender.py: receiver.py: Not as drastic as what is observed on the RaspberryPi but there is definitely an improvement |
|
Thanks @martins-mozeiko for the patch 👍 |
This makes generated convert to and from function to call C functions directly instead of going through Python capsule API - that currently requires importing module, which can lead to a lot of imports for nested types in array. Now conversion functions are placed in separate libraries that link to each other. Python module libraries link to these new libraries.
See #9 for more details.
Sorry, I cannot provide any specific performance numbers right now, I can try to do that a bit later.
I have tested this change on Ubuntu 16 and Windows.
Connects to #9