Skip to content
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

Every write triggers block erase #581

Closed
davidk88 opened this issue Jul 15, 2021 · 4 comments
Closed

Every write triggers block erase #581

davidk88 opened this issue Jul 15, 2021 · 4 comments
Labels

Comments

@davidk88
Copy link

Hi,

I'm using release littleFS 2.4.1

is it normal that every (append) write triggers new block erase and all data from previous block is copied to a new block. This happens if file is opened-written-closed or open all the time and only written and synced after write. Every write is just around few 10 bytes. And only when file is outlined.

Operations starting to get very long after file reaches a few kilobytes.

I'm using 16MB flash with 64K erase block.

Thank you

@davidk88
Copy link
Author

Related:

#344
#374
#564
#541

@SadE54
Copy link

SadE54 commented Aug 2, 2021

@davidk88 Did you solved your problem ?

@davidk88
Copy link
Author

davidk88 commented Aug 3, 2021

No, I did not use littleFS then.

@geky geky added the question label Aug 3, 2021
@geky
Copy link
Member

geky commented Aug 3, 2021

Hi @davidk88, yes each append requires a full rewrite of the block when you sync the file.

Two mechanisms that avoid this:

  1. LittleFS has a concept of inline files that are stored in the metadata logs. If the data you write is <cache_size and <1/8th block_size than the data will be directly written into the log avoiding the rewrite.
  2. LittleFS avoids full writes until you call lfs_file_sync or lfs_file_close. So multiple small writes should be coalesced into a single write. If you need to sync for power-resilience reasons than this isn't that helpful.

There was some discussion previously about expanding the inline mechanism to also store small appends to files, in order to avoid this rewrite cost in some cases, but it would add quite a bit of complexity to the internal file logic. I'd like to explore it but it's relatively medium priority[1] at the moment.


[1] there are enough high priority tasks that medium priority should not be expected any time soon, unfortunately, unless someone contributes an implementation.

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

No branches or pull requests

3 participants