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 8580 invoked from network); 25 Apr 2022 21:28:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Apr 2022 21:28:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1650922122; b=C/uL5BSe4ZoAcjCAqEfRnZEXLf1j8ABSVYnVhabaQorPSmlmZGIP43mblNZrO6z52EFxzEh9sQ RUhnt+Z5IOa4lW2PH9ZgcNBd2YwpD3qMfsnkoofgsaXFMG+p+AVDSG3cYZ0XB9TrEnlmz01r0+ LjEgMdW8RXX9z+rCi1gD6vzebyTtM8UyOSGnTeq/idQ69pbcotxlR6XgnWgIPxqEL5wPzIEXZq R1W6cSDYqQSTigIXcSvZDkeT0xc6nMK8JYya6JSwZMxP4wSVS/MOrH3wQ9CdBhB0tlfnwb/+Oz XyZ+bztiSwVEZEmqASxqXMQRkh+iMUeK9uaPxZOPUekIkw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1650922122; bh=+/W0iaEELR5vTdhW2pMvYF40CpReSa8Wz1LafxJACng=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=Jq0yX5KwhQA3GOXN/JQJjOrrehBrk6jIJeJjvMev+7HenWr2L3+ezePoEKrcP7nvSDiGDun5+S LtkNOIbOqXZ995Hevltj5SpNfpXfhqD6R7a6Wske2vSqIxoNPjXK9Hit0Z1+ri2G6SUhi1NTsZ CdQxrtJrrmeN3ldAGzQQYq5fH7jkv6XUdzMc2ynvfzWzlQz9DoHvOPWGGHFL7d1e+j51To95Hb JYWiqX+nTB0YaLCoZbc6kb6Ly8IHCr3S6Q88rT2BmUba6XjTBRyC+OXs+9+2MEocaoqLS22M+N nwapdNKRZBNlAlWWLDyyn50EG/T0t9vB3nBEnybd3RJuCQ==; 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:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=zDSnEL2d0dTMjmYMGBoIc7EfR6vTUjA9Y5s6U56eiag=; b=kpRus4I7iRL5ysCnJz45sidxK1 cG99WseMFtGYs9yzikybnFxSgMdPiyQYrMhVOBo94RJ+tRTlM9f5kVXB0UK4+jtI/MGAoddWHfe84 xSvkQ0Wiw1quoJhQxNg+veasysQidN/5ShTKbSQIBVhZKy+K7MqzgTejehXxz1omwDfXq1y2yl7dJ +XRb9IIRG+uhFXBHinMSehS2qLpnWLdMbOZbo+ePq/dt1h1bxtFZpZlJW5MZJSaiClnKOy2PINSOh iCFovj0O6WnBHcqo7cgGP4u2mr3ZenfXGkWbFfeC4cfugqTcJyygThljlRKfKCO1/OU/MLg+Jw1eB YqEWngdA==; Received: from authenticated user by zero.zsh.org with local id 1nj6G8-000EeL-Ui; Mon, 25 Apr 2022 21:28:41 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:45910) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nj6Fb-000EJo-9s; Mon, 25 Apr 2022 21:28:08 +0000 Received: by mail-ej1-f48.google.com with SMTP id y3so11785110ejo.12 for ; Mon, 25 Apr 2022 14:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=zDSnEL2d0dTMjmYMGBoIc7EfR6vTUjA9Y5s6U56eiag=; b=5PEwhEDWClqelOCg1N0BVZ4rXmKb0XYnx9aa1GGoxt3y6uBYKyhsRwK6BSB+y5bT0l L7C1Jls+6Fd0lf7EYoyzsqT68tE+y9YKeS0ltl0TKhhoB8Gi/HF+ujOw8iswu9MekqEK RVg9h0NjmoRE6G8ylAy/cKLv6vCsncgK1EgYPyK/nbof5MjsZ3wi02I3cXEkU03jcu94 27aZ0ML4ceWqcoaKSo6GZ5uzbyyZIB+cAvJtmUltzomYoGvIHUr39CcisbBFQwSLO56q A4euitNHirgYbYiW2xn07DIy5zgh/158q+HDN0Sz/QAzsDvsrL7LwwRlOI3n6KWPs2JU AFNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=zDSnEL2d0dTMjmYMGBoIc7EfR6vTUjA9Y5s6U56eiag=; b=RLKHeWDzY3H2ta7er30FcrL/yGYJ9wUV684VodWBkGtI0o4K7yNsqMJ5C4dZx1idiM MAJBj8tUMoAMeCLcvhI0hrMavALHx0o9l8Uvc2MTYSG9txPASmwQIrXM9fOXQ8royHaL VTmAf4NYz73+0lrXRJp6zfoGl6VDuIwzvjV/LkzThMdmNfMwGyxEE6X5hhbPmJub6EGr anwuyUNvtYSWII9j53YE+HZbrU6hTzXqmj3FCyZ2XCW5I21iHRxxvYudMVqKa7FtJi1w Hzqrj1cPZb6THDsT9lE0dxGtquKb915LrUOOXWhaId0ukAkLj68hLaezCgRvmi1gprvu 54VA== X-Gm-Message-State: AOAM530nNFPR9llkOaDZRCtcqgps16miAfY+IjdxbV9YM5bI1FeDYl7c k+k/4ufPGXlL6qkQvVI/Awfb6A0c8zj+pP0i9rlcXg== X-Google-Smtp-Source: ABdhPJxLM9T+kC3GmZVJm3ew7BpQaaU/FEPQk8B0tRooF+CPAgbP8N2iYEHmHsw3Qh0MXibFn2MxBkAO4F9PJf5ZnTQ= X-Received: by 2002:a17:907:62a1:b0:6da:7952:d4d2 with SMTP id nd33-20020a17090762a100b006da7952d4d2mr18147469ejc.260.1650922086613; Mon, 25 Apr 2022 14:28:06 -0700 (PDT) MIME-Version: 1.0 References: <20220425192036.p6awbyro2a2lp7bq@chazelas.org> In-Reply-To: <20220425192036.p6awbyro2a2lp7bq@chazelas.org> From: Bart Schaefer Date: Mon, 25 Apr 2022 14:27:54 -0700 Message-ID: Subject: Re: ZSH performance regression in 5.8.1.2-test To: Bart Schaefer , Jordan Patterson , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 50093 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: On Mon, Apr 25, 2022 at 12:20 PM Stephane Chazelas wrote: > > 2022-04-25 11:56:59 -0700, Bart Schaefer: > > On Mon, Apr 25, 2022 at 11:26 AM Jordan Patterson w= rote: > > > > > > This recent fix has led to a performance regression in zsh: 49792: > > > Non-interative shell input is line buffered. Jumping back to this for a moment: > > > Summary > > > 'prefix/5.8.1/bin/zsh -i -c exit' ran > > > 1.16 =C2=B1 0.06 times faster than 'prefix/5.8/bin/zsh -i -c exit' > > > 9.22 =C2=B1 0.27 times faster than 'prefix/5.8.1.2-test/bin/zsh -i= -c exit' I hadn't parsed closely before that 5.8.1 is faster than 5.8. That means avoiding stdio is faster if we don't have to do 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, The context is shell command input, that is, any of 1) loading init files 2) source or . command 3) zsh < file 4) command | zsh Have I missed any? The bug from https://bugs.gentoo.org/839900 crops up in a special case of 3 or 4 when the input runs a sub-command that itself wants to read from stdin. In that case the shell is supposed to have stopped reading at a newline, leaving the rest of the original input available to be consumed by the sub-command. >[...] 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. Theoretically we can block-read with impunity in cases 1 and 2 (anyone disagree?). Testing for seek-ability would allow doing the "read too much and back up" trick in case 3. I don't immediately see any way to avoid reading one byte at a time in case 4, does anyone have a suggestion? It does not appear from some quick tests that lseek(SHIN, 0, SEEK_CUR) is guaranteed to succeed in case 3 nor to fail with ESPIPE in case 4. How to distinguish them?