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

SPIFFS write caching not working with FileStream #1679

Closed
mikee47 opened this issue May 2, 2019 · 2 comments · Fixed by #1680
Closed

SPIFFS write caching not working with FileStream #1679

mikee47 opened this issue May 2, 2019 · 2 comments · Fixed by #1680

Comments

@mikee47
Copy link
Contributor

mikee47 commented May 2, 2019

Excessive flash writing is occurring when using a FileStream for writing to a file in small chunks (e.g. serialising JSON data directly to a file stream). The behaviour is as if SPIFFS write caching isn't working at all.

Investigation shows that FileStream::write calls fileSeek before a fileWrite to ensure the data is written to the end of a file. The problem is that SPIFFS_lseek flushes the write cache, every time.

Removing the call to fileSeek fixes the problem and performance is restored. However, that's probably too simple as a proper fix as we'd potentially lose position tracking. Maybe arrange things so that fileSeek is only called if the file position has been changed, e.g. by another seek or read operation.

@mikee47
Copy link
Contributor Author

mikee47 commented May 3, 2019

The same thing will happen for anyone using the fileXXX API or SPIFFS directly. My feeling is that this is generally undesirable behaviour and SPIFFS could probably do with looking at.

@mikee47
Copy link
Contributor Author

mikee47 commented May 3, 2019

Bug also affects LTS branch

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

Successfully merging a pull request may close this issue.

1 participant