Skip to content

[minor size decrease] Force autorelease to free stuff inline.#43188

Open
andy31415 wants to merge 2 commits intoproject-chip:masterfrom
andy31415:inline_auto_release
Open

[minor size decrease] Force autorelease to free stuff inline.#43188
andy31415 wants to merge 2 commits intoproject-chip:masterfrom
andy31415:inline_auto_release

Conversation

@andy31415
Copy link
Contributor

@andy31415 andy31415 commented Feb 17, 2026

Summary

When testing compile output for stm32, I found that AutoRelease always generates ::Release functions, which seem to bloat code since most code can reason out to only be a final "free".

Testing

Trivial force compiler to always inline these, resulting in minor flash decreases.
Locally stm32 light saves 56 bytes of text.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds compiler hints to force inlining of the destructor and Release() method in the AutoRelease template class to reduce code size on embedded targets like STM32. The change leverages the compiler's ability to optimize out function calls when the underlying Release() operation is simple.

Changes:

  • Added __attribute__((always_inline)) to AutoRelease destructor to force inline compilation
  • Added __attribute__((always_inline)) to AutoRelease::Release() method for the same optimization

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces __attribute__((always_inline)) to the AutoRelease destructor and Release method. This change aims to force the compiler to inline these functions, which the author has verified leads to a minor decrease in flash size on stm32. This is a targeted optimization to improve code efficiency, and given the context of embedded development, such compiler-specific attributes are often used for performance gains. The use of __attribute__ aligns with existing practices in the codebase, as seen in CodeUtils.h.

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

PR #43188: Size comparison from 4dbe59f to cfe0fbb

Full report (26 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nxp, psoc6, qpg, realtek, stm32)
platform target config section 4dbe59f cfe0fbb change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1108172 1108154 -18 -0.0
RAM 178674 178674 0 0.0
bl702 lighting-app bl702+eth FLASH 663248 663230 -18 -0.0
RAM 134689 134689 0 0.0
bl702+wifi FLASH 838954 838936 -18 -0.0
RAM 124213 124213 0 0.0
bl706+mfd+rpc+littlefs FLASH 1073182 1073164 -18 -0.0
RAM 117157 117157 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 905796 905778 -18 -0.0
RAM 105748 105748 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 986248 986230 -18 -0.0
RAM 109644 109644 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 777436 777412 -24 -0.0
RAM 103280 103280 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 786000 785968 -32 -0.0
RAM 108496 108496 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 731068 731044 -24 -0.0
RAM 97260 97260 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 715596 715572 -24 -0.0
RAM 97460 97460 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 556508 556500 -8 -0.0
RAM 204448 204448 0 0.0
lock CC3235SF_LAUNCHXL FLASH 590704 590688 -16 -0.0
RAM 204744 204744 0 0.0
efr32 lock-app BRD4187C FLASH 969152 969112 -40 -0.0
RAM 125476 125476 0 0.0
BRD4338a FLASH 757708 757668 -40 -0.0
RAM 237712 237712 0 0.0
window-app BRD4187C FLASH 1066872 1066832 -40 -0.0
RAM 126700 126700 0 0.0
esp32 all-clusters-app c3devkit DRAM 98260 98260 0 0.0
FLASH 1590114 1590062 -52 -0.0
IRAM 93514 93514 0 0.0
nxp contact mcxw71+release FLASH 746432 746408 -24 -0.0
RAM 66912 66912 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1701804 1701772 -32 -0.0
RAM 213852 213852 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1602924 1602892 -32 -0.0
RAM 210740 210740 0 0.0
light cy8ckit_062s2_43012 FLASH 1468652 1468620 -32 -0.0
RAM 196936 196936 0 0.0
lock cy8ckit_062s2_43012 FLASH 1496788 1496756 -32 -0.0
RAM 224720 224720 0 0.0
qpg lighting-app qpg6200+debug FLASH 840292 840276 -16 -0.0
RAM 127764 127764 0 0.0
lock-app qpg6200+debug FLASH 778904 778872 -32 -0.0
RAM 118712 118712 0 0.0
realtek light-switch-app rtl8777g FLASH 704952 704920 -32 -0.0
RAM 113440 113440 0 0.0
lighting-app rtl8777g FLASH 750648 750608 -40 -0.0
RAM 114640 114640 0 0.0
stm32 light STM32WB5MM-DK FLASH 477256 477200 -56 -0.0
RAM 141280 141280 0 0.0

@github-actions
Copy link

github-actions bot commented Feb 18, 2026

PR #43188: Size comparison from 8f0e573 to d5001c2

Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 8f0e573 d5001c2 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1108158 1108140 -18 -0.0
RAM 178674 178674 0 0.0
bl702 lighting-app bl702+eth FLASH 663234 663216 -18 -0.0
RAM 134689 134689 0 0.0
bl702+wifi FLASH 838940 838922 -18 -0.0
RAM 124213 124213 0 0.0
bl706+mfd+rpc+littlefs FLASH 1073168 1073150 -18 -0.0
RAM 117157 117157 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 905782 905764 -18 -0.0
RAM 105748 105748 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 986234 986216 -18 -0.0
RAM 109644 109644 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 777636 777596 -40 -0.0
RAM 103280 103280 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 785984 785952 -32 -0.0
RAM 108496 108496 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 731060 731020 -40 -0.0
RAM 97260 97260 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 715580 715556 -24 -0.0
RAM 97460 97460 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 556492 556476 -16 -0.0
RAM 204448 204448 0 0.0
lock CC3235SF_LAUNCHXL FLASH 590688 590672 -16 -0.0
RAM 204744 204744 0 0.0
efr32 lock-app BRD4187C FLASH 969152 969112 -40 -0.0
RAM 125476 125476 0 0.0
BRD4338a FLASH 757692 757652 -40 -0.0
RAM 237712 237712 0 0.0
window-app BRD4187C FLASH 1066840 1066800 -40 -0.0
RAM 126700 126700 0 0.0
esp32 all-clusters-app c3devkit DRAM 98260 98260 0 0.0
FLASH 1590100 1590048 -52 -0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 955920 955892 -28 -0.0
RAM 162081 162081 0 0.0
nxp contact mcxw71+release FLASH 746416 746392 -24 -0.0
RAM 66912 66912 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1701788 1701756 -32 -0.0
RAM 213852 213852 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1602908 1602876 -32 -0.0
RAM 210740 210740 0 0.0
light cy8ckit_062s2_43012 FLASH 1468732 1468700 -32 -0.0
RAM 196936 196936 0 0.0
lock cy8ckit_062s2_43012 FLASH 1496772 1496740 -32 -0.0
RAM 224720 224720 0 0.0
qpg lighting-app qpg6200+debug FLASH 840292 840260 -32 -0.0
RAM 127764 127764 0 0.0
lock-app qpg6200+debug FLASH 778888 778856 -32 -0.0
RAM 118712 118712 0 0.0
realtek light-switch-app rtl8777g FLASH 704936 704904 -32 -0.0
RAM 113440 113440 0 0.0
lighting-app rtl8777g FLASH 750832 750792 -40 -0.0
RAM 114640 114640 0 0.0
stm32 light STM32WB5MM-DK FLASH 477440 477392 -48 -0.0
RAM 141280 141280 0 0.0
telink bridge-app tl7218x FLASH 726486 726438 -48 -0.0
RAM 95708 95708 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 851362 851314 -48 -0.0
RAM 44148 44148 0 0.0
tl7218x FLASH 842762 842714 -48 -0.0
RAM 99532 99532 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 725062 725014 -48 -0.0
RAM 55728 55728 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 787688 787640 -48 -0.0
RAM 74912 74912 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725062 725014 -48 -0.0
RAM 33212 33212 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613962 613912 -50 -0.0
RAM 118196 118196 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 841612 841568 -44 -0.0
RAM 97240 97240 0 0.0

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.

3 participants

Comments