From owner-freebsd-arch@FreeBSD.ORG Mon Apr 13 08:22:01 2015 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D98DF58B for ; Mon, 13 Apr 2015 08:22:01 +0000 (UTC) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 9F5AE2FA for ; Mon, 13 Apr 2015 08:22:01 +0000 (UTC) Received: from critter.freebsd.dk (unknown [192.168.60.3]) by phk.freebsd.dk (Postfix) with ESMTP id A27DF3B8A2 for ; Mon, 13 Apr 2015 08:22:00 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.9/8.14.9) with ESMTP id t3D8M0Re079210 for ; Mon, 13 Apr 2015 08:22:00 GMT (envelope-from phk@phk.freebsd.dk) Subject: Re: default file descriptor limit ? In-reply-to: <78759.1428912996@critter.freebsd.dk> From: "Poul-Henning Kamp" References: <78759.1428912996@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <79208.1428913320.1@critter.freebsd.dk> Date: Mon, 13 Apr 2015 08:22:00 +0000 Message-ID: <79209.1428913320@critter.freebsd.dk> Cc: arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2015 08:22:01 -0000 -------- 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. > >I'm all for autosizing things but this is just plain stupid... Just to give an idea how utterly silly this is: #include #include 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@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.