From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24416 invoked from network); 25 Apr 2022 19:21:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Apr 2022 19:21:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1650914486; b=UB/3SdjaqJ7OLTZEANTYIxaMo8YtMIF6LcO8DSmw6BH5rXTuML/SNihdE1KBWK67/sxlT8SRZ6 q7OH/YNSn8IZQ/M0W88ZEpiJ0G9RJ9w6NW0XRmgvvnpsxxYkxEkU+WIHznkLoMTNEiQSWFHkpi FpOvgsmavTm5/Ta1IbaIYMIWP3x8qM+5Bmt8ROmdRURD/PFZ00kilUGvMDuZQDVQ6l2u5gBBXZ fm9n0eT/NSfxfJXMU7yNcIUz57R7N/SHw2+ltk5B9pxGrN3yOh8IkLV+kZcIgeFM8S9UNfBrxg 6TNDWlLfUie5DiBJgTilGjwDq/9dny+pr9Qdv4ktZleWTA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay10.mail.gandi.net) smtp.remote-ip=217.70.178.230; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1650914486; bh=y5ARX0MBqF3vDqCqfLsQMqdiz1ZKgSiLkbeu+fi9faU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=AKBJJNNnM8IOUU0Jd+pYDRUi2ARSOoLRw8Nla5II/UgRZWbbaiicB3+b2OsF8Bmg6zlJx8k2jh vL+DK5pjoOpjBvYGY3WzUDfIQ4bHhVYjcfrpF3nXie5niB6omNa5/2SBkGdgP4XERchKIKoNeH rTwqiyJVvRrzEtFHh/zWUzKqxEIDONqcvpK6PT51hHNmvTm8Wqb2eRYCJs00LbncaR4ZrMdiEF pi9ZAGf9S6nm/zohuKBp9KlsNa9ZDT90DMuXcCi2izm7ENKNedDWc2D0+2ba7aXY67fICBxW4K g3/fVP9Xlx6BOS5LJP5aec81rnsz5guSilfEFo12PxpsSA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gEQ1rC4jz3AqMGA5IARV730savV3a/HvYf8o1+Bocu0=; b=GiuQblYJpsOOeju+uPThAuH+4I 8CgIiKpZUg22b3muXQtvqt5vjU32ZrCbUhwu1ztQXk2SrnvB+3vv4jAy/YLH/kpB4omDMwK23zp6Z rt2qY6SeW/vl/j9rmnwRPVg0T8aawU0tapc9UvLzTAwLLMY0TaKHT2QMlyDBgtVAoDRV7NRZ69elc ByoUvxCMmW9eTIL5uUNge28yXLfmNebfL2kK/2g7D4nDf8ANfn4KKY35jOmZ0VS57bZpOXigQ2c3L 3hwBc9i8tQfr+/8QcHbBWAjxNi8172UM93ryor3vkFtK7dZWuBeU3NEXW1b1dE/vsGEzluluQabRj GfGleFFQ==; Received: from authenticated user by zero.zsh.org with local id 1nj4Gy-000AyB-Qi; Mon, 25 Apr 2022 19:21:24 +0000 Authentication-Results: zsh.org; iprev=pass (relay10.mail.gandi.net) smtp.remote-ip=217.70.178.230; dmarc=none header.from=chazelas.org; arc=none Received: from relay10.mail.gandi.net ([217.70.178.230]:49741) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1nj4GE-000Adh-I2; Mon, 25 Apr 2022 19:20:39 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id 67351240002; Mon, 25 Apr 2022 19:20:37 +0000 (UTC) Date: Mon, 25 Apr 2022 20:20:36 +0100 From: Stephane Chazelas To: Bart Schaefer Cc: Jordan Patterson , Zsh hackers list Subject: Re: ZSH performance regression in 5.8.1.2-test Message-ID: <20220425192036.p6awbyro2a2lp7bq@chazelas.org> Mail-Followup-To: Bart Schaefer , Jordan Patterson , Zsh hackers list References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 50092 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2022-04-25 11:56:59 -0700, Bart Schaefer: > On Mon, Apr 25, 2022 at 11:26 AM Jordan Patterson 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