Re: Timings for optimised poll(2)

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 26 Aug 1997 13:33:44 +0200 (MET DST)


Richard Gooch wrote:
>
> As Dean has already pointed out, if you want to check for activity on
> a few fds which all have large numbers, then select(2) has to scan
> through a large number of bits. So in this case poll(2) has less work
> to do.
>
> Example timings (Pentium 100):
> 1021 file descriptors (3-1023), check for activity on 1014-1023
>
> Using a select(2) loop like this:
> memcpy (&i_fds, &input_fds, sizeof i_fds);
> memcpy (&o_fds, &output_fds, sizeof i_fds);
> memcpy (&e_fds, &exception_fds, sizeof i_fds);
> nready = select (max_fd + 1, &i_fds, &o_fds, &e_fds, &tv);
> takes 362 microseconds.
>
> Using a poll(2) loop like this:
> nready = poll (pollfd_array + start_index, num_to_poll, 0);
> takes 93 microseconds.
>
> Now, if we change the test to do checks on descriptors 924-1023:
> select(2) takes 1274 microseconds
> poll(2) takes 1023 microseconds.
>
> And now if we check descriptors 24-1023:
> select(2) takes 3897 microseconds
> poll(2) takes 4221 microseconds.

Richard,

It could very well be that poll has adavantages over select. However
if you want to introduce a non-standard API into the kernel, you
should think about it very well before just jumping in and doing it.
(Well, what you do privately on your computer doesn't really matter).

In this case you claimed that "select" showed a bottleneck somewhere.
You supported your claim by submitting an awfully inefficient piece of
code.

In general you've already made up your mind before you start
benchmarking, and it is hard to make the enemy look good by writing
good code for the "enemy".

Now it seems that you are finally running the right benchmarks, and
that is a good thing.

Doing the right thing for the wrong reasons is "bad".

If you really are doing the right benchmarks and those indicate that
your new approach is promising, then I say you should go for it.

Roger.

P.S. For sparse bitvectors the select code should probably scan the
in, out and ex set separately, and use "find_first_zero" like calls.