-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
uORB::Subscription subscribe directly to uORB device node object #12040
Conversation
ec0455a
to
e1cc423
Compare
e1cc423
to
aecabbb
Compare
aebe8c2
to
ece2390
Compare
Indoor test on Pixhawk 4 v5Modes Tested
Flight Test: Notes: Flight Log |
Indoor flight test on PixRacer V4Modes Tested Flight Test: Notes: Flight log: 1 Flight log: 2 Indoor flight test on Pixhawk 2 Cube V3Modes Tested Flight Test Notes: Flight log: 1 Flight log : 2 |
ece2390
to
967cd18
Compare
967cd18
to
2bfc645
Compare
The main motivation for this change is saving memory (see #11176 (comment) for details), but the performance improvements in uORB are also going to be worthwhile overall. Here's a comparison of the common check and copy operations. C API (orb_check(), orb_copy(), etc)
C++ API
On a typical setup these operations are called tens of thousands of times every second, so shaving off microseconds from each orb check and copy will actually be a considerable cpu usage improvement (in aggregate). |
Awesome! Just for the sake of curiosity: Coukd you share the output of top for one representative setup? |
We'll need to move the high rate modules and logger to uORB::Subscription to see most of the benefit. Here's the current comparison below where the main difference is a small decrease in cpu usage for each Mavlink instance (notice the FDs per task). This isn't a direct comparison though, because for safety I also restored the original MavlinkOrbSubscription semantics where the data is always copied even if there's no timestamp update (the PR is doing more orb copy work yet still faster). Memory-wise the huge win will be after logger and a few other heavy subscribers are updated. That's when we'll be able to drop the NuttX file descriptors significantly and overall have an extra 15-20 kB of memory to play with. Master
PR
|
2bfc645
to
12ca6c8
Compare
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.
Nice, this makes Subscription
much more usable.
Some general remarks:
- The class API docs don't make it clear when to use which class. Can you clarify this? Especially that
Subscription
should generally be used over the Polled classes. - Can you rename
SubscriptionPolled
toSubscriptionPollable
? I findPolled
confusing, since there is nopoll
involved. - Did you check the need for
virtual
for theSubscription
classes? If not required, we should remove that overhead early on.
The naming is better, but I'd actually like to kill this off entirely as soon as possible (likely once FlightTasks is migrated). Then it's only LPE using it for polling, which we can either work around with the C API, or add a blocking update method to the new uORB::Subscription.
|
@dagar after the pr we upload master and it worked without issues |
Can you share the details of that setup and the parameters? I'm unable to reproduce locally on a Pixhawk 4 or 4 mini. |
55d7e56
to
47052b3
Compare
In the last refactor I consolidated the copy logic to be shared by https://github.com/PX4/Firmware/pull/12040/files#diff-6933463aec16725fb6cb34d9b949df62R169 @dannyfpv please try again. |
Tested on Pixhawk 4 v5 (Update)Modes Tested:
Notes: Logs:
Note: |
47052b3
to
d6d2f60
Compare
Tested on Pixhawk 4mini v5Modes Tested
Procedure Notes Log |
d6d2f60
to
c71c879
Compare
As discussed on the dev call this week, let's give this another round of thorough testing, including a setup with heavy mavlink usage and logging over mavlink. The majority of the new |
c71c879
to
bd07909
Compare
Rebased on master to resolve minor FlightTasks merge conflict. |
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.
Looks correct, but let's do the heavy load test first before merging.
{ | ||
bool updated = false; | ||
|
||
if ((dst != nullptr) && (_data != nullptr)) { |
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.
Using an early return would reduce the level of indentation:
if ((dst != nullptr) && (_data != nullptr)) { | |
if (!dst || !_data) { | |
return false; | |
} |
Testing looks good, let's get this into master and keep going. There's a lot more to be done. Thanks everyone! |
Continuation of #11176.
This is a minimal version of #11176 with the core uORB changes. The larger changes to
mavlink, logger, flighttasks, etc can follow incrementally.Changes
The new uORB::Subscription subscribes directly to the underlying uORB::DeviceNode, bypasses file descriptors. It's faster, uses less memory, and gets us past NuttX file descriptor limits.
Longer term uORB::SubscriptionPolled will be phased out entirely.