4 ms·
> It's probably about 50 lines of C to code up a file tree walk recursion and test it yourself. This is exactly what I was doing, fwiw. I can't match up a lot
by R0b0t1 5y ago
> It's probably about 50 lines of C to code up a file tree walk recursion and test it yourself.
This is exactly what I was doing, fwiw. I can't match up a lot of the extra calls to close(2) but if you're doing what find does you need to be calling newfstatat(2) to get file information. I'll look again -- there may be a way to get these faster. It was something I was going to propose putting into io_uring.
- cb321 5y agoYou need not newfstatat every dirent unless you need more metadata (times, size, etc.) for something else (as alluded to above by, at least, both me and bscphil elsewhere in this thread). You can simply try to call `opendir()` based upon `d_type`. See [1]. IIRC, this d_type in dirent usage is somewhat new (maybe mid- to late- 1990s) compared to Unix itself. In olden times, one had to stat. It is possible the filesystem you are testing on gives DT_UNKNOWN all the time mandating stats. [2] [1] https://lobste.rs/s/kpzdew/git_ls_files_is_faster_than_fd_find#c_nal5fc https://lobste.rs/s/kpzdew/git_ls_files_is_faster_than_fd_fi... [2] https://stackoverflow.com/questions/47078417/readdir-returning-dirent-with-d-type-dt-unknown-for-directories-and https://stackoverflow.com/questions/47078417/readdir-returni...