-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
NVS manual garbage collection (IDFGH-13397) #14305
Comments
The different response of NVS api in the "empty" vs "full" scenarios are result of different way, the free space for the newly written data is discovered. If the NVS has already written into all the 4k pages reserved to it, subsequent attempts to write the data can either fit into the remaining space in the active NVS page (then it is fast) or needs to reclaim some space from the NVS pages marked as full (with some entries in it marked as erased). Then the "local" defragmentation takes place as a part of the nvs_set_* operation. Which, because of its unpredictability, causes annoying delays. If I understand your proposal, you would like to extend the API by function defragmenting the complete NVS space. In the context of this proposal, what exactly is meant by the note: "It might be nice to be able to specify a limit in terms of time." ? Please share also more about the granularity of data storage (whether you use blob or store individual items using single entry operations) and frequency of updates. |
Hi @rrtandler, you understand my problem well.
Optional partial defragmentation. On startup, I'd like to defrag the whole partition. But once our UI is running, sometimes there are better times to defrag that are not be long enough to defrag the entire partition, then I might like to request defragmentation, but once defragmentation exceeds the specified time, please return soon.
We have a 64KB NVS, about 25% utilization on most devices, mix of items:
|
Hi @bryghtlabs-richard - sorry for late response. I'll take this topic to our internal feature candidate discussion. |
Thank you kindly. I haven't had time to look into this myself, but it still causes our UI animations to stutter sometimes - it seems almost every time the 8KB blob is updated during an animation the UI stutters. I wonder if a different way to specify would be useful - If I could specify that NVS defrag until at least 12KB of space were free, or the time limit were exceeded, this would keep my UI working, without defragging unnecessarily. |
There is one thing that comes to my mind related to the animation blocking. Is your animation using separate FreeRTOS task to create the animation in parallel to the task calling the NVS blob update ? |
It occurs in both cases:
|
I have consulted options that might help you at the moment and there are actually 2 potential settings in place:
|
Thanks for those ideas Radek,
|
Thanks for the update, At the moment, we do not have plan for implementation of NVS defragmentation. While this is true, I was already thinking of how to implement it and as a side effect, following NVS use scheme came to my mind when taking into account your particular use case.
Hope it could inspire you and help. Radek |
Is your feature request related to a problem?
When NVS has plenty of erased space, writes are fast. But after NVS has been fully written writes require erases of previously written data, which make my UI stutter.
Describe the solution you'd like.
I would like the ability to request garbage collection and erasure of free space at a time when it makes sense for my application, similar to TRIM command for managed Flash SSDs. Once complete, most unused space in NVS would be erased.
Describe alternatives you've considered.
I've considered deferring writes or commits to NVS, but this is not a great workaround, as it increases the time where data may be lost before NVS writes to Flash.
Additional context.
It might be nice to be able to specify a limit in terms of time.
The text was updated successfully, but these errors were encountered: