rp2/mpconfigport: Configure heap for PSRAM.

PSRAM will be used exclusively if MICROPY_GC_SPLIT_HEAP == 0, it will be
added to RAM if MICROPY_GC_SPLIT_HEAP == 1, and the system will fall back
to RAM only if it's not detected.

Due to the size of PSRAM, GC stack was overflowing and causing the GC to
scan through the entire memory pool.  This caused noticable slowdowns
during GC.  Increase the stack from 256 to 4096 bytes to avoid overflow and
increase the stack entry type size to accomodate 8MB+ PSRAM.

Changes are:
- ports/rp2/mpconfigport.h: Make split-heap optional and enable by default.
- ports/rp2/mpconfigport.h: Increase GC stack entry type to uint32_t.
- ports/rp2/mpconfigport.h: Raise GC stack size.

Co-authored-by: Kirk Benell <kirk.benell@sparkfun.com>
Signed-off-by: Phil Howard <github@gadgetoid.com>
This commit is contained in:
Phil Howard
2024-08-09 14:15:33 +01:00
committed by Damien George
parent 11f057dd9a
commit b7d5caf2a3

View File

@@ -86,7 +86,15 @@
#endif
// Memory allocation policies
#if MICROPY_HW_ENABLE_PSRAM
#define MICROPY_GC_STACK_ENTRY_TYPE uint32_t
#define MICROPY_ALLOC_GC_STACK_SIZE (1024) // Avoid slowdown when GC stack overflow causes a full sweep of PSRAM-backed heap
#else
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
#endif
#ifndef MICROPY_GC_SPLIT_HEAP
#define MICROPY_GC_SPLIT_HEAP MICROPY_HW_ENABLE_PSRAM // whether PSRAM is added to or replaces the heap
#endif
#define MICROPY_ALLOC_PATH_MAX (128)
#define MICROPY_QSTR_BYTES_IN_HASH (1)