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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support throttling serialized graph publisher #204

Conversation

efernandez
Copy link
Collaborator

Motivation

I've been throttling the serialized graph message published by the fuse_publishers::SerializedPublisher using the throttle node from topic_tools, so I only record a few graphs for debugging purposes. Recording all would take too much disk and bandwidth.

So far so good, but the serialized publisher is still serializing and publishing all the graphs it gets notified from the optimizer. It turns out that serializing the graph is quite fast, but it still takes a noticeable amount of time. If the optimization frequency is high, we could get too many graphs and the impact becomes more significant.

Since I'm throttling the serialized graph messages after anyway, it makes more sense to throttle the publisher directly in the serialized publisher, so we can save some cycles.

Changelog

  • Move the fuse_models::ThrottledCallback to fuse_core
  • Support generic callbacks in ThrottledCallback. An alias template called ThrottledMessageCallback is provided for ROS messages. Unfortunately, the automatic type deduction in ros::NodeHandle::subcribe() no longer works due to the generic ThrottledCallback::callback() we have now. For this reason we now have to do subscribe<Message>() instead of just subscribe(). If you know how to make this cleaner, I'd like to know. 馃槂
  • Add support to throttle graph publishing. It doesn't throttle any graph by default. BTW, I'm happy to create a parameters folder and a class to encapsulate the fuse_publishers::SerializedPublisher configuration, as it's done in fuse_models.

Results

If the optimization frequency or the rate of the sensor models inputs are low, the impact of this is very low. I've evaluated this with the following relevant configuration:

  • 50Hz optimization frequency
  • A bunch of sensor models inputs that when all are processed and the graph isn't throttled, the graph is published at approx. 30Hz

The plots below show the CPU% of the fuse optimizer node in blue, and the average in red:

  • No graph publisher throttling:
    C4-2020-11-13_18-58-25_01_plot
  • Graph publisher throttled, with a throttle period of 30s, which is a reasonable value for use case described in the motivation section (I expect similar results with smaller throttling periods though):
    C5-2020-11-13_19-01-16_01_plot

We save approx. 10% of CPU.

@efernandez efernandez requested review from ayrton04 and svwilliams and removed request for ayrton04 November 13, 2020 19:23
@efernandez efernandez self-assigned this Nov 13, 2020
@efernandez efernandez added the enhancement New feature or request label Nov 13, 2020
fuse_publishers/src/serialized_publisher.cpp Outdated Show resolved Hide resolved
fuse_publishers/src/serialized_publisher.cpp Outdated Show resolved Hide resolved
@efernandez efernandez force-pushed the throttle-serialized-publisher-upstream branch from 2a7d11f to 0458f04 Compare November 30, 2020 10:09
@efernandez
Copy link
Collaborator Author

Not sure why the checks failed, so I've rebase this PR on top of #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

3 participants