From owner-freebsd-python@freebsd.org Tue May 9 19:13:21 2017 Return-Path: Delivered-To: freebsd-python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D506DD666D0 for ; Tue, 9 May 2017 19:13:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id BE0A71112 for ; Tue, 9 May 2017 19:13:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id BCCD4D666CF; Tue, 9 May 2017 19:13:21 +0000 (UTC) Delivered-To: python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC6F1D666CE for ; Tue, 9 May 2017 19:13:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3488D1111 for ; Tue, 9 May 2017 19:13:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v49JDFbA092113 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 9 May 2017 22:13:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v49JDFbA092113 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v49JDE9q092112; Tue, 9 May 2017 22:13:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 9 May 2017 22:13:14 +0300 From: Konstantin Belousov To: pmhausen Cc: python@freebsd.org Subject: Re: Proposal for pkg-message for python 3.x ports Message-ID: <20170509191314.GK1622@kib.kiev.ua> References: <36BF7EEF-EE06-4A70-B0F2-69D1454CD1FF@me.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36BF7EEF-EE06-4A70-B0F2-69D1454CD1FF@me.com> User-Agent: Mutt/1.8.2 (2017-04-18) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 May 2017 19:13:21 -0000 On Tue, May 09, 2017 at 07:23:38PM +0200, pmhausen wrote: > Dear python port maintainers, > > I discovered an odd performance problem with python 3.6 on servers with > large amounts of memory. > > You can find all the details in a thread of the help@python.org > mailinglist with subject > > "Python bug? Closing *all* file descriptors on fork() instead of only open ones?" > > Unfortunately I cannot get at the list archives. Otherwise I would have sent > you a direct link. > > Short version: since python 3.3 (if my google-fu worked) python tries to > close all open file descriptors in the child after fork(). Since there is > no standard POSIX compliant way to do this for *open* descriptors only, > it tries to use /dev/fd on FreeBSD and if that is not available it closes > *all* descriptors (resulting in ERR#9 for the majority). On a 64 bit FreeBSD > 11 system with 128 GB of RAM the auto-tuned kern.maxfilesperproc > is between 3 and 4 million. That's a heck of a lot of system calls for each > fork() ;-) > > I suggest adding a hint to mount fdescfs and add it to /etc/fstab in the > pkg-message for the affected python ports. We have closefrom(2), which is semi-portable, in the sense that it is available not only on FreeBSD.