Skip to content
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

Cache disable flag to avoid reading environmental variable. #1029

Merged
merged 6 commits into from
Feb 27, 2023

Conversation

fujitatomoya
Copy link
Collaborator

address #977

Signed-off-by: Tomoya Fujita Tomoya.Fujita@sony.com

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya
Copy link
Collaborator Author

@clalancette minor performance improvement. this can avoid reading environmental variable every time it publishes data with using LoanedMessage.

CC: @MichaelOrlov would be interested for you, as performance improvement.

rcl/src/rcl/publisher.c Outdated Show resolved Hide resolved
rcl/include/rcl/publisher.h Outdated Show resolved Hide resolved
This reverts commit 2ed9454.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya
Copy link
Collaborator Author

@clalancette requesting 2nd review, modification for test code is bigger than fix itself...

@fujitatomoya
Copy link
Collaborator Author

can we backport this humble? probably not, since c structure is extended, this is API compatibility but ABI?

@fujitatomoya
Copy link
Collaborator Author

https://build.ros2.org/job/Rpr__rcl__ubuntu_jammy_amd64/154/ is related to this PR, but cannot reproduce this failure on my local environment.

@ros-pull-request-builder retest this please

@fujitatomoya
Copy link
Collaborator Author

either @Barry-Xu-2018 or @iuhilnehc-ynos can you run the test with your local environment? I cannot reproduce the failure reported https://build.ros2.org/job/Rpr__rcl__ubuntu_jammy_amd64/159/.

colcon test --event-handlers console_direct+ --packages-select rcl

@iuhilnehc-ynos
Copy link
Collaborator

iuhilnehc-ynos commented Feb 2, 2023

@fujitatomoya

I can reproduce this issue in the ros:rolling image with this PR. The failure in Rpc is because the rmw_fastrtps is not the latest.
After using rmw_fastrtps with at least ros2/rmw_fastrtps@19d141d, the failure was gone.

It means the ros-rolling-rmw-fastrtps-cpp should be updated in http://repo.ros2.org/ubuntu/testing.

@fujitatomoya
Copy link
Collaborator Author

It means the ros-rolling-rmw-fastrtps-cpp should be updated in http://repo.ros2.org/ubuntu/testing.

Ah, okay so using latest repo for rolling and CI should be fine. i will start the CI to verify. @iuhilnehc-ynos thanks for the information.

@clalancette i thought Rpr job base runtime is updated nightly, but obviously it is not. How often does it get updated?

@clalancette
Copy link
Contributor

@clalancette i thought Rpr job base runtime is updated nightly, but obviously it is not. How often does it get updated?

Only when we do releases into Rolling. We are way overdue for that; we will spend some time next week doing releases into Rolling.

@fujitatomoya
Copy link
Collaborator Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator Author

Window is unstable, i will restart it later.

@fujitatomoya
Copy link
Collaborator Author

  • Windows Build Status

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujitatomoya Thanks for moving to rcl_options and checking environment variable inside get_default_options methods. Implementation looks good to me.

However I have a question and suggestion for unit tests.

  • Need to check that explicitly settled up value for the publisher_options.disable_loaned_message and subscriber_options.disable_loaned_message will not be overridden by the environment variable after calling pub/sub init.
  • And we shouldn't rely on default value of the environment variable. We should set environment variable explicitly for each test.

rcl/test/rcl/test_publisher.cpp Outdated Show resolved Hide resolved
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya
Copy link
Collaborator Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator Author

@iuhilnehc-ynos can you review this?

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujitatomoya Thanks for addressing comments from review.
I still have a strong opinion that we should not rely on default settings for ROS_DISABLE_LOANED_MESSAGES environment variable in test_publisher_loan_disable and test_subscription_loan_disable when doing check for EXPECT_FALSE(publisher_options.disable_loaned_message); right after reading default options.
We need either explicitly set environment variable in test or even better remove check for EXPECT_FALSE(publisher_options.disable_loaned_message); after getting default options. And always forcefully set publisher_options.disable_loaned_message value as we needed for test case.
The rationale for that is:

  1. It's not safe to rely (not reliable to assume) that ROS_DISABLE_LOANED_MESSAGES environment variable will not be set by default on testing machine and environment. It could be leftovers from another tests. It might work currently but could be broken in future if order of tests will be changed or some new tests would be added.
  2. You've already have dedicated tests for checking publisher_options.disable_loaned_message after getting default options with different values of the ROS_DISABLE_LOANED_MESSAGES environment variable.

Copy link
Collaborator

@iuhilnehc-ynos iuhilnehc-ynos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor comments.

rcl/include/rcl/publisher.h Show resolved Hide resolved
rcl/src/rcl/publisher.c Show resolved Hide resolved
@fujitatomoya
Copy link
Collaborator Author

@fujitatomoya Thanks for addressing comments from review. I still have a strong opinion that we should not rely on default settings for ROS_DISABLE_LOANED_MESSAGES environment variable in test_publisher_loan_disable and test_subscription_loan_disable when doing check for EXPECT_FALSE(publisher_options.disable_loaned_message); right after reading default options. We need either explicitly set environment variable in test or even better remove check for EXPECT_FALSE(publisher_options.disable_loaned_message); after getting default options. And always forcefully set publisher_options.disable_loaned_message value as we needed for test case. The rationale for that is:

  1. It's not safe to rely (not reliable to assume) that ROS_DISABLE_LOANED_MESSAGES environment variable will not be set by default on testing machine and environment. It could be leftovers from another tests. It might work currently but could be broken in future if order of tests will be changed or some new tests would be added.
  2. You've already have dedicated tests for checking publisher_options.disable_loaned_message after getting default options with different values of the ROS_DISABLE_LOANED_MESSAGES environment variable.

@MichaelOrlov I see, probably it would be better, not to have flaky test 👍

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya
Copy link
Collaborator Author

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@fujitatomoya
Copy link
Collaborator Author

@MichaelOrlov @iuhilnehc-ynos thanks for the review, all comments are addressed. requesting final check.

rcl/src/rcl/publisher.c Show resolved Hide resolved
@fujitatomoya
Copy link
Collaborator Author

@iuhilnehc-ynos thanks for the review.

CI(windows unstable):

  • Windows Build Status

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujitatomoya Please remove logging to the stderr stream when rcl_get_disable_loaned_message(&disable_loaned_message) returning failure.
This is a normal situation when ROS_DISABLE_LOANED_MESSAGES is not defined and ret != RCL_RET_OK in this particular situation.

rcl/src/rcl/publisher.c Show resolved Hide resolved
rcl/src/rcl/subscription.c Show resolved Hide resolved
@fujitatomoya
Copy link
Collaborator Author

@clalancette i am putting a hold on this until #1029 (comment) is resolved. after rolling release, i will kick the Rpr job to make sure it passes, and then i will merge this into rolling.

@fujitatomoya
Copy link
Collaborator Author

@ros-pull-request-builder retest this please

@fujitatomoya
Copy link
Collaborator Author

rpr job is happy now, CI is green.

@clalancette i will be waiting for the final review on this.

@fujitatomoya
Copy link
Collaborator Author

@clalancette @MichaelOrlov @iuhilnehc-ynos thank you for the review, i will go ahead to merge this. since this changes ABI, this will be available on Iron or later.

@fujitatomoya fujitatomoya merged commit 60d8064 into rolling Feb 27, 2023
@delete-merged-branch delete-merged-branch bot deleted the fujitatomoya/20230120-performance-improvement branch February 27, 2023 22:04
danthony06 pushed a commit to danthony06/rcl that referenced this pull request Jun 14, 2023
* Cache disable flag to avoid reading environmental variable.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* Revert "Cache disable flag to avoid reading environmental variable."

This reverts commit 2ed9454.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* extend pub/sub option to save loaned message disable flag.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* add more test cases.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* set env variable explicitly during loaned message test.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

* add comments and error handling.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>

---------

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants