zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Jordan Patterson <jordanp@gmail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: ZSH performance regression in 5.8.1.2-test
Date: Mon, 25 Apr 2022 20:20:36 +0100	[thread overview]
Message-ID: <20220425192036.p6awbyro2a2lp7bq@chazelas.org> (raw)
In-Reply-To: <CAH+w=7YwV=Cu1N7dSb417R1Q0vAMu6R6hAryXqE4RBkmU_w5gA@mail.gmail.com>

2022-04-25 11:56:59 -0700, Bart Schaefer:
> On Mon, Apr 25, 2022 at 11:26 AM Jordan Patterson <jordanp@gmail.com> wrote:
> >
> > This recent fix has led to a performance regression in zsh: 49792:
> > Non-interative shell input is line buffered.
> 
> Hm.  If we use stdio for speed, we have memory management re-entrance
> issues that can lead to a crash.
> 
> If we use direct read of more than one character at a time, we can't
> enforce line buffering.
> 
> Is there a way we can detect the case where we need to line-buffer and
> avoid it otherwise?
[...]

Sorry if I'm beside the point as I don't know the context here,
but in cases where it's important that we don't read past the
newline character that delimits an input line (like for the read
builtin), some other shells, when the input is seekable do read by
blocks (instead of one byte at a time), and seek back to just
after the newline when they've read too much.

That explains why using "read" on regular files can be
significantly slower in zsh than in ksh/bash.

ksh93 goes even further (but that causes bugs, and I'm not
suggesting zsh goes there) in that the
second "read" on the same fd reuses information that was
retrieved from the previous read.

It also explains why ksh93 uses socketpair() instead of pipe()
for its pipes on Linux, as you can /peek/ at their contents
without consuming them. Again, that comes with its own set of
problems.

-- 
Stephane


  reply	other threads:[~2022-04-25 19:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 18:16 Jordan Patterson
2022-04-25 18:56 ` Bart Schaefer
2022-04-25 19:20   ` Stephane Chazelas [this message]
2022-04-25 21:27     ` Bart Schaefer
2022-04-26  7:01       ` Bart Schaefer
2022-04-26  8:31         ` Peter Stephenson
2022-04-27  0:33           ` Bart Schaefer
2022-04-27 14:11           ` Stephane Chazelas
2022-04-27 15:02             ` Bart Schaefer
2022-04-27 15:07               ` Peter Stephenson
2022-04-27 15:17                 ` Bart Schaefer
2022-04-26 14:31         ` Jun. T
2022-04-26 15:15           ` Peter Stephenson
2022-04-27  0:55             ` Bart Schaefer
2022-04-27  9:16               ` Jun T
2022-04-27  0:38           ` Bart Schaefer
2022-04-27  9:34             ` Peter Stephenson
2022-04-27 10:28               ` Jun T
2022-04-27 12:42                 ` Jun T
2022-04-27 13:58                 ` Jun T
2022-04-27 15:25                   ` Bart Schaefer
2022-04-27 16:18                     ` Jun. T
2022-04-27 19:54         ` Jordan Patterson
2022-04-28  9:53           ` Jun T
2022-04-28 14:56             ` Bart Schaefer
2022-04-28 18:51           ` Jun. T
2022-04-29  0:28             ` Bart Schaefer
2022-04-29  2:25               ` Jun. T
2022-04-26  1:08 ` Bart Schaefer
2022-04-26  3:03   ` Jordan Patterson

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

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

  git send-email \
    --in-reply-to=20220425192036.p6awbyro2a2lp7bq@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=jordanp@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).