Date: Mon, 13 Apr 2015 11:31:59 +0300 From: Slawa Olhovchenkov <slw@zxy.spb.ru> To: Poul-Henning Kamp <phk@phk.freebsd.dk> Cc: arch@freebsd.org Subject: Re: default file descriptor limit ? Message-ID: <20150413083159.GN1394@zxy.spb.ru> In-Reply-To: <79209.1428913320@critter.freebsd.dk> References: <78759.1428912996@critter.freebsd.dk> <79209.1428913320@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Apr 13, 2015 at 08:22:00AM +0000, Poul-Henning Kamp wrote: > -------- > In message <78759.1428912996@critter.freebsd.dk>, Poul-Henning Kamp writes: > > $ limits > > Resource limits (current): > > [...] > > openfiles 462357 > > > >say what ? > > > >This wastes tons of pointless close system calls in programs which > >use the suboptimal but best practice: > > > > for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) > > close(i); > > > >For reference Linux seems to default to 1024, leaving it up to > >massive server processes to increase the limit for themselves. This is typical only on startup, I think? > >I'm all for autosizing things but this is just plain stupid... > > Just to give an idea how utterly silly this is: > > #include <stdio.h> > #include <unistd.h> > > int > main(int c, char **v) > { > int i, j; > > for (j = 0; j < 100; j++) > for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) > close(i); > return (0); > } > > Linux: 0.001 seconds > FreeBSD: 17.020 seconds > > > PS: And don't tell me to fix all code in /usr/ports to use closefrom(2). % time ./a.out 0.581u 3.302s 0:03.88 100.0% 5+168k 0+0io 0pf+0w % time limits -n 100 ./a.out 0.000u 0.004s 0:00.00 0.0% 0+0k 0+0io 0pf+0w % limits [...] openfiles 116460 May be now time to introduce new login class, for desktop users, with reduced limits for open files and some regionals settings. And modify bsdinstall to support this. And may be some Gnome/KDE tools for creating users (I am don't use KDE/Gnome). Base login class ('default') don't touching, don't have limits and have locale "C", used for system startup and daemons.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150413083159.GN1394>