[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Opening 5000 file descriptors in linux??
- To: linux-mm@kvack.org
- Subject: Re: Opening 5000 file descriptors in linux??
- From: Oskar Pearson <oskar@linux.org.za>
- Date: Tue, 6 Apr 1999 21:35:30 +0200
- In-Reply-To: <14082.48568.621877.339352@dukat.scot.redhat.com>; from Stephen C. Tweedie on Thu, Apr 01, 1999 at 01:28:40AM +0100
- References: <19990329212938Z160486-220+9825@vger.rutgers.edu> <36FFF75C.7BC30B3D@netscape.com> <3700D917.7686EB1B@grips.com> <14082.48568.621877.339352@dukat.scot.redhat.com>
- Resent-Date: Tue, 6 Apr 1999 22:45:46 +0200
- Resent-From: oskar@linux.org.za
- Resent-Message-Id: <199904062045.WAA00390@vi.qualica.com>
- Resent-To: linux-mm@kvack.org
- Sender: owner-linux-mm@kvack.org
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/