From owner-freebsd-ports@freebsd.org Fri Apr 12 07:36:28 2019 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99E6D1575264 for ; Fri, 12 Apr 2019 07:36:28 +0000 (UTC) (envelope-from dimpase@gmail.com) Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 097F18F725 for ; Fri, 12 Apr 2019 07:36:28 +0000 (UTC) (envelope-from dimpase@gmail.com) Received: by mail-lj1-x244.google.com with SMTP id h21so7893678ljk.13 for ; Fri, 12 Apr 2019 00:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3Qd+YuvMY3zl4knZgXsevKuHsRdVaqt3j1MfyXaz+vc=; b=P39lFvQ6CJn1PIJDVSUxI2Zyk4B57gTs0GruVcdmNce5PYsFPx/Emf0dJU/QuUNzt6 40smTdPYqJ/biiPEzVNYVFiUy4VRK2cD66NVmv7S932e3kjoPq9yUuq0IExglYlfE2Cz 2lazpn9VQEOsYxZb5bZhReHs1+zx62rktefoBXCDMkUKPsjKhRhrAy1fCm3SRCrsQyTe bYT+Z80QZHFzwo+Rnr9Y9fjEwL+A4TKsvpKKJYNpL4hV8fgMWQZ97J+jx6lhZwnmgB11 MJNxGL8nV4YQnOcnMP7VV1VUwvj9VoPciCCAO7n+7rcoxCeBX7BvWOjL4yV+rLvaQE+b 7g0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3Qd+YuvMY3zl4knZgXsevKuHsRdVaqt3j1MfyXaz+vc=; b=tBAlWydusQYY2McVjjfWLV9vuAQmzBVvxPyFFTFIeONSjoZZLNZvBbjEwNl7ymlD0K D028txhZZpo9CCPqJYqWq3K8sNmX3JpDvwiZ6Q5dw5xDkyXJ5xGYdPdPCnSZa5ETnRmo np4wNU5u3HHRvX6gJsOgWIOQf7UMF/ukChpHOHR6T92wDU2WQDh3wkygOuUDmTyRCMN0 6qHCztancsN6Slu7JbPPGiZYK04RIs4nIdNDRB/ee7qaFWEYnab7vZPfzz3KCVPGhXY4 4sZ7biEVLK8bs24w52LFdL1SI2FwMGJWXxWdvRIoXYZJa99U9o+qwPSZD3j2z9jP54E/ xJUQ== X-Gm-Message-State: APjAAAXr7bBMoXc1fHbNL22TesX7Rg0ft19FYI5RUgGIIcxIPF6z5CFq mOu76Tan/4rjm2pFxTNOOzrZDDwcXmhQIKw+a0Y= X-Google-Smtp-Source: APXvYqwBRAoFwBdWcckoEQQkMiQd0AJpybdwx2IfwD0dRV+Xqi3RuJlBZsuCxlXJ6bKfZeLAZBFt2hziUJ1TjGUY9CY= X-Received: by 2002:a2e:8693:: with SMTP id l19mr28804092lji.47.1555054585392; Fri, 12 Apr 2019 00:36:25 -0700 (PDT) MIME-Version: 1.0 References: <20190411161649.1b740d21@vm2.home.zagrebin.ru> <8f3f8413-60f2-bb03-a6b4-4f6364cdc3df@rlwinm.de> <20190411143926.5rg4jskmodt4shhi@laparbeit> <9729db47-12c4-caf4-cdcf-1913dab73c8e@rlwinm.de> <20190412101012.4142854f@vm2.home.zagrebin.ru> In-Reply-To: <20190412101012.4142854f@vm2.home.zagrebin.ru> From: Dima Pasechnik Date: Fri, 12 Apr 2019 09:36:13 +0200 Message-ID: Subject: Re: python 3 subprocess performance To: Alexander Zagrebin Cc: FreeBSD Ports Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 097F18F725 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.92 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.92)[-0.924,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[freebsd]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Apr 2019 07:36:28 -0000 On Fri, Apr 12, 2019 at 9:11 AM Alexander Zagrebin wrote= : > > =D0=92 Thu, 11 Apr 2019 17:32:42 +0200 > Jan Bramkamp =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > > > The reason is that that python does something stupid (tm). It tries to > > close all file descriptors (except a few whitelisted ones) up to the > > maximum file descriptor number. It does this by asking the kernel for > > the maximum possible number and closing everything it doesn't want to > > keep. Some time later someone came up with an optimization (read the > > open file descriptors from /dev/fd). All of this pain and suffering is > > caused by good old Ulrich Drepper braindamage: > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D10353. > > > > Most Linux distros have lower default file descriptor limits than > > FreeBSD making this workaround less painful. The correct solution > > would be to teach python3 about closefrom(2). > > Thank you for hint and testing! > > Indeed the problem is in closing more than 400,000 file descriptors in > loop. It seems that all current versions of Python are affected. > Python2 uses False as default value for the close_fds parameter of > the Popen constructor, so this issue is mostly not visible. > Python3 has changed this default to True. > > As Jan Bramkamp suggested, I've wrote simple patch to fix an issue (see > attached file). It seems the problem has gone. The attachment has been stripped out. Could you paste the diff into the mes= sage? If this is a Python issue, shouldn't this be reported upstream, on https://bugs.python.org ? Dima > > -- > Alexander Zagrebin > _______________________________________________ > freebsd-ports@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-ports > To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org"