Skip to content

Improve STM32 heap allocation performance and debugging. #1662

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

UncleGrumpy
Copy link
Collaborator

Improves heap memory allocation performance by making the execution of the conditional local_heap_setup function UNLIKELY since this is only matches on the the first heap allocation.

Improves application memory debugging on STM32 by adding system_info/1 keys avm_free_heap_size and avm_minimum_free_size with functionality matching the esp32 keys for these statistics.

Adds memory-size output report after compiling.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@UncleGrumpy UncleGrumpy force-pushed the stm32_heap_size branch 2 times, most recently from 2b91463 to 2e8e0c9 Compare June 1, 2025 04:30
Copy link
Collaborator

@bettio bettio left a comment

Choose a reason for hiding this comment

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

We still need to add this change in UPDATING.md with a short explaination about how to migrate existing code.

@UncleGrumpy UncleGrumpy force-pushed the stm32_heap_size branch 2 times, most recently from 5860c50 to 1d151cd Compare June 6, 2025 19:31
@UncleGrumpy UncleGrumpy requested a review from bettio June 11, 2025 00:24
Adds linker flag to display memory size information after building to STM32 platform
libopencm3.cmake configuration file.

Signed-off-by: Winford <winford@object.stream>
Make the local_heap_setup conditional unlikely to improve performance of memory allocation since
this only is true only at the first memory allocation.

Signed-off-by: Winford <winford@object.stream>
…latform

Adds support for getting the current free heap size on STM32 platform using
`erlang:system_info(atomvm_free_heap_size)`.

Signed-off-by: Winford <winford@object.stream>
…2 platform

Adds support for getting the current free heap size on STM32 platform using
`erlang:system_info(atomvm_minimum_free_size)`.

Signed-off-by: Winford <winford@object.stream>
…th atomvm_ prefix

Adds new ESP32 erlang:system_info/1 heap memory keys `atomvm_free_heap_size` and
`atomvm_minimum_free_size` to align with newly added STM32 memory keys.

When the old keys are used a deprecation warning will be printed to the console to alert users to
update to the new key names before the old keys are removed in the 0.8.x release cycle.

Signed-off-by: Winford <winford@object.stream>
Adds documentation to the `erlang` module and "Programmer's Guide" for newly added STM32
system_info/1 keys.

Signed-off-by: Winford <winford@object.stream>
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