Skip to content
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

Avoid including AP_InertialSensor.h in headers #28933

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

peterbarker
Copy link
Contributor

increases amount of work compiler needs to do for no good reason

... particularly when including in AP_AHRS.h, which is used a lot.

Board                    AP_Periph  blimp  bootloader  copter  heli  iofirmware  plane  rover  sub
CubeOrange-periph-heavy  *                                                                     
CubeRedPrimary                      8      *           0       0                 -16    0      16
Durandal                            -8     *           -24     -24               -32    -24    0
Hitec-Airspeed           *                                                                     
KakuteH7-bdshot                     16     *           0       -8                -16    -8     16
MatekF405                           0      *           8       16                0      16     0
Pixhawk1-1M-bdshot                  0                  8       16                -8     8      0
bebop                               32                 16      48                -4     -16    -16
f103-QiotekPeriph        *                                                                     
f303-Universal           *                                                                     
iomcu                                                                *                         
revo-mini                           0      *           8       8                 0      8      0
skyviper-v2450                                         8                                       

increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
increases amount of work compiler needs to do for no good reason
@tpwrules
Copy link
Contributor

Is this a measurable time save? Allowing inline isn't a bad reason. Of course the difference doesn't appear huge, and I am assuming these are not methods on the hot path.

@peterbarker
Copy link
Contributor Author

Is this a measurable time save? Allowing inline isn't a bad reason. Of course the difference doesn't appear huge, and I am assuming these are not methods on the hot path.

They are also methods of dubious implementation ("first usable" vs "primary").... We're also not particularly good at being consistent about whether the accel vector is a product of the AHRS or ins library.

I have not attempted to measure time deltas. I think it's pretty clear that we won't form needless header dependencies during compilation, on top of any time savings from not including them - and that makes cache hits more likely.

@tpwrules
Copy link
Contributor

Okay, it seems those methods are very rarely used anyway, maybe it would be better to just kill them?

I assume you are testing all the build options, that's the only other possibility of issue I can see.

Copy link
Collaborator

@andyp1per andyp1per left a comment

Choose a reason for hiding this comment

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

We use inline for a reason

@@ -221,9 +220,7 @@ class AP_GyroFFT
// whether analysis can be run again or not
bool start_analysis();
// return samples available in the gyro window
uint16_t get_available_samples(uint8_t axis) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't do this, this is in the hot path and inlining helps


// get the index of the current primary gyro sensor
virtual uint8_t get_primary_gyro_index(void) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Simply un-inlining things requires a fair amount of testing, I suggest you don't do that in this PR

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.

3 participants