3 ms·
> the cost of reading a lot of little files would be too high The `readfile()` system call will reduce that by some factor, though probably not as high as a fa
by cryptonector 7y ago
> the cost of reading a lot of little files would be too high
The `readfile()` system call will reduce that by some factor, though probably not as high as a factor of one third (it replaces three system calls with two, assuming it turns out to be useful). But getting all the data in one call will be even faster.
Incidentally, a typical read-all-of-this-file function in user-land allocates a buffer of the right size after doing an `open()` and then `fstat()` to find the file's size. Whereas a system call to read a file in one go really can't do that unless it establishes a memory mapping (which is... expensive). So I rather question the utility of this thing. Also, since one might not know what size buffer to give it, it might as well have an option to return an open FD. Or the app should have to `stat()` then `readfile()`, thus replacing three syscalls (`open()`, `fstat()`, `close()` with two -- bummer. Or the caller can `readfile()` repeatedly if the buffer given was not large enough (oof).
No, I'm pretty sure this `readfile()` can't possibly make reading lots of tiny files fast enough to not want a better solution for getting mounted filesystem metadata out of the kernel.
- ploxiln 7y agoOne of the cases posited is `ps` or `top` which (on linux) read /proc/[0-9]+/stat and /proc/[0-9]+/cmdline, and in these cases it knows the the max it will want to read (which is pretty small, maybe 512 bytes at most). So this can make `ps` or `top` 3x faster / more efficient.
- bicolao 7y agoThere must be other use cases besides ps and top to justify new syscalls right? ps and top are not exactly slow to even make these optimizations visible.
- deleted 7y ago[deleted]