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
[FATFS] calling stat() on every file in a folder is too slow (IDFGH-8788) #10220
Comments
So I may be pretty dumb! It looks like But, if I want to get filesize quickly as well, I would need to do something like this (reimplement edit: Just btw, to anyone that finds this thread, this code does work! it is so much faster!
|
While it is unlikely we would add a non-standard API like better_vfs_fat_readdir, we can do an optimization for this specific case. If implemented, this can close #9570 which I think was asking for a similar feature. |
That's a clever solution. Yes, that would be a great idea. |
When / if you implement caching, please consider adding it to the v4.4 branch as well. It'll be a massive improvement. |
In my project it can get up to 3-4 seconds per file just to query their size. This can't be right. Thanks @chipweinberger for your workaround! |
wow very impressive work @RathiSonika |
Is your feature request related to a problem?
Goal: get all paths in a folder that are directories (and ideally their filesize too)
stat()
is a very slow function. It takes 10+ seconds to callstat()
on 300+ paths in the same directory.But! it takes less than a second to call
readdir
on every path in the same directory.This is unfortunate because in the code ,
vfs_fat_readdir_r
already has all thestat()
information and just throws it away!Is there anything I can do to speed this up?
Describe the solution you'd like.
Not sure.
Perhaps I can call
f_readdir
myself directly? Some guidance here would be helpful.FRESULT f_readdir (
FF_DIR* dp, /* Pointer to the open directory object /
FILINFO fno /* Pointer to file information to return */
)
The text was updated successfully, but these errors were encountered: