Selection / Polling Performance vs. Asynchronous I / O

In terms of performance, which one is better? selection / polling or asynchronous I / O? My previous impression: selection / polling repeatedly queries the kernel for data, while asynchronous I / O relies on the kernel notifying you of data availability. However, I noticed that select / poll also relies on kernel notifications. So, I believe that in terms of performance, both of them are the same. The only difference is that the select / poll blocks, while asynchronous I / O does not work. Am I missing something right?

+2
source share
2 answers

select / poll also relies on kernel notification for off-the-shelf file descriptors. But the drawback of select / poll is that they are blocked as soon as they are called, because the Systemcall-Handler runs in a kernel-space.

Real asynchronous I / O is via LibAIO (on Linux) and IOCP on Windows. As far as I know, they do not block the calling process / thread in user space, and they allow real overlapping I / O.

This means that asynchronous non-blocking I / O (LibAIO and IOCP) is faster because it does not block the calling thread and they allow real overlapping I / O. Selection / polling is also asynchronous, but they are asynchronous locking. Both btw select and poll suffer from other specific problems, so they cannot scale so well.

I hope I can help. (I'm new too :))

+2
source

With asynchronous I / O, you must constantly contact and check if there is new data to read periodically. This makes it intense. Selection / polling simply blocks without consuming processor power. It does not work inside.

-1
source

Source: https://habr.com/ru/post/1369221/


All Articles