Files
PX4-Autopilot/test
Ramon Roche 49e5550b94 perf(mavlink): remove mutex from forward_message hot path
Remove mavlink_module_mutex from forward_message() to eliminate
per-message lock overhead in the forwarding path.

The mutex is unnecessary because:
- Instances can only be destroyed via destroy_all_instances(), which
  stops all threads before modifying the array
- Pointer reads from mavlink_module_instances[] are naturally atomic
  on aligned architectures (ARM, x86)
- pass_message() has its own per-instance _message_buffer_mutex

Benchmark results (SITL SIH, 2 connections, wall-clock timing):

  200 Hz (400 msg/s): avg 648 ns -> 563 ns (-13%)
  500 Hz (1000 msg/s): avg 469 ns -> 407 ns (-13%)
  Mutex lock section: avg 327 ns -> 262 ns (-20%)

Benchmark gist: https://gist.github.com/mrpollo/167d4ec7436fb773bf193be6c2800639

Also includes a MAVSDK C++ traffic generator tool for reproducing
the benchmark.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-03-31 18:15:20 -07:00
..