Skip to content

DroneCAN: update libcanard#30613

Merged
tpwrules merged 2 commits intoArduPilot:masterfrom
tridge:pr-canard-update
Jul 13, 2025
Merged

DroneCAN: update libcanard#30613
tpwrules merged 2 commits intoArduPilot:masterfrom
tridge:pr-canard-update

Conversation

@tridge
Copy link
Copy Markdown
Contributor

@tridge tridge commented Jul 12, 2025

this reduces CPU usage in the hot frame accept path using hash on the message ID into a set of message lists

this is the key change: dronecan/libcanard#81

I profiled the change using SYS_STATUS.load while I had another flight controller on the bus sending a high rate of ESC RawCommand messages.
Here is the result on a CubeOrange with current master copter:
image
and here it is with this PR:
image
this shows roughly 10% reduction in overall CPU usage.
Note that this is a (deliberately) extreme case. We don't process RawCommand in ArduPilot main firmware, so we need to traverse all the way to the end of the linked list to determine that we shouldn't accept it, plus I setup the other flight controller with SCHED_LOOP_RATE=800 and as an OctoQuad, so over 2400 frames/sec of CAN frames we need to reject
The gain in CPU in more normal operation will be much smaller - maybe 2 to 3%? I setup the extreme case as it is quite a noisy thing to measure so much easier when you push the CAN bus hard

this reduces CPU usage in the hot frame accept path using hash on the
message ID into a set of message lists
@tridge tridge added the CAN label Jul 12, 2025
@tpwrules
Copy link
Copy Markdown
Contributor

Curious if you've done any particular profiling?

@tridge
Copy link
Copy Markdown
Contributor Author

tridge commented Jul 12, 2025

Curious if you've done any particular profiling?

I've added some profiling data to the PR

@tpwrules
Copy link
Copy Markdown
Contributor

This looks reasonable but I will try to test on hardware this weekend.

When I did testing I used a slightly tweaked --enable-stats and @SYS/threads.txt.

@tridge tridge requested a review from tpwrules July 12, 2025 09:32
Copy link
Copy Markdown
Contributor

@tpwrules tpwrules left a comment

Choose a reason for hiding this comment

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

Looks good to me, I tested on CubeOrange it did not immediately break everything.

I want to get this in this PR too just to make bisecting easier and reduce the amount of submodule churn: dronecan/dronecan_dsdlc#35 (it's tested and ready to go in)

@tridge
Copy link
Copy Markdown
Contributor Author

tridge commented Jul 12, 2025

I want to get this in this PR

done

@tpwrules tpwrules merged commit a5c73ec into ArduPilot:master Jul 13, 2025
124 of 128 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants