SPIFFS performance too bad?

gongli
Posts: 10
Joined: Fri Dec 21, 2018 2:56 am

SPIFFS performance too bad?

Postby gongli » Mon Dec 24, 2018 4:21 am

Hi, I found fopen/fread spiffs files on my board are extraordinary slow.

The board I have is an ESP32-WROVER-B board with 16MB spi flash. About 10M of the flash is partitioned as spiffs.
On the spiffs, there are several files arranged in at most two level sub directories. Sizes of the files range from several KBs to several hundreds KBs.

As I observed, a fopen can take hundreds of milliseconds to several seconds, while a fread take up to several seconds, for files at about 500KB. The fread is carried out slice-by-slice, with a single slice of size 4KB.

In my use case, these file operation is not time critical. However, as they go far beyond my normal expectation. I wonder if these performances are normal?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: SPIFFS performance too bad?

Postby loboris » Mon Dec 24, 2018 9:52 am

This is definitely not normal.
Opening the file and reading should be quite fast (< 1ms per 4K block). Writing can be slow, as the sector has to be erased and that can take ~100 ms.

gongli
Posts: 10
Joined: Fri Dec 21, 2018 2:56 am

Re: SPIFFS performance too bad?

Postby gongli » Mon Dec 24, 2018 10:29 am

Thanks loboris for the reply. Any clue to the cause?

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: SPIFFS performance too bad?

Postby ESP_igrr » Mon Dec 24, 2018 11:02 am

Perhaps try increasing the page size? For the 10MB partition, 256 byte page size might be resulting in too many pages. I recall seeing such issues reported on the SPIFFS repository, although I can't find the exact link now...

gongli
Posts: 10
Joined: Fri Dec 21, 2018 2:56 am

Re: SPIFFS performance too bad?

Postby gongli » Tue Dec 25, 2018 3:06 am

Thanks for the hint. I tried increasing page size from 256 to 1024 which did no help. Worse, it's performance downgraded by ~50%. I also tried increasing block size from 4096 to 8192 or 32768, but they won't work (complained NOT A FS error). However, by reduce partition size to 4MB I can see more than doubled performance. Though still fall below some normal expectation.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: SPIFFS performance too bad?

Postby Ritesh » Fri Dec 28, 2018 7:07 pm

gongli wrote:
Tue Dec 25, 2018 3:06 am
Thanks for the hint. I tried increasing page size from 256 to 1024 which did no help. Worse, it's performance downgraded by ~50%. I also tried increasing block size from 4096 to 8192 or 32768, but they won't work (complained NOT A FS error). However, by reduce partition size to 4MB I can see more than doubled performance. Though still fall below some normal expectation.
Hi,

Would you please explain your scenario in details with statistical data as well? Also, Would you please try with direct file instead of creating file inside directory? Because there might be chances of getting delay while writing data into file system? Also are you using standard SPIFFS or loboris supported SPIFFS component?
Regards,
Ritesh Prajapati

gongli
Posts: 10
Joined: Fri Dec 21, 2018 2:56 am

Re: SPIFFS performance too bad?

Postby gongli » Sat Dec 29, 2018 8:43 am

Ritesh wrote:
Fri Dec 28, 2018 7:07 pm

Would you please explain your scenario in details with statistical data as well? Also, Would you please try with direct file instead of creating file inside directory? Because there might be chances of getting delay while writing data into file system? Also are you using standard SPIFFS or loboris supported SPIFFS component?
My use case is a small web server hosting several files (less than 10). The file sizes range from hundred bytes to hundred K bytes. In the performance observation only a single browser is connected.

The file system image is generated using mkspiffs https://github.com/igrr/mkspiffs

Code: Select all

mkspiffs -d 5 -c [directory] -b 4096 -p 256 -s 0x400000 spiffs.bin
The app uses api esp_vfs_spiffs_register() to mount the file system at run time.

A 4MB partition is designed for the spiffs:

Code: Select all

storage,  data, spiffs,  0x800000, 4M,
The module on board is an ESP32-WROVER-B with 16MB flash.

And put all files under root directory makes no difference. Listed below are some detaild time measurements. The fopen means time used for calling fopen(), flash for fread(), and socket for socket send(). Among these, the biggest file is app.js which is nearly 600KB.
I (292722) app: httpd.hpp:155 serving /spiffs/index.html in 16ms. fopen=4ms flash=10ms socket=2ms
I (292878) app: httpd.hpp:155 serving /spiffs/all.css in 98ms. fopen=0ms flash=82ms socket=16ms
I (294910) app: httpd.hpp:155 serving /spiffs/main.css in 2028ms. fopen=10ms flash=1872ms socket=146ms
I (294937) app: httpd.hpp:155 serving /spiffs/aisz.js in 22ms. fopen=5ms flash=14ms socket=3ms
I (294962) app: httpd.hpp:155 serving /spiffs/main.js in 20ms. fopen=9ms flash=8ms socket=3ms
I (300033) app: httpd.hpp:155 serving /spiffs/vendor.js in 5067ms. fopen=4ms flash=4149ms socket=914ms
I (307310) app: httpd.hpp:155 serving /spiffs/app.js in 7272ms. fopen=6ms flash=5940ms socket=1326ms

FoxTerrier
Posts: 3
Joined: Tue Sep 22, 2020 12:43 pm

Re: SPIFFS performance too bad?

Postby FoxTerrier » Tue Sep 22, 2020 12:45 pm

Hello,
I got exactly same problem as you (with same (not so good) solution : return to 2Mb SPIFFS in place od 8mb)
Did you finally find a real solution ? tune sspiffs settings ?
any advice ?

Thanks a lots !

Who is online

Users browsing this forum: Google [Bot] and 91 guests