unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 71355@debbugs.gnu.org, stefankangas@gmail.com
Subject: bug#71355: 30.0.50; [PATCH] Improve performance of buffered output in Eshell
Date: Wed, 5 Jun 2024 09:42:43 -0700	[thread overview]
Message-ID: <037ebce9-93af-f1ad-67d9-550fd1074294@gmail.com> (raw)
In-Reply-To: <86ikynk30i.fsf@gnu.org>

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).

In starting on this work, I compared to the amount of data that I get 
each time a child process filter is called; that's normally 4095 bytes 
in my tests. Then I started a bit lower (512) and gradually doubled the 
buffer size until I was able to get most of the performance benefit.

A lot of this improvement does come from reducing the number of times 
that we call 'eshell-output-filter-functions', so if we made those 
functions much faster, or throttled them somewhere else, then we could 
get a large perf improvement while using a small buffer size. However, 
even if I remove everything from 'eshell-output-filter-functions', a 
larger buffer is *still* faster (0.2s for 2048 vs 0.5s for 128). For 
comparison, the same command in an ordinary shell takes about 0.1s, so 
that's my ultimate target.

Note that this buffered output code is really only used when Eshell will 
output a (relatively) large block of text all at once from a Lisp 
command. External processes and most ordinary Lisp code won't use this, 
since you have to use the special functions for buffering your writes.

[1] Well, 5 calls to the print function, but most callers printed a line 
at a time.





  reply	other threads:[~2024-06-05 16:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  5:36 bug#71355: 30.0.50; [PATCH] Improve performance of buffered output in Eshell Jim Porter
2024-06-04 21:52 ` Stefan Kangas
2024-06-05  1:55   ` Jim Porter
2024-06-05  3:50     ` Jim Porter
2024-06-05 12:06       ` Eli Zaretskii
2024-06-05 16:42         ` Jim Porter [this message]
2024-06-05 16:51           ` Eli Zaretskii
2024-06-05 17:35             ` Jim Porter
2024-06-05 17:57               ` Eli Zaretskii
2024-06-05 18:47                 ` Jim Porter
2024-06-05 18:58                   ` Eli Zaretskii
2024-06-05 20:07                     ` Jim Porter
2024-06-06  4:43                       ` Eli Zaretskii
2024-06-06 18:02                         ` Jim Porter
2024-06-08  4:25                           ` Jim Porter
2024-06-08  7:33                             ` Stefan Kangas
2024-06-08 19:43                               ` Jim Porter
2024-06-06  9:20     ` Stefan Kangas
2024-06-06 18:04       ` Jim Porter
2024-06-06 23:14     ` Stefan Kangas
2024-06-07  0:09       ` Jim Porter
2024-06-07  8:51         ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=037ebce9-93af-f1ad-67d9-550fd1074294@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=71355@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).