You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFC Possible performance improvement for SPIRAM targets #8428
The time for GC on an ESP32 without SPIRAM is ~1.8ms. Add SPIRAM and it goes to 100ms, impacting the latency of the soft-only interrupts. This cliff edge leads me to avoid SPIRAM modules where possible. It would be good if there were a way to avoid it.
One approach might be for the user to be able to specify (perhaps in boot.py) the maximum SPIRAM to be made available in the pool, from 0 upwards in increments of (say) 1MB.
Another approach would be to automate this. Initially the pool would comprise only internal RAM. If an allocation would cause OOM, 1MB of SPIRAM would be added to the pool. This would continue until SPIRAM was exhausted. In this way an application would only use the amount of SPIRAM it actually required. GC would take place in the current pool, so in small applications SPIRAM would never be used and GC would be fast. Adding to the pool would be a one way process - once a 1MB block was added, it would remain in place until reset.
This is an illustration - there may well be better algorithms than the above. For example adding a block before OOM actually occurs might improve performance by reducing fragmentation.
Limiting the amount of SPIRAM for the heap might be the easier part, by starting with a small amount like 1M and being able to extend it once. Reducing it seems more complicated, if the heap is already populated.
In any case, SPIRAM is subject to cache misses and therefore slow.
My thinking is based on the fact that boards like the UM Feather S2 have useful features, but include 8MB SPIRAM. For smaller, high performance applications, even the ability to disable SPIRAM in boot.py would be a big advantage. We win twice: with fast RAM and short GC time.
Reducing it seems more complicated, if the heap is already populated.
I don't envisage a need for this. The firmware would initialise with the heap restricted to internal RAM. The boot.py option (or algorithm) would only ever increase the size.
Here is a practical issue reported by a user. In a uasyncio application GC was causing 300ms of additional latency between pressing a button and getting a response.
Another approach would be to automate this. Initially the pool would comprise only internal RAM. If an allocation would cause OOM, 1MB of SPIRAM would be added to the pool. This would continue until SPIRAM was exhausted.
Activity
robert-hh commentedon Mar 18, 2022
Limiting the amount of SPIRAM for the heap might be the easier part, by starting with a small amount like 1M and being able to extend it once. Reducing it seems more complicated, if the heap is already populated.
In any case, SPIRAM is subject to cache misses and therefore slow.
peterhinch commentedon Mar 19, 2022
My thinking is based on the fact that boards like the UM Feather S2 have useful features, but include 8MB SPIRAM. For smaller, high performance applications, even the ability to disable SPIRAM in
boot.pywould be a big advantage. We win twice: with fast RAM and short GC time.I don't envisage a need for this. The firmware would initialise with the heap restricted to internal RAM. The
boot.pyoption (or algorithm) would only ever increase the size.peterhinch commentedon Mar 25, 2022
Here is a practical issue reported by a user. In a uasyncio application GC was causing 300ms of additional latency between pressing a button and getting a response.
dpgeorge commentedon Apr 22, 2022
I think this is a very good idea.
tannewt commentedon Sep 28, 2023
This was done in #12141 and can be closed.