Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dfs: add fast lookup table for files
Currently, looking up files on dfs is quite slow. Every time a fopen() is done (or a dfs_open), the filesystem code scans the whole filesystem looking for a file matching the requested one (it actually does do that in a directory aware way, but it still needs to scan linearly directories to look for matches). "Scanning" means reading one filesystem sector via PI for each file, linearly. This basically happens because dfs doesn't have a real "directory" sector that stores the list of all the files with pointers to them. This commit adds that. It adds a global datastructure, indexed by filename hash, loaded once at filesystem mount, that allows to quickly lookup for a file. It also starts parting with the approach of DFS having the concept of "current working directory", which is basically never used in libdragon producitons (and also, if needed, shouldn't be part of the filesystem code but possibly a higher level). Doing a test with 1000 files in the filesystem (measures are CPU ticks): OLD CODE: best=10,357, worst=2,677,366 NEW CODE: best= 980, worst= 3,976
- Loading branch information