-->
Page 1 of 2

Best practice using SPIFFS

PostPosted: Tue Oct 13, 2015 3:51 pm
by andrew melvin
Beginning to do work with SPIFFS on the arduino IDE, and I have some questions....

I'm going to try and use SPIFFS instead of storing big arrays in RAM. I'm concerned with heap usage, and speed.

1) If i open a file, I use about 120Bytes of heap, so not much. is this really the overhead of having a file open?
2) Is having more than one file open at a time acceptable (Seems to maintain the 120bytes of heap, even 120bytes for 3 files) as writing to an open file is super fast, whereas .. see below..
3) Is it acceptable to open a file, and keep it open? are writes immediately saved... because close() takes around 3-4ms.

just wanting to know more about how it all works?

many thanks all

Re: Best practice using SPIFFS

PostPosted: Sun Oct 18, 2015 9:36 pm
by SPComputing
I can think of no good reason to keep a file open longer than the time it takes to write a record's worth of information. If open too long, something invariably happens and the file is corrupted.

Best wishes and good luck!

Re: Best practice using SPIFFS

PostPosted: Mon Oct 19, 2015 1:27 pm
by lalo_uy
To be sure that a write is in the media, either close or flush the file.

Re: Best practice using SPIFFS

PostPosted: Sat Oct 24, 2015 3:22 pm
by bbx10node
I did some performance testing that might be helpful. Writes are slow on a Huzzah board. Not sure if this true for all boards. Also the test runs out of free space even though the test file is removed between test cycles. I have not dug into the source code yet.

https://github.com/bbx10/esp-spiffs-test

Code: Select allSPIFFS Performance
49585 msecs
1048576 bytes
21147 write bytes/sec
2216 msecs
1048576 bytes
473184 read bytes/sec
SPIFFS Performance
write failed
SPIFFS Performance
open for write failed