3 ms·
Why files can't be read without blocking with Linux? There's certainly an API for this.
by vbezhenar 9y ago
Why files can't be read without blocking with Linux? There's certainly an API for this.
- signa11 9y ago> Why files can't be read without blocking with Linux? There's certainly an API for this. i guess you are referring to aio(7) ? posix aio on linux is implemented in glibc, and doesn't scale in presence of multiple threads. which is probably what is alluded to...
- nemanjaboric 9y agoWhich API are you referring to? If you're referring to `aio_` that's just glibc's user-space thread-pool emulation of the POSIX's asynchronous IO + many operations needed for the truly async IO are not supported (such as `stat` and `open`). There's `io_` syscalls family, but that's not in the ready-to-use state yet, judging by the manpages and various patches being submitted every month.
- vbezhenar 9y agoI'm referring to `fcntl(fd, F_SETFL, flags | O_NONBLOCK)`. `stat`, `open` are blocking, yes, didn't think about that. Also according to [1] file operations will always block, even in non-blocking mode, so I was wrong, sorry. 1: https://www.remlab.net/op/nonblock.shtml https://www.remlab.net/op/nonblock.shtml
- signa11 9y ago> ... Also according to [1] file operations will always block ... not quite :) look at aio(7)
- biokoda 9y agoio_ syscalls only really work on XFS and require O_DIRECT which means kernel is not caching anything. Unsuitable for web servers.
- deleted 9y ago[deleted]