Skip to content

User callback debugging and MavlinkDirect improvements#2694

Merged
julianoes merged 3 commits intomainfrom
pr-user-callbacks
Nov 2, 2025
Merged

User callback debugging and MavlinkDirect improvements#2694
julianoes merged 3 commits intomainfrom
pr-user-callbacks

Conversation

@julianoes
Copy link
Copy Markdown
Collaborator

@julianoes julianoes commented Oct 26, 2025

This adds better user callback tracking with MAVSDK_CALLBACK_DEBUGGING=1 set:

[04:24:30|Info ] Callback stats: 191 callbacks/sec (avg), queue size: 0 (callback_tracker.cpp:48)
[04:24:30|Info ] Top callback sources (by time): (callback_tracker.cpp:66)
[04:24:30|Info ]   mavlink_direct_impl.cpp:163: 20 calls, 119 us total, 5 us avg, 92.2% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   mavlink_command_sender.cpp:472: 10 calls, 10 us total, 1 us avg, 7.8% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   info_impl.cpp:167: 5 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:1024: 5 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:1206: 3 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:1223: 5 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:1230: 5 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:1303: 5 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:685: 150 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)
[04:24:30|Info ]   telemetry_impl.cpp:770: 500 calls, 0 us total, 0 us avg, 0.0% of time (callback_tracker.cpp:89)

The instrumentation let me discover that we were using the queue internally instead of externally in MavlinkDirect. That's fixed as well.

Comment thread src/mavsdk/core/mavsdk_impl.cpp
Comment thread src/mavsdk/core/mavsdk_impl.cpp Outdated
This adds a class to debug user callbacks taking too long.

The class is only instantiated and used when the env variable
MAVSDK_CALLBACK_DEBUGGING=1
is set.
We should not use the callback queue internally (unless we need to) but
only once it comes to external/user callbacks.
@sonarqubecloud
Copy link
Copy Markdown

@julianoes julianoes merged commit 4086878 into main Nov 2, 2025
54 checks passed
@julianoes julianoes deleted the pr-user-callbacks branch November 2, 2025 02:29
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.

2 participants