All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Opening 5000 file descriptors in linux??
       [not found]     ` <14082.48568.621877.339352@dukat.scot.redhat.com>
@ 1999-04-06 19:35       ` Oskar Pearson
  0 siblings, 0 replies; only message in thread
From: Oskar Pearson @ 1999-04-06 19:35 UTC (permalink / raw)
  To: linux-mm

Hi

Stephen Tweedie wrote:

> Two things: first of all, the default rlimit for open files is still
> 1024, so you need to raise that to use more in one process.  From bash,
> that's 
> 
> 	ulimit -Hn 100000; ulimit -n 100000

Done.

> or use the setrlimit() kernel call.
> 
> Secondly, the default FD_SET type only has space for 1024 fds in the
> bitmap, so either make sure you are using poll, or define your own,
> sufficiently large, FD_SET if you need to use select.
> 
> Other than that, all should work.

Interesting thing. Someone sent me a simple piece of code that they
were having problems with. Instead of opening /dev/null 5 million
times, they actually opened a network socket. Here is the code:

--------
#include <stdio.h>
#include <sys/socket.h>
main()
{
        int s;
        for(s = 0;; s++)
                if(socket(AF_INET,SOCK_STREAM,0) < 0)
                        break;
        printf("%d\n", s);
}
--------

This breaks much sooner than the ulimit value:

vi:~ # ./test 
508
vi:~ # ./test 
519
vi:~ # ./test 
519
<fiddle around with random things so that the system swaps>
vi:~ # ./test 
552

strace output:
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 552
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 553
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 554
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = -1 ENOBUFS (No buffer space
available)

no dmesg errors.

vi:~ # uname -a
Linux vi.qualica.com 2.2.5-ac1 #2 Sun Apr 4 14:26:31 SAST 1999 i586
unknown

If I add a second delay every 10 seconds, the system seems to free up
enough memory to get to around about 1000 filedescriptors. This points
to a resource management problem, IMHO.

I am not sure if the later ac-? patches do the same thing. I was out
of the country this last weekend.

Oskar
--
To unsubscribe, send a message with 'unsubscribe linux-mm my@address'
in the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://humbolt.geo.uu.nl/Linux-MM/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-04-06 20:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <19990329212938Z160486-220+9825@vger.rutgers.edu>
     [not found] ` <36FFF75C.7BC30B3D@netscape.com>
     [not found]   ` <3700D917.7686EB1B@grips.com>
     [not found]     ` <14082.48568.621877.339352@dukat.scot.redhat.com>
1999-04-06 19:35       ` Opening 5000 file descriptors in linux?? Oskar Pearson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.