Re: FD_SETSIZE problem on Linux

From: (no name) (no email)
Date: Fri Feb 20 2004 - 11:39:16 EST


On Fri, 20 Feb 2004, Michael Tokarev wrote:

> Each call to select() (or poll() for that matter) requires
> kernel to build internal data structures (for watching for
> events) from the data provided in the select()/poll() syscall,
> ie, to "decode" the user-supplied data into something non-
> trivial, and after the call is done, in-kernel structures
> needs to be converted back into whatever userspace wants
> (bits in fd_set or elements in pollfd array). At least
> this is how linux does that, may be other OSes manipulates
> directly on fd_set or pollfd[]. Each conversion takes
> quite some resources (mostly CPU), and grows (mostly
> lineary) with the number of filedescriptors being watched.

One could cache the structures and update only the bits that change with
the next call. The caching could be turned on only for processes that are
observed to do select a lot of descriptors.

>
> At the same time, more FDs being watched means an event
> occur more frequently, so select() will be called more
> often. So now we're seeing exponential grows of (CPU)
> resources needed.
>

I call this quadratic, not exponential, but indeed it would be useful to
be able to say "use the last bit mask with these changes". One saves the
CPU cost of a bunch of XORs.

-- 
	Viktor.







Hosted Email Solutions

Invaluement Anti-Spam DNSBLs



Powered By FreeBSD   Powered By FreeBSD