Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

LittleFS is terribly slow at saving settings (partial file rewrite) #7271

Closed
TD-er opened this issue May 4, 2020 · 7 comments
Closed

LittleFS is terribly slow at saving settings (partial file rewrite) #7271

TD-er opened this issue May 4, 2020 · 7 comments

Comments

@TD-er
Copy link
Contributor

TD-er commented May 4, 2020

As also mentioned before in #5932
I have now changed the code in ESPEasy to be able to switch between SPIFFS and LittleFS using a single define (or simply changing the PIO env label). See: letscontrolit/ESPEasy#3052
So I will now be testing LittleFS a lot on my test environments.

The read speed of Little FS is a lot (!!) faster than SPIFFS, but the write speed of our settings is awfully slow.
Saving settings:

  • 67 msec on SPIFFS
  • 2285 msec on LittleFS.

During write the node is completely blocked, so this is unacceptable slow.
The settings file we have is way too large to keep in memory.
I only update a part in the file (always start at multiple of 1k block in the file).

I would like to know what would be the best approach for fixing this as SPIFFS was unusable slow for larger file systems (> 1 MB), but this is really unusable slow for writes. (updates in a file)

@earlephilhower
Copy link
Collaborator

This is a known "design choice" of LittleFS: littlefs-project/littlefs#244

The simplest thing I can suggest is to split the file into objects. Make a subdir of the name of the file, and record individual objects in their own files in that subdir.

OTW, I suggest you open a new issue on upstream https://github.com/ARMmbed/littlefs/ to let them know that this design choice kind of sucks for a large class of applications...

@TD-er
Copy link
Contributor Author

TD-er commented May 5, 2020

I've been thinking about this a bit more.
What I can do is split the parts of my settings file into separate pieces. But that makes backup or share of the file a lot more difficult.
So then I should make some special handler to combine them into a single file when it is requested as a single file.
But to me it seems like this should be part of the file system's task.
The file system should then have the option to set a flag to a file to mark it as "random write" or perhaps a more appropriate described flag.
This flag then under water stores the file in blocks of 4 or 8 k (for example) in a special directory.
When accessed it should then translate the calls for read/write into those separate file accesses.
Only problem then may be that you are using a lot more file handlers.

Is that some limit you're aware of?

@earlephilhower
Copy link
Collaborator

File handles are just extra memory. There's no hard-coded limit in littlefs or the 8266 File class. However, what you're discussing seems like basically making a new filesystem with all the corner cases/etc. that any other would need. Just in this case, instead of writing to flash, you're writing to a 4K file in LittleFS (which then writes to flash).

If it's just export/import, what about a basic streaming format like tar? Or simply concatenate the blobs together on export and then break them up on import?

@devyte
Copy link
Collaborator

devyte commented May 6, 2020

There are no other known alternatives: it's either spiffs or littlefs. Spiffs upstream went stale, so we deprecated that for now. I suppose somebody could pick up spiffs maintenance, but it's been three years now.
If anybody knows an alternative fs that is reasonably fast in all cases, is safe against power cuts, is compatible with our license model, and has wear leveling, I'm all ears. Or eyes, as it were.
Closing, because there's nothing we can do about it at this time.

@devyte devyte closed this as completed May 6, 2020
@TD-er
Copy link
Contributor Author

TD-er commented May 6, 2020

What term do you plan for the deprecated state of SPIFFS and when is it no longer available in this library?

As mentioned, LittleFS is in our use case not a good replacement for SPIFFS, so I do need to dig into it to make our file handling fit LittleFS.

@devyte
Copy link
Collaborator

devyte commented May 6, 2020

Per internal discussions, spiffs won't get pulled any time soon. The earliest, and this likely won't happen given the limitation reported here, would be v3.
You have time.

@TD-er
Copy link
Contributor Author

TD-er commented May 6, 2020

Thanks.
I will of course try to make ESPEasy and LittleFS get along.
I'm not sure what side of it will have to change :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants