select/poll 与异步 I/O 的性能
从性能角度来看,哪一个更好?选择/轮询还是异步 I/O?我之前的印象是 select/poll 反复向内核请求数据,而异步 I/O 则依赖于内核通知数据可用性。但是,我注意到 select/poll 也依赖于内核通知。因此,我相信从性能的角度来看两者是相同的。唯一的区别是 select/poll 会阻塞,而异步 I/O 则不会。我是正确的还是我错过了什么?
From a performance standpoint, which one is better? select/poll or asynchronous I/O? My earlier impression was select/poll repeatedly asks the kernel for data, whereas asynchronous I/O relies on kernel's notification for data availability. However, I have noticed that select/poll also relies on kernel notifications. So, I believe from a performance standpoint both are same. The only difference is that select/poll blocks whereas asynchronous I/O does not. Am I correct or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Select/poll 还依赖于内核通知以获取就绪文件描述符。但 select/poll 的缺点是它们一被调用就会阻塞,因为系统调用处理程序在内核空间中运行。
真正的异步 I/O 是通过 LibAIO(在 Linux 上)和 IOCP(在 Windows 上)实现的。据我所知,它们不会阻塞用户空间中的调用进程/线程,并且允许真正的重叠 I/O。
这意味着异步非阻塞 I/O(LibAIO 和 IOCP)更快,因为它不会阻塞调用线程并允许真正的重叠 I/O。 Select/poll也是异步的,但它们是异步阻塞。顺便说一句, select 和 Poll 还存在其他特定问题,因此它们无法很好地扩展。
Select/poll also relies on kernel notification for ready file descriptors. But the disadvantage of select/poll is that they block as soon they are called because the System call handler runs in kernel space.
Real asynchronous I/O is achieved via LibAIO (on Linux) and IOCP on Windows. As far as I know they don't block the calling process/thread in the User Space and they allow real overlapped I/O.
That means asynchronous Non-Blocking I/O (LibAIO & IOCP) is faster because it does not block the calling Thread and allow real overlapped I/O. Select/poll are also asynchronous, but they are Asynchronous Blocking. And btw select and Poll suffer from other specific problems so that they can't scale that well.