default file descriptor limit ?
Poul-Henning Kamp
phk at phk.freebsd.dk
Mon Apr 13 08:22:01 UTC 2015
--------
In message <78759.1428912996 at 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.
>
>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).
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the freebsd-arch
mailing list