-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add selective collect to memory allocations #10264
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.