-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add central memory-class ladder (MemClass.h) with fail-safe-small defaults #10901
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ce57701
Right-size nRF52 heap tiers after 2.8.0 heap-exhaustion field reports
thebentern 5338923
Add central memory-class ladder (MemClass.h) with fail-safe-small def…
thebentern b4d5f98
Merge remote-tracking branch 'origin/develop' into memclass-feedback
thebentern 85a3c2f
Address review: fix RP2350 class-table doc, add PacketRecord static_a…
thebentern 08476c2
Address review: share PACKETHISTORY_MAX, trim policy comments
thebentern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #pragma once | ||
|
|
||
| // Central memory-class ladder: RAM-sized caches key their per-platform tier off | ||
| // MESHTASTIC_MEM_CLASS. Classes rank *usable app heap after platform overheads* | ||
| // (SoftDevice, WiFi+BLE stacks) - not raw RAM - and an unclassified chip lands in | ||
| // SMALL on purpose: small caches are a recoverable default, an exhausted heap is not. | ||
| // | ||
| // MEM_CLASS_TINY <32 KB free heap STM32WL | ||
| // MEM_CLASS_SMALL ~100-250 KB nRF52840, classic ESP32/S2/C3, RP2040/RP2350 | ||
| // MEM_CLASS_MEDIUM ~250-500 KB, no PSRAM ESP32-S3/C6/P4 without PSRAM | ||
| // MEM_CLASS_LARGE PSRAM or host ESP32-S3+PSRAM, portduino | ||
| // | ||
| // Compare ordinally (>=). RP2350 rides with RP2040 so this header stays a behavioral | ||
| // no-op (MEDIUM candidate later). Variants may predefine MESHTASTIC_MEM_CLASS or any | ||
| // cache constant - consumer ladders stay #ifndef-guarded. MAX_NUM_NODES is deliberately | ||
| // unclassed (flash-shaped: nodes.proto vs filesystem). Included before configuration.h, | ||
| // so only toolchain/board -D macros and the ARCH_* macros the ladders already use are | ||
| // safe here. | ||
|
|
||
| #define MEM_CLASS_TINY 1 | ||
| #define MEM_CLASS_SMALL 2 | ||
| #define MEM_CLASS_MEDIUM 3 | ||
| #define MEM_CLASS_LARGE 4 | ||
|
|
||
| #ifndef MESHTASTIC_MEM_CLASS | ||
| #if defined(ARCH_STM32WL) | ||
| #define MESHTASTIC_MEM_CLASS MEM_CLASS_TINY | ||
| #elif (defined(CONFIG_IDF_TARGET_ESP32S3) && defined(BOARD_HAS_PSRAM)) || defined(ARCH_PORTDUINO) | ||
| #define MESHTASTIC_MEM_CLASS MEM_CLASS_LARGE | ||
| #elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32P4) | ||
| #define MESHTASTIC_MEM_CLASS MEM_CLASS_MEDIUM | ||
| #else | ||
| // Classic ESP32 / S2 / C3, all nRF52, RP2040/RP2350, and - by design - any chip | ||
| // nobody has classified yet: small caches are a recoverable default, an | ||
| // exhausted heap is not. New RAM-rich targets opt up by adding a branch above. | ||
| #define MESHTASTIC_MEM_CLASS MEM_CLASS_SMALL | ||
| #endif | ||
| #endif // MESHTASTIC_MEM_CLASS | ||
|
|
||
| // Ceiling for the boot-allocated mesh caches (TMM + warm store + packet history); | ||
| // mesh-pb-constants.h static_asserts their sum, so an oversized cache fails the build. | ||
| // Raising a budget is allowed - as a visible, reviewable one-line diff. | ||
| #ifndef MESHTASTIC_BOOT_CACHE_BUDGET | ||
| #if MESHTASTIC_MEM_CLASS <= MEM_CLASS_TINY | ||
| #define MESHTASTIC_BOOT_CACHE_BUDGET (8 * 1024) | ||
| #elif MESHTASTIC_MEM_CLASS == MEM_CLASS_SMALL | ||
| #define MESHTASTIC_BOOT_CACHE_BUDGET (16 * 1024) | ||
| #elif MESHTASTIC_MEM_CLASS == MEM_CLASS_MEDIUM | ||
| #define MESHTASTIC_BOOT_CACHE_BUDGET (32 * 1024) | ||
| #else | ||
| #define MESHTASTIC_BOOT_CACHE_BUDGET (256 * 1024) | ||
| #endif | ||
| #endif // MESHTASTIC_BOOT_CACHE_BUDGET |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.