From owner-svn-src-all@freebsd.org Sat Feb 22 03:32:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F6DB24E541; Sat, 22 Feb 2020 03:32:06 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48PYm60THCz4tqm; Sat, 22 Feb 2020 03:32:06 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id DD67F1F8CD; Sat, 22 Feb 2020 03:32:05 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qk1-f173.google.com with SMTP id f3so895976qkh.3; Fri, 21 Feb 2020 19:32:05 -0800 (PST) X-Gm-Message-State: APjAAAXUghvDDTp5jpL0OmR2Ybh2HxywSqBacCtnbSfOKVb1x1mdzy68 BgZAcC7bsl0S2j0Oi+jFTtJfpzIdK0xx2pnh998= X-Google-Smtp-Source: APXvYqwveQAHQSn0Thg8zghHMq79FHW6G19b7Beq84CX3INEX78jDNLEqd1N7b2t7Zvl9FNKXHvwA05bEja/z3IUrtU= X-Received: by 2002:a37:a488:: with SMTP id n130mr36896918qke.120.1582342325292; Fri, 21 Feb 2020 19:32:05 -0800 (PST) MIME-Version: 1.0 References: <202002200301.01K31RTk043426@repo.freebsd.org> In-Reply-To: From: Kyle Evans Date: Fri, 21 Feb 2020 21:31:53 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r358152 - head/bin/sh To: Li-Wen Hsu Cc: Antoine Brodin , Hiroki Sato , src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Feb 2020 03:32:06 -0000 On Fri, Feb 21, 2020 at 3:53 PM Li-Wen Hsu wrote: > > On Sat, Feb 22, 2020 at 4:58 AM Antoine Brodin wrote: > > > > On Thu, Feb 20, 2020 at 4:01 AM Hiroki Sato wrote: > > > > > > Author: hrs > > > Date: Thu Feb 20 03:01:27 2020 > > > New Revision: 358152 > > > URL: https://svnweb.freebsd.org/changeset/base/358152 > > > > > > Log: > > > Improve performance of "read" built-in command when using a seekable > > > fd. > > > > > > The read built-in command calls read(2) with a 1-byte buffer because > > > newline characters need to be detected even on a byte stream which > > > comes from a non-seekable file descriptor. Because of this, the > > > following script calls >6,000 read(2) to show a 6KiB file: > > > > > > while read IN; do echo "$IN"; done < /COPYRIGHT > > > > > > When the input byte stream is seekable, it is possible to read a data > > > block and then reposition the file pointer to where a newline > > > character found. This change adds a small buffer to do this and > > > reduces the number of read(2) calls. > > > > > > Theoretically, multiple built-in commands reading the same seekable > > > byte stream in a single pipe chain can share the buffer. However, > > > this change just makes a single invocation of the read built-in > > > allocate a buffer and deallocate it every time for simplicity. > > > Although this causes read(2) to read the same regions multiple times, > > > the performance penalty should be small compared to the reduction of > > > read(2) calls. > > > > > > Reviewed by: jilles > > > MFC after: 1 week > > > Differential Revision: https://reviews.freebsd.org/D23747 > > > > This seems to be broken on at least i386. > > Please either fix or revert. > > > > Antoine (with hat: portmgr) > > Could you provide more detail? I'm worried because I didn't see > related regression from the recent test results. We may need to add > more test against the breakage you mentioned. > This trivially failed with the example in the commit message; only the first line would be output. It also triggered a failure of functional_test:read2 in /usr/tests/bin/sh/builtins on i386 (and all of the other platforms with a 32-bit size_t), which would exit with a non-zero status code. I tested and deployed the fix suggested by cem@ as r358235 by just making residue an off_t, Thanks, Kyle Evans