You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm using littlefs to record some logs. The log is a ring buffer, so it overwrites the oldest one when the file reaches the max size. However I found the performanc drops significantly when overwriting. Below is my code to reproduce the problem.
The first peak is caused by overwriting the 100K data written first. And the second peak is caused by overwriting the data from the beginning.
Seems that write operation that changes existing data causing littlefs to rewrite all data after. Is this some intended behavior? And is it possible to avoid this?
The text was updated successfully, but these errors were encountered:
Ah yes, this is one of the main areas of LittleFS that needs work. Random writes are implemented by effectively rewriting all data that follows. As you can imagine this leads to terrible performance when you modify a small part of the beginning of a file. (tracked here: #27)
There are plans to improve this, but unfortunately this just how it is at the moment.
For your use case, one option is to have 2 files that you switch between so you are never rewriting.
Something like:
if (wc >= 32000 / 5) {
// note that lfs_rename implicitly deletes tt-old if it existserr=lfs_rename(&lfs, "tt", "tt-old")
assert(err >= 0);
}
Hi, I'm using littlefs to record some logs. The log is a ring buffer, so it overwrites the oldest one when the file reaches the max size. However I found the performanc drops significantly when overwriting. Below is my code to reproduce the problem.
And the configuration is
This is the performance data that I collected: https://pastebin.com/2EsJ9Ey9
And the chart drawn from the data:
The first peak is caused by overwriting the 100K data written first. And the second peak is caused by overwriting the data from the beginning.
Seems that write operation that changes existing data causing littlefs to rewrite all data after. Is this some intended behavior? And is it possible to avoid this?
The text was updated successfully, but these errors were encountered: