From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#71355: 30.0.50; [PATCH] Improve performance of buffered output in Eshell Date: Wed, 5 Jun 2024 10:35:08 -0700 Message-ID: <9da5a395-48e8-fb20-145b-1d2581315fcf@gmail.com> References: <22b0dc8f-11dc-5fd2-c75d-88c17580d28d@gmail.com> <848772e9-5ef0-8a8a-decd-c0b79366ec27@gmail.com> <86ikynk30i.fsf@gnu.org> <037ebce9-93af-f1ad-67d9-550fd1074294@gmail.com> <8634prjpt0.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="27038"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71355@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 05 19:37:17 2024 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 1sEuZY-0006oO-Id for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jun 2024 19:37:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEuZ9-0007lE-4b; Wed, 05 Jun 2024 13:36:51 -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 1sEuZ6-0007kE-Kd for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 13:36:48 -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 1sEuZ6-0007Mg-Bj for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 13:36:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEuZK-0006tg-7P for bug-gnu-emacs@gnu.org; Wed, 05 Jun 2024 13:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jun 2024 17:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71355 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71355-submit@debbugs.gnu.org id=B71355.171760899126416 (code B ref 71355); Wed, 05 Jun 2024 17:37:02 +0000 Original-Received: (at 71355) by debbugs.gnu.org; 5 Jun 2024 17:36:31 +0000 Original-Received: from localhost ([127.0.0.1]:51714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEuYp-0006s0-0P for submit@debbugs.gnu.org; Wed, 05 Jun 2024 13:36:31 -0400 Original-Received: from mail-pj1-f47.google.com ([209.85.216.47]:50261) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEuYm-0006rf-1V for 71355@debbugs.gnu.org; Wed, 05 Jun 2024 13:36:30 -0400 Original-Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2c2999f969aso82150a91.0 for <71355@debbugs.gnu.org>; Wed, 05 Jun 2024 10:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717608908; x=1718213708; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=z2F0JNPfvN47gAHbjppfEA1gnHYElobm8iPhNOMeJ6Q=; b=Tm0VR2/vM8EmB+Qg+DqBJO/UK9qmrs6qzTMu6qdsYc4JhDzRfXd3Usufc16/C5MwwW NkY8N7/qzAMozkoOj8X7Z/Gie9I0EvoU7oUuHesMfPTm8YUhEpTEJrpdurfnIvivp0NR ZQ85gLJrPPLcxtAKAyqSvAutWWFLD5h0i0GZYPY/GCuyEKgeGhcyxBunrRx7GZTMwXbj 3yUm2yts3I8CgGgwQa8h6JifA+zibR8P68YQH8ZhO0IucYyvh2VS69Zd+8tw+2EJ10Qw m/POzhWGn3YGMgZodquj9MN8I4P8T941Qb0FKwapF+XEMdOFgK3AEgeAZ6jC2MUiXxeA tPEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717608908; x=1718213708; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z2F0JNPfvN47gAHbjppfEA1gnHYElobm8iPhNOMeJ6Q=; b=Q63Gjyi3656VlE8jczGxH+/gCNm1m8i/5gNi7+wd4tOtqXVDMAej7Igfv6DkND/i7D j2oY3/3j7dSV6BPDN8WGG5/qa9CKsggQBU68zzMdtnY09E1jOOy8J/L895VTtjJtjdZL NGqMn4XhvXKmPgG0hhwZ/sT7Ttd8Y2N5dwD8rHF1MIuqNxtEDM/Y7c97An3RqqdO+IvF HeYmqiDJpSN1Ob5bUx11+urahDxuGnOc+KWKv09xIIBvZHJPxgUPJsJHlyCmoBccGiZ/ UdWVF5slF+RA/uJ4Vx9XMY3Piw3AapOr6267N72NxQqOqmsu7NaeKYHB+5H6HxCA0itO vtPA== X-Gm-Message-State: AOJu0YxmCB8/XIIA9UvML5aKBySFrnTY0oNmw1p9iA8CofNLSGCp+BNA Gres7hzUz2TZcTcjonJ1KNg3hvG9+wH86g3WC2oRtfqBrAB6An+H X-Google-Smtp-Source: AGHT+IEW3E59P7KQxeK/3zff65aSoNpcl5f3GW24JTyjzAzybadjdDE3RGyAsuxTPKmm8yjT7l0+9g== X-Received: by 2002:a17:90b:4b48:b0:2c2:3d83:d7ee with SMTP id 98e67ed59e1d1-2c27db5a64amr3169731a91.30.1717608907736; Wed, 05 Jun 2024 10:35:07 -0700 (PDT) Original-Received: from [192.168.1.2] (syn-023-240-098-037.res.spectrum.com. [23.240.98.37]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c254a76729sm4139464a91.0.2024.06.05.10.35.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jun 2024 10:35:07 -0700 (PDT) Content-Language: en-US In-Reply-To: <8634prjpt0.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:286626 Archived-At: On 6/5/2024 9:51 AM, Eli Zaretskii wrote: >> Date: Wed, 5 Jun 2024 09:42:43 -0700 >> Cc: 71355@debbugs.gnu.org, stefankangas@gmail.com >> From: Jim Porter >> >> On 6/5/2024 5:06 AM, Eli Zaretskii wrote: >>> Is 2K indeed the optimal size? It is about 25 80-column lines, which >>> is quite a lot. "Normal" shells send output to the screen in smaller >>> chunks. How about 128 instead? or maybe some small multiple of the >>> line length, like 1 or 2? >> >> Yes, I believe 2k is the optimal size, or close to it. Trying a value of >> 128 results in basically no change in performance from baseline. That >> makes sense to me, since 128 is actually fairly close to the old value >> for this buffering (which was five *lines*[1]; the old code measured >> this differently). > > That's strange, because I see no output at all until all of it is > available and showsn, and I thought you said the same in your OP? Yes, without my patch that's expected. When I talk about changes in performance, I mean the total time to complete the command, as measured by, e.g. "time cat config.log". Here's what's happening: all of the output in 'eshell/cat' occurs in a loop, periodically calling 'eshell-interactive-print' (how often it calls this depends on the buffering settings). That runs the functions in 'eshell-output-filter-functions', which can be fairly expensive. So one way to make output faster would be to optimize those functions, which I did in my second patch. However, a larger buffer size is still faster even when there are no output filter functions, due to other overheads in the code. So I think even if we could make 'eshell-output-filter-functions' all very cheap, it's worth increasing the buffer size. In addition to this, the performance improvements I made allowed me to add in the extra work of redisplaying periodically when using this buffered output scheme. That's all new in my patch, and previously you'd have to wait until the command was finished to see any output. From Emacs's perspective, everything in 'eshell/cat' is synchronous, so I needed to manually trigger the redisplay (or do some other sorcery to hand control back to the command loop).