| ▲ | solatic 3 hours ago | |||||||
Headline is wrong. I/O wasn't the bottleneck, syscalls were the bottleneck. Stupid question: why can't we get a syscall to load an entire directory into an array of file descriptors (minus an array of paths to ignore), instead of calling open() on every individual file in that directory? Seems like the simplest solution, no? | ||||||||
| ▲ | cb321 3 hours ago | parent | next [-] | |||||||
One aspect of the question is that "permissions" are mostly regulated at the time of open and user-code should check for failures. This was a driving inspiration for the tiny 27 lines of C virtual machine in https://github.com/c-blake/batch that allows you to, e.g., synthesize a single call that mmaps a whole file https://github.com/c-blake/batch/blob/64a35b4b35efa8c52afb64... which seems like it would have also helped the article author. | ||||||||
| ||||||||
| ▲ | levodelellis 3 hours ago | parent | prev | next [-] | |||||||
Not sure, I'd like that too You could use io_uring but IMO that API is annoying and I remember hitting limitations. One thing you could do with io_uring is using openat (the op not the syscall) with the dir fd (which you get from the syscall) so you can asynchronously open and read files, however, you couldn't open directories for some reason. There's a chance I may be remembering wrong | ||||||||
| ▲ | stabbles 3 hours ago | parent | prev | next [-] | |||||||
What comes closest is scandir [1], which gives you an iterator of direntries, and can be used to avoid lstat syscalls for each file. Otherwise you can open a dir and pass its fd to openat together with a relative path to a file, to reduce the kernel overhead of resolving absolute paths for each file. | ||||||||
| ||||||||
| ▲ | arter45 3 hours ago | parent | prev | next [-] | |||||||
>why can't we get a syscall to load an entire directory into an array of file descriptors (minus an array of paths to ignore), instead of calling open() on every individual file in that directory? You mean like a range of file descriptors you could use if you want to save files in that directory? | ||||||||
| ▲ | justsomehnguy 2 hours ago | parent | prev [-] | |||||||
If you don't need the security at all then yes. Otherwise you need to check every file for the permissions. | ||||||||