Add selective collect to memory allocations#10264
Conversation
|
I have this branch with debugging prints and checks: https://github.com/tannewt/circuitpython/tree/debug_gc_selective_collect |
|
Hopefully #10269 will make enough space for this. |
By selectively collecting an allocation, we can skip scanning many allocations for pointers because we know up front they won't have them. This helps a ton when large buffers are being used and memory is slow (PSRAM). In one Fruit Jam example GC times drop from 80+ms to ~25ms. The example uses a number of bitmaps that are now no longer scanned.
69e4bcd to
c340596
Compare
Update Hallowing M4 so that it has synthio, jpegio and tilepalettemapper. It doesn't need *target or the other display buses.
dhalbert
left a comment
There was a problem hiding this comment.
This is a big change but is a very good idea.
I tried to do complete // CIRCUITPY-CHANGE labelling, partly for my own benefit at the next upstream mege, and partly for the reader.
As I discussed in two comments, I think it might be safer to force conscious choice between the _with_collect() and _without_collect() versions of things by eliminating the old ambiguous name, or else make the old name do the safer thing of assuming collecting.
Co-authored-by: Dan Halbert <halbert@halwitz.org>
4025752 to
35ffb64
Compare
|
I've also modified This is when testing https://github.com/adafruit/Adafruit_Learning_System_Guides/pull/3013/files on Fruit Jam (RP2350 with PSRAM). |
dhalbert
left a comment
There was a problem hiding this comment.
Looks good! And the m_malloc_without_collect() is clearer.
|
Jammed |
|
I wrote up more info about this here: https://blog.adafruit.com/2025/04/28/improving-garbage-collection-time-in-circuitpython/ |
By selectively collecting an allocation, we can skip scanning many allocations for pointers because we know up front they won't have them. This helps a ton when large buffers are being used and memory is slow (PSRAM). In one Fruit Jam example GC times drop from 80+ms to ~25ms. The example uses a number of bitmaps that are now no longer scanned.