From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#66020: (bug#64735 spin-off): regarding the default for read-process-output-max Date: Thu, 21 Sep 2023 03:57:43 +0300 Message-ID: <451d6012-e5ab-df6c-50e3-dac20b91781c@gutov.dev> References: <83pm4bi6qa.fsf@gnu.org> <83bkfs2tw5.fsf@gnu.org> <18a0b4d8-32bd-3ecd-8db4-32608a1ebba7@gutov.dev> <83il8lxjcu.fsf@gnu.org> <2e21ec81-8e4f-4c02-ea15-43bd6da3daa7@gutov.dev> <8334zmtwwi.fsf@gnu.org> <83tts0rkh5.fsf@gnu.org> <831qf3pd1y.fsf@gnu.org> <28a7916e-92d5-77ab-a61e-f85b59ac76b1@gutov.dev> <83sf7jnq0m.fsf@gnu.org> <5c493f86-0af5-256f-41a7-7d886ab4c5e4@gutov.dev> <83ledanvzw.fsf@gnu.org> <83r0n2m7qz.fsf@gnu.org> <26afa109-9ba3-78a3-0e68-7585ae8e3a19@gutov.dev> <83il8dna30.fsf@gnu.org> <83bke5mhvs.fsf@gnu.org> <83a5tmk79p.fsf@gnu.org> <937d9927-506f-aa36-94e9-3cceb8f629dd@gutov.dev> <83zg1hay6q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5535"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 66020@debbugs.gnu.org To: Eli Zaretskii , Stefan Kangas , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 21 02:59:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qj82E-00019v-LK for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Sep 2023 02:59:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qj81v-0003XK-Pa; Wed, 20 Sep 2023 20:58:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qj81u-0003Wg-4K for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2023 20:58:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qj81t-0002LR-Se for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2023 20:58:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qj822-0004JS-Ho for bug-gnu-emacs@gnu.org; Wed, 20 Sep 2023 20:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Sep 2023 00:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66020 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66020-submit@debbugs.gnu.org id=B66020.169525788616505 (code B ref 66020); Thu, 21 Sep 2023 00:59:02 +0000 Original-Received: (at 66020) by debbugs.gnu.org; 21 Sep 2023 00:58:06 +0000 Original-Received: from localhost ([127.0.0.1]:60677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qj817-0004I9-NP for submit@debbugs.gnu.org; Wed, 20 Sep 2023 20:58:06 -0400 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44225) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qj814-0004Hd-DK for 66020@debbugs.gnu.org; Wed, 20 Sep 2023 20:58:04 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 81A125C01F4; Wed, 20 Sep 2023 20:57:47 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 20 Sep 2023 20:57:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1695257867; x=1695344267; bh=/SMKlPMD5eNouTqIWYRhKVgZZJpXTfFocMz gA4OnJr0=; b=ftTBKGCkWLYaBKyOPxzkdOnaJ13lbR6mt8ThgjMQ7futVjc4LIE 5R5TKmXCG/wROvjVgWSNLP9U6gMTuomAcCxf6/lFgx9tsq1Y4G3EI5nIgeN96jLB XwexGMSG3dP3eaKoX5yRzE7bsxhxOk0iDmt/t98RsjIxxbu2j3oFvSzwpLlCXxye RDNW+vTr6Ejdb8RObOsaqYAEMmb2xTTRwLQpAtgdsM6VhaBB5QzKzuiq2cUjLZyD t6OVNfsr1yUPTvI4FnauoDYfTEmeS0Y0OhHhw6O3hZCEuODW0z+H4PNiomRlOZ0H VnRkPBLJPLo7PHb/qzP+AtF3A3TaZA2h6GA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1695257867; x=1695344267; bh=/SMKlPMD5eNouTqIWYRhKVgZZJpXTfFocMz gA4OnJr0=; b=WqcwNG7eeaVzJCSywc7GFMTTb0TJ89dDtS+V4+cnrVcaE1sbUx4 2RJIlnA/qp+m9z3SCh7eHZtDsWPjoueEpb4NDy4uGZs+ihszwi9RYqmQephQzx2z HQDKe1yasrcrhChL864s0LdwVBDyOoevVNl4B+NU0KTcB0WfYUPYJDb/Jfp/Ol9t dahXf6Wm+5jpo6iGUeWCcJ5W7aNtrpmnphSwrDiJRs6r58vH5FTTgxlrWiEN88fN vusjNLbiuypFu/5Da0tNE654r2bqLvm/LCAh8FWPqetFrGCjHMag2RXlULbJrpBy IQ90k4qHbdEmx7kN2QGLF3tTgz6B9o/XSuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekgedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Sep 2023 20:57:45 -0400 (EDT) Content-Language: en-US In-Reply-To: <83zg1hay6q.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270965 Archived-At: On 20/09/2023 14:20, Eli Zaretskii wrote: >> Date: Tue, 19 Sep 2023 22:59:43 +0300 >> Cc: 66020@debbugs.gnu.org >> From: Dmitry Gutov >> >> - Maybe we declare the difference insignificant and bump the value of >> read-process-output-max, given that it helps in other cases, >> - Or try to find out the cause for degradation, >> - Or keep the default the same, but make it easier to use different >> value for different processes (meaning, we resurrect the discussion in >> bug#38561). > > I'd try the same experiment on other use cases, say "M-x grep" and > "M-x compile" with large outputs, and if you see the same situation > there (i.e. larger buffers are no worse), try increasing the default > value on master. I've run one particular rgrep search a few times (24340 hits, ~44s when the variable's value is either 4096 or 409600). And it makes sense that there is no difference: compilation modes do a lot more work than just capturing the process output or splitting it into strings. That leaves the question of what new value to use. 409600 is optimal for a large-output process but seems too much as default anyway (even if I have very little experimental proof for that hesitance: any help with that would be very welcome). I did some more experimenting, though. At a superficial glance, allocating the 'chars' buffer at the beginning of read_process_output is problematic because we could instead reuse a buffer for the whole duration of the process. I tried that (adding a new field to Lisp_Process and setting it in make_process), although I had to use a value produced by make_uninit_string: apparently simply storing a char* field inside a managed structure creates problems for the GC and early segfaults. Anyway, the result was slightly _slower_ than the status quo. So I read what 'alloca' does, and it looks hard to beat. But it's only used (as you of course know) when the value is <= MAX_ALLOCA, which is currently 16384. Perhaps an optimal default value shouldn't exceed this, even if it's hard to create a benchmark that shows a difference. With read-process-output-max set to 16384, my original benchmark gets about halfway to the optimal number. And I think we should make the process "remember" the value at its creation either way (something touched on in bug#38561): in bug#55737 we added an fcntl call to make the larger values take effect. But this call is in create_process: so any subsequent increase to a large value of this var won't have effect. Might as well remember it there (in a new field), then it'll be easier to use different values of it for different processes (set using let-binding at the time of the process' creation).