public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Kegel <dank@kegel.com>
To: Chuck Winters <cwinters@atl.lmco.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Number of File descriptors
Date: Sat, 14 Jul 2001 08:06:45 -0700	[thread overview]
Message-ID: <3B506005.7C6D2982@kegel.com> (raw)

Chuck wrote:
> Will select be ultra slow trying to select on 3000 file descriptors? 

Note that using select in a program that uses more than 1024 file 
descriptors is not completely portable; you have to redefine __FD_SETSIZE.
I have heard people say that's easy, but as recently as March 2000,
Ulrich Depper advised against it:
http://sources.redhat.com/ml/bug-glibc/2000-03/msg00051.html
As far as I can see, it's not easy on Red Hat 6.2 or 7.1.

But that's ok; you can use poll() instead.

See http://www.kegel.com/dkftpbench/Poller_bench.html for
some measurements on the speed of select() and poll() for large numbers
of file descriptors.  Here's an excerpt:

Time to select or poll n file descriptors, in microseconds,
on 650 MHz dual Pentium III with kernel 2.4.0-test10-pre4 smp:

               file descriptors
              100    1000   10000 
    select     52       -       - 
      poll     49    1184   14660 

So poll() is indeed slow at 1000 to 10000 file descriptors; whether 
it's too slow depends on your application.

> Also, what is the clarification on the kernel doing a sequential 
> search through the open file descriptors?

Yep, that's where the slowness comes from.  Linux offers several ways
around it: 
  * RT signal stuff that comes standard with 2.4
  * Provos' /dev/poll patch
  * Vitaly Luban's enhanced RT signal patch
  * Davide Libenzi's enhanced /dev/epoll patch
You can read about all of these at http://www.kegel.com/c10k.html#nb

The first has the advantage of being part of the 2.4 kernel already,
but is a bit of a pain to use (you have to handle signal overflow).
The second still has one linear scan in it, so it doesn't scale well.
The third and fourth are the top contenders for 'fastest replacement for 
select()' on Linux, but aren't part of the standard kernel yet.

- Dan

             reply	other threads:[~2001-07-14 15:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-14 15:06 Dan Kegel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-13 13:59 Number of File descriptors Chuck Winters
2001-07-14  6:03 ` David Schwartz
2001-07-17 13:46 ` Chuck Winters
2001-07-18 13:12   ` Patrick O'Rourke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B506005.7C6D2982@kegel.com \
    --to=dank@kegel.com \
    --cc=cwinters@atl.lmco.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox