-
Notifications
You must be signed in to change notification settings - Fork 797
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
lfs_rename sometimes very slow #327
Comments
I've tried suspending all other tasks during flash operation and suspending all other tasks during the lfs_rename but still saw the same problem in both cases. |
Our LittleFS configuration is:
One thing that might unusual about what we're doing is that the log files are almost always very small when they're renamed, usually 112 bytes but sometimes up to 336. I'm assuming that means that the file data will be stored inline. |
Hi @kevinior thanks for reporting. Is it possible LittleFS is hitting a block allocation scan cycle? I should add a debug statement, if it is it would be hitting this line: If this is the case it's unfortunately an outstanding issue that we're working on but don't have a good fix for yet: You can try increasing the block_size to a multiple of the underlying device's block size. This may help as a short-term solution by reducing the number of logical blocks that need to be scanned when finding free blocks. |
Thanks for the reply @geky I'm currently running a test with debug output at that line to check if that's what's happening in our case. After that I'll try increasing the block_size. Would there be any benefit for us in increasing |
I've just run a test where the problem was observed but didn't hit that line in Now I'll see if increasing the block_size helps. |
I can reproduce the slow rename issue using the test program with emubd and the settings from the test program. When it goes slow, it does more read i/o. Normally it reads less than 5k bytes to do a rename. When it takes a long time, this increases to > 50k bytes. The number of bytes programmed goes up a bit -- say from 50 to 150. [I'm using the |
I have this issue too; mainly after doing a lot of writes and it appears as if the rename function is the only one that has issues. I have switched from SPIFFS to LITTLEFS due to the performance but these hickups make my FreeRTOS have timing issues. |
We are also seeing long lfs_rename execution times, same as described: normally very quick, but every 10-16 renames takes 2-3 minutes to complete. Lots of reads indeed, no errors that we've seen, it just takes forever. Any insights on what to try would be appreciated. |
@geky We changed our application so that we weren't renaming files as often but the problem has appeared again (it just takes longer to appear). We're now on LittleFS v2.3. Are there any configuration tweaks that will help? Our current configuration is:
|
It looks like (at least in our case) this is related to #376 . I have a test program using rambd on Linux that creates a data directory (in /) and fills it with some files. Each time round the loop it (recursively) deletes any directories called trashX, renames the old data directory to trashX (X is a unique number) and creates a new data directory. Using the settings in my previous comment I was seeing peaks where an After reading #376 I tried making sure that both the data directory and trashX directories were created in subdirectories rather than root. This dropped the peak read count for |
We experience very long locking of the FS if we perform a single rename (more 12s) The hardware is pretty solid:
littlefs version 2.4.1 (issue also existing on 2.2.0) Too simplify the issue and reproduce easily.
Then in loop
Usually each rename of the loop requires 4000+ flash read operations (96K of data) and a single write, no erase. ... It looks to be a lot for a FS filled with 100 files and 26KB of data (the more files and/or data, the longer is the lock) I will try to analyze what is done, but this scenario may sound a bell to the littlefs developers. |
Hello. |
I'm working on a system where we're logging data to LittleFS (v2.1.2). We periodically rotate the log by renaming the file. There's also some logging of debug and error messages going on in a similar way.
Usually the call to lfs_rename takes less than 100 ms but I've seen a pattern where the execution time slowly starts to increase. When it reaches about 250 ms it will usually drop back down to <100 ms but sometimes it instead suddenly takes 2 or 3 seconds.
I haven't been able to come up with a minimal test program that reproduces the behaviour. In our real application we use FreeRTOS and have a few tasks using the filesystem. There's a mutex controlling access to the filesystem, so only one task can perform LittleFS operations at a time. In fact there's only ever one file open at a time.
I've also timed the underlying flash operations (it's a Winbond W25Q64JV) and none of those are ever taking more than 100 ms.
So is this expected behaviour for lfs_rename and is there some way of tuning LittleFS so that this doesn't happen?
The text was updated successfully, but these errors were encountered: