Subject: Re: default maximum number of open file descriptors too small?
To: Luke Mewburn <lukem@telstra.com.au>
From: Bakul Shah <bakul@netcom.com>
List: tech-kern
Date: 11/28/1995 11:27:45
> Another idea (that I thought of in the shower this morning) is to
> rename select to oselect, and to redefine fd_set as something like:

>         typedef int32_t fd_mask;
>         typedef struct fd_set {
>                 size_t   fd_size;
>                 fd_mask *fds_bits;
>         } fd_set;
> Have the new select use this new type.

I do something similar in the userland -- I have a class
FDset with the necessary operations: add, remove, is_member,
clear, copy, members etc.  The last operation returns a list
of ints, corresponding to 1 bits in the bitvector; this list
is much easier to work with.  This also allows me to hide
machine dependencies (since under winsock (on NT/Windows)
fdset_t is a list of ints, much like the members()
function).

But I am not sure if the idea you suggest is sufficiently
radical :-)  It is a small reworking of the interface and
generally people are reluctant to change for a small
benefit.  Basic problem with select() is that it does not
scale well.  Even if 3 bits are set, the entire set (upto
nfds) must be traversed.  The second problem is that
implementing fair service can be painful -- so people punt
on it and earlier fds end up getting lion's share of service
and can `starve' or delay service to higher numbered fds.
Also, since read/write fdset membership does not change all
that much, it would be much more efficient if the arg list
to select was `compiled' in some fashion.  Finally tying
select() with some async facility would be very helpful.

So if you really want to fix select(), come up with something
much more useful!