Edge-triggered interfaces are too difficult?
[Posted March 11, 2003 by corbet]
The new epoll interface was covered here
back in
October, 2002. The epoll system calls offer a significant performance
improvement for applications which must frequently poll large numbers of
file descriptors. It does so by performing the setup work only once, and
then trapping new I/O events as they occur.
One aspect of the epoll interface is that it is edge-triggered; it
will only return a file descriptor as being available for I/O after a
change has happened on that file descriptor. In other words, if you tell
epoll to watch a particular socket for readability, and a certain amount of
data is already available for that socket, epoll will block anyway. It
will only flag that socket as being readable when new data shows
up.
Edge-triggered interfaces have their own advantages and disadvantages. One
of their disadvantages, as epoll author Davide
Libenzi has discovered, would appear to be that many programmers do not
understand edge-triggered interfaces.. Additionally, most existing
applications are written for
level-triggered interfaces (such as poll() and
select()) instead. Rather than fight this tide, he has sent out
a new patch which switches epoll over to
level-triggered behavior. A subsequent
patch makes the behavior configurable on a per-file-descriptor basis.
The end result is a more flexible epoll interface that can be more easily
used in existing applications. The patch has not been merged as of this
writing, but there does not seem to be any reason why it shouldn't be.
After all, epoll has not yet appeared in a stable kernel release; now is
the best time to be making improvements to the interface.
(
Log in to post comments)