-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get best performance from LittleFS #1033
Comments
Hi @ashiroji, thanks for creating an issue. I suspect you're running into the same issue as in #27, that is littlefs doesn't really implement random writes efficiently. Writes to the beginning of files (such as headers) will cause the entire file to be rewritten. It's interesting to note you wouldn't have seen this with the separate unit tests as you need both the data and header updates. This is a known issue, and there's work ongoing to improve this, but it's also a pretty significant/long-term change (rip out and replace the core file data-structure). As for workarounds, the best option is probably to store the header and data as separate files, and concatenate later if you need to match a specific file format. Depending on how you transfer files from the device, you could even do this concatenation transparently to the recipient of the file.
There are quite a few options here. One option is to start with lfs_filebd, which maps littlefs's block device API onto a local file, modifying/extending as necessary. Another option is to fork littlefs's test/bench runner, which is what littlefs uses to run its test suite locally, simulate powerloss, etc. It's powerful but also very strictly provided "as is", has little/no documentation, susceptible to change, etc. The best way to get started with the test/bench runner would probably be to look at some of the existing tests (tests/test_dirs.toml for example), run the tests, and poke around the test runner to see how it works: $ make test - j
$ make test-runner -j && ./scripts/test.py runners/test_runner test_dirs
$ ./scripts/test.py --help It would be nice to document this part of the build system better, but right now it's been low priority. |
Thank you very much for your help. |
Hi again, I get a much better performance, here are the numbers for the fusion of both files:
The downside of this method, is that maximum possible file to create is only half of the available memory, in order to have enough space for the copy afterwards. Thank you for your help. Looking forward for the new version of littleFS |
Hello,
In the current project, I'am using LittleFS (through Zephyr OS) with an external flash memory to store sensor data in a specific file format.
I am using the following Flash memory GD25LB256 (256Mbits) configured in SPI (it supports QSPI too and the HW connections are already made)
I would like to be able to buffer 1 minute of data (29,29Kbytes) and then store it in the flash.
The file format used contains an ASCII header (the first 512 bytes) and data.
Every time the file is appended, the header must be updated to maintain consistency.
The typical scenario is following:
At the moment, we identify 3 operations:
Unit testing each function independently gives reasonable execution time:
But when combining all functions together, the header update operation execution time grows exponentially.
I've read through a lot of the issues online (especially here) and I'm not sure if my problem is due to a bad configuration or that I'm hitting a bottleneck in LittleFS implementation.
If you can offer some expertise and architectural advice to handle this in a better way that would be appreciated.
It would also be helpful, if you can show me how to use LittleFS with a simulated flash
Thank you for your time and help
The text was updated successfully, but these errors were encountered: