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: Tue, 4 Jun 2024 18:55:00 -0700 Message-ID: References: <22b0dc8f-11dc-5fd2-c75d-88c17580d28d@gmail.com> 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="26848"; mail-complaints-to="usenet@ciao.gmane.io" To: Stefan Kangas , 71355@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 05 03:57:14 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 1sEftq-0006rt-6D for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jun 2024 03:57:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEftT-0006Qc-OA; Tue, 04 Jun 2024 21:56: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 1sEftR-0006PU-Hk for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 21:56:49 -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 1sEftR-0004T4-7n for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 21:56:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sEfte-0008W9-5f for bug-gnu-emacs@gnu.org; Tue, 04 Jun 2024 21:57: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 01:57: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.171755258732659 (code B ref 71355); Wed, 05 Jun 2024 01:57:02 +0000 Original-Received: (at 71355) by debbugs.gnu.org; 5 Jun 2024 01:56:27 +0000 Original-Received: from localhost ([127.0.0.1]:42997 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEft4-0008Ug-M7 for submit@debbugs.gnu.org; Tue, 04 Jun 2024 21:56:27 -0400 Original-Received: from mail-pl1-f182.google.com ([209.85.214.182]:56368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sEfsz-0008UE-Pf for 71355@debbugs.gnu.org; Tue, 04 Jun 2024 21:56:25 -0400 Original-Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1f44b441b08so47818835ad.0 for <71355@debbugs.gnu.org>; Tue, 04 Jun 2024 18:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717552502; x=1718157302; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=gHjm+aPFEkYtGcuk6NyGmMqqG98zNUqccrkLlj3ZA8g=; b=B716/p0GvTgCzjAvYGVRaSmmIbgXaRzFfmvjlNrzRhg7Fjvk3rgZgCpwqoZTnNxUOi d+T9q+z3nbC8NiBYuSsW9R9ABdgsnZyXpXxuLdHk3D5ZcH7ljHWX4XiwYLAzlpdmQ0q/ vZOjIERU+i25a+3u7KwyEsMC4sNndAhd37XmUpe3ANz8hq7vQKQEC1FsYUblzng+Y0ls KVPNASv2hEl2hfrTqc131WF1KstZVdqu30CFnoTBXXWhkaO+PgEoLZKwGjVgs8ncv3yY tODR1tHD7CjUi5YZzQjGRsoWytJheKkepzEjOpi3dYWQiNROgI4YHlbk42/zmw98/3ka Kyqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717552502; x=1718157302; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gHjm+aPFEkYtGcuk6NyGmMqqG98zNUqccrkLlj3ZA8g=; b=TyjPYyXy26JTDarHhUT9Xull5pAHbt9D9P/BHtlDFIcmV5b5OjIaC2183UCVdwR4t4 UtgVeRi73zuvQYLMJyakMKRXNAm+EACAHFGKs5qTVPb0G/RnvFFgsrLDaPNv0RutXaP0 6ErQEdWVmxTF3LeT5KmP6v7zEGSBxADOHltIM36iJVfEj5mz8CyAkPNtQZls+N/It+oB XOT/uOd9FSjUzXmDc0GjBDtmmeJF31zv/7iQMSlJIjE3e++GmPJGO48EyHXfQqfvWG9I 3B6s+apq8F+ExRpFH+N5656bjisFrQtfeHYvl/q4Un8V5PDoreBBQoV5BeXNAFO6ObmH Wqlg== X-Forwarded-Encrypted: i=1; AJvYcCXtVOub4nIOHx+TmO5z48Hs7kDB0NJu7+7E5b3gL0NIhTsh08yKNN3+HaRD7SYFdg8/ZuBzsVtHFD8Ih5N8OboqsZlzJtk= X-Gm-Message-State: AOJu0YwqnZp+Z9ggqwpLVCzaI/RpWfW6gZTEKnpqvAxyN/PNs0nhdAMA KRtb0hE657Jy4xoVPP+7eZxdE1sSoWZWF36T4jrUlsgV3UVOJXH7 X-Google-Smtp-Source: AGHT+IHRuAcdl3Co6sws6gV03PminjaFsWVS+wod0Q4Ow3MP0O6QJKZaUgGsRrhevjiRfEBsoKIT4A== X-Received: by 2002:a17:903:32cf:b0:1f3:cb7:b10b with SMTP id d9443c01a7336-1f6a5905ea4mr16458535ad.7.1717552501637; Tue, 04 Jun 2024 18:55:01 -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 d9443c01a7336-1f6323f8460sm91698535ad.222.2024.06.04.18.55.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jun 2024 18:55:01 -0700 (PDT) Content-Language: en-US In-Reply-To: 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:286569 Archived-At: On 6/4/2024 2:52 PM, Stefan Kangas wrote: > Nice, thanks for working on this. Your patch makes sense to me at first > glance, but I didn't test it. The performance improvement definitely > seems highly worthwhile based on your measurements. If anyone has time to test, I'd be interested to see if the results are similarly good on other platforms (I'm testing on x86_64 GNU/Linux), but I imagine they're comparable. The main areas of improvement are: 1. Batching output into larger chunks reduces the constant-time overheads associated with each write to the screen. 2. Scanning for control characters in output is much faster thanks to 're-search-forward'. 3. The above improvements made it possible to add periodic redisplays, which eat into the perf improvements. I mitigated this by throttling the redisplay to 40Hz (the slowest value I found where the throttling isn't obvious). > Bonus points for adding tests, as always. I wrote some tests for the control character fix, since my changes to that function were nontrivial. I'll see if I can think of a few others, though I'm partly relying on the now-fairly-extensive Eshell test suite to catch any mistakes. >> +(defcustom eshell-buffered-print-size 2048 >> + "The size of the print queue in characters, for doing buffered printing. >> This is basically a speed enhancement, to avoid blocking the Lisp code >> from executing while Emacs is redisplaying." > > How did you decide on this value? Basically, I tried a few different command invocations that normally take a while (the main ones being "cat config.log" and "ls -Al /usr/bin") and scaled up the value by factors of two until I stopped seeing any major perf improvements. (Larger values are faster still, but not by a whole lot.) > Could the docstring be expanded to explain what a user can expect to > happen if they increase or decrease this value? Sure, that makes sense. Essentially, smaller values will be slower, but may update faster (subject to the redisplay throttling), whereas larger values are the opposite.