Skip to content

CommonMessaging - Improved inlining and branch predicition

This MR includes a minor change to CommonMessaging.h designed to improve the runtime performance of CommonMessaging::setUpMessaging(), which is quite heavily called, by making a few trivial changes.

  • The method CommonMessaging::setUpMessaging() is split in two, moving the part that is infrequently called to a new private method. This makes the footprint of CommonMessaging::setUpMessaging() much smaller and consequently improves the likelihood of it being inlined.
  • I added an UNLIKELY( ) hint around the !m_commonMessagingReady to help the compiler better optimise the check branch prediction.

Together these MRs address a small performance regression I recently noticed, most likely due to !566 (merged). See the callgrind heat maps below for the cost of a given algorithm call, before and after the change.

Before : before

After: after

Edited by Christopher Rob Jones

Merge request reports