> been reading the select(2) man pages and it mentions poll(2)
> being more efficient in most cases. this makes it obvious to
> discard the use of select(2) in writing new servers.

select requires that you set up a bit array correctly.  but often
people just use a fd_set, and cause a variety of strange buffer
overflow cases as soon as their fd's happen to be greater than the bit
size of the fd_set.

the kernel has to iterate over these bit arrays a few times.

for everyone involved, poll is just plain cheaper.

finally, go look at the latest commit to lib/libc/net/res_send.c to
see how much easier poll() is to use.

> i've come across some performance benchmarks which is trying
> to use kqueue(2).

shrug.  performance is only a small part of the whole.

> the question is, which one is more useful when writing new servers?
> kqueue or poll?

use poll.  it is easier to use -- the behaviours are less surprising.
it is also much more portable.  everyone has select and poll, and
quite honestly poll() is a better select(), even if it came out of
AT&T.

Reply via email to