From owner-svn-src-all@freebsd.org Sat Feb 22 19:14:54 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 DEAEA249A5D; Sat, 22 Feb 2020 19:14:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 48Pygy4fxCz3PxT; Sat, 22 Feb 2020 19:14:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from [192.168.0.3] (unknown [181.52.72.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: pfg) by smtp.freebsd.org (Postfix) with ESMTPSA id 9B0316E8D; Sat, 22 Feb 2020 19:14:53 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Subject: Re: svn commit: r358152 - head/bin/sh To: Kyle Evans , Li-Wen Hsu Cc: Antoine Brodin , Hiroki Sato , src-committers , svn-src-all , svn-src-head References: <202002200301.01K31RTk043426@repo.freebsd.org> From: Pedro Giffuni Organization: FreeBSD Message-ID: <6f2029df-e08b-65eb-fa28-ca4dcdd351c8@FreeBSD.org> Date: Sat, 22 Feb 2020 14:14:53 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 19:14:55 -0000 For the record ... On 21/02/2020 22:31, Kyle Evans wrote: > 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, This is an example case of why it is important to keep the i386 port building and running. If we don't have a 32 bit port that is easy to build and test many bugs like these can easily go through. Cheers, Pedro.