Page 2 of 2

Re: Difference between SRAM & SPIRAM

Posted: Mon Nov 12, 2018 3:33 am
by jickster
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

Re: Difference between SRAM & SPIRAM

Posted: Mon Nov 12, 2018 7:21 am
by pythoncoder
As a matter of general interest there are some benchmark results in the original Loboris thread.

Re: Difference between SRAM & SPIRAM

Posted: Mon Nov 12, 2018 10:25 am
by kevinkk525
You can find a benchmark here too: viewtopic.php?f=2&t=5173

Re: Difference between SRAM & SPIRAM

Posted: Mon Nov 12, 2018 11:20 am
by loboris
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.