3 ms·
Ask HN: Why isnt there a syscall to read/write to multiple file desc. on linux?
I am currently playing around with linux epoll interface in order to better understand boost.io and libuv. Upon epoll returns, It looks like the ready file descriptors have to be processed in sequence with one system call per ready file descriptors. Is there a better pattern to process multiple ready file descriptors?
PS : Linux has a vectored/io interface but it does not seems to support multiple fds.
- JoachimSchipper 10y agoNo, there's no better pattern than select/poll/epoll/kqueue-then-multiple-read. Using many threads or async I/O can allow you to handle multiple file descriptors, but these are hardly convenient - and it's easy to end up with less-performant code.
- JoachimSchipper 10y agoFwiw: you can, however, send multiple datagrams to multiple hosts with sendmmsg(). Still one socket at a time, but...
- wmf 10y agoLinux is based on the idea that system calls are cheap (whether this idea is correct or not), so they prefer to avoid system calls that perform multiple operations. But there has been research on this topic: https://www.usenix.org/node/170841 https://www.usenix.org/node/170841 https://www.usenix.org/node/186147 https://www.usenix.org/node/186147