poll vs. epoll

Shachar Shemesh wine-devel at shemesh.biz
Fri Aug 20 01:55:15 CDT 2004

Dan Kegel wrote:

> Shachar wrote:
>> I noticed that in server/fd.c, the wineserver is using "poll" to 
>> select between file descriptors. The application is going through 
>> this code over 2000 times a second, with over 380 file descriptors 
>> each time. I am wondering whether this can be the cause of the slowdown.
>> One of the possible solutions to this would be to use epoll instead. 
>> This, of course, would have to be backed by a configure check, as not 
>> all systems for which wine is intended support epoll. Another, 
>> arguably better, solution would be to use libevent for this purpose. 
>> Libevent has the distinct advantage that it automatically chooses the 
>> best tool for the job (epoll, poll, /dev/poll, or if all else fails, 
>> select).
> By all means, let's try epoll.
> FWIW, I wrote a wrapper layer that illustrates how to detect
> whether epoll etc. are available.  I'm convinced that *runtime*
> detection is the only way to go.  Compile time detection is insufficient.
> My code is at http://kegel.com/rn

Sure will have a look.

> If you actually try to use it, let me know.  I expect it might
> be useful mostly as a guide.  It's edge-trigger oriented, but
> you can trivially add the flag (or remove the flag) needed to
> get level-triggered behavior again if you really need it.
> I highly recommend using edge-triggered behavior, though.

I'm sure that edge trigger yields better performance. The problem, 
however, what with all the potential races edge trigger introduces, and 
the fact I'm not sufficiently familiar with the wineserver semantics, 
that going edge trigger in a bug free way right now is beyond me.

> - Dan

Shachar Shemesh
Lingnu Open Source Consulting ltd.

More information about the wine-devel mailing list