selecttest tool

JINMEI Tatuya / 神明達哉 Jinmei_Tatuya at isc.org
Wed Jul 30 21:52:16 UTC 2008


I've written a small test tool to check if a given system (+
operational environment) can support a given (normally large) number
of sockets and whether and how the select() system call/function can
support the given number of sockets.  It might be a useful check tool
for those who are currently suffering from 'too many files' kind of
problems with the P1 versions but cannot move to a beta and plan to
try and deploy P2.

The test tool is available at
http://www.jinmei.org/selecttest.tgz

See the README file contained in it about how to build and use it.

Hope it helps.

---
JINMEI, Tatuya

p.s. here are some test results from my own experiments:

1. FreeBSD 7.0(RC1)
   It can support at least about 4000 sockets.

% ./selecttest 
selecttest: nsocks = 4093, TEST_FDSETSIZE = -1, FD_SETSIZE = 1024, sizeof fd_set = 128
created 4093 sockets, maxfd = 4095
FD_CLR test...OK
FD_SET test...OK
select test...OK

2. Linux (SuSE 9.2, kernel 2.6.8-24; I know it's old) doesn't allow
   redefining FD_SETSIZE in the application, but still accepts larger
   size of fd set in select().  (Note the difference between
   TEST_FDSETSIZE and FD_SETSIZE)

selecttest: nsocks = 4093, TEST_FDSETSIZE = 4096, FD_SETSIZE = 1024, sizeof fd_set = 128
created 4093 sockets, maxfd = 4095
FD_CLR test...OK
FD_SET test...OK
select test...OK

3. Solaris 10 accepts larger size of fd set if FD_SETSIZE is increased
   at compilation time.

% ./selecttest 
selecttest: nsocks = 4093, TEST_FDSETSIZE = -1, FD_SETSIZE = 1024, sizeof fd_set = 128
created 4093 sockets, maxfd = 4095
FD_CLR test...OK
FD_SET test...OK
select: Invalid argument

[rebuild the tool with a larger FD_SETSIZE]

% ./selecttest 
selecttest: nsocks = 4093, TEST_FDSETSIZE = 4096, FD_SETSIZE = 4096, sizeof fd_set = 512
created 4093 sockets, maxfd = 4095
FD_CLR test...OK
FD_SET test...OK
select test...OK

4. HP-UX 11.11...cannot open more than several hundreds sockets.  Not
   sure if this is only in my test environment.

# ulimit -n
8192
# ./selecttest
selecttest: nsocks = 4093, TEST_FDSETSIZE = -1, FD_SETSIZE = 2048, sizeof fd_set = 256
opening 447th socket failed: File table overflow


More information about the bind-users mailing list