NVS occasionally takes a long time to initialize

Our product is using NVS to manage settings in external flash.  The normal NVS initialization time is between 1 to 3 seconds at boot.  Occasionally I have witnessed 10 to 15 seconds.  I trapped it one time and was able to trace through the initialization.  I found that the time was being spent in garbage collection.  Once this was done, subsequent NVS initialization returned to the normal 1 to 3 seconds.  My question is what conditions in the external flash would cause NVS to spend that much time in garbage collection?  We are using v1.8.0 of the nRF SDK.  We allocate 16 4k sectors for NVS to manage.

Parents
  • nvs_mount which can cause the nvs_gc (garbage collection) to trigger is an synchronous procedure. If the mount is happening in the lower priority thread (like main) while other higher priority threads are already functioning, then there is a possibility that the garbage collection might be starving for sometime. I did not find any benchmarks on our end on how fast the gc should perform on different conditions. I would check what other higher priority threads are running in your system when the gc takes about 15 seconds.

Reply
  • nvs_mount which can cause the nvs_gc (garbage collection) to trigger is an synchronous procedure. If the mount is happening in the lower priority thread (like main) while other higher priority threads are already functioning, then there is a possibility that the garbage collection might be starving for sometime. I did not find any benchmarks on our end on how fast the gc should perform on different conditions. I would check what other higher priority threads are running in your system when the gc takes about 15 seconds.

Children
No Data
Related