Difference between SRAM & SPIRAM

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Difference between SRAM & SPIRAM

Post by jickster » Mon Nov 12, 2018 3:33 am

loboris wrote:
jickster wrote:
Sun Nov 11, 2018 5:53 pm
SPIRAM is much slower. Waayyyyyyyy slower.
It is slower, but...
Theoretical SPI-RAM access speed is ~40MB/s.
In final application, for example in MicroPython firmware, SPI-RAM access speed is is ~14 MB/sec.
The access is cached in internal RAM buffer (same as Flash access) and practical results shows it is quite usable if it is used in a way it is suposed to be used.
In the typical MicroPython application there is often no difference if the heap is on internal RAM or external SPI-RAM.

What’s continuous, random read, write speed for SPIRAM vs sram?


Sent from my iPhone using Tapatalk Pro

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Difference between SRAM & SPIRAM

Post by pythoncoder » Mon Nov 12, 2018 7:21 am

As a matter of general interest there are some benchmark results in the original Loboris thread.
Peter Hinch
Index to my micropython libraries.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Difference between SRAM & SPIRAM

Post by kevinkk525 » Mon Nov 12, 2018 10:25 am

You can find a benchmark here too: viewtopic.php?f=2&t=5173
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: Difference between SRAM & SPIRAM

Post by loboris » Mon Nov 12, 2018 11:20 am

For all practical usage (especially in an environment such as MicroPython) there is almost no difference between using internal RAM and external SPI-RAM.

Main reason for that is the fact that the ESP32 code is executed from Flash which is an external, SPI connected, device.
Flash read operations are buffered, but in a large application such as MicroPython, the called code can be located anywhere in Flash (mostly outside of the Flash read buffer) and reading from Flash into flash buffer occures frequently.

In MicroPython, external SPI-RAM is used only for MPy heap (if some C functions are not written to use it) and only the MicroPython heap objects are accessed from it.
During the heap object acces, usualy quite large number of C functions are called (both MPy and esp-idf functions) which causes large number of Flash reads and this has much more impact on execution speed than RAM acces speed.

The practical speed difference between using internal RAM and external SPI-RAM is 10% - 90%, depending on function and optimization used.

Post Reply