From owner-svn-src-head@freebsd.org Fri Feb 21 22:07:19 2020 Return-Path: Delivered-To: svn-src-head@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 EE7E3245475; Fri, 21 Feb 2020 22:07:19 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48PQYM62qcz4q9s; Fri, 21 Feb 2020 22:07:19 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-ot1-f43.google.com with SMTP id i6so3427819otr.7; Fri, 21 Feb 2020 14:07:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=RGvMfszjYcK1S12S6oW+Qlnd340osGw1XhRC5zD4Pxc=; b=aGPdM4LhLU4QZ1KAxSq1NFSZFhhOoO/m7XVyqUhaq/Dy2gGzvhoXZAJWLME6e9DD5O ndc0oQgcDMbQfUNRIk1ZOHs/w27R27SlT0rLAWI3cQIMjutO10bCjTe9mlMrr45g973O 4hLk+8IBUTKUam/XIFwKRH+rclWePcp9ZShR6Sjg0S2AgfcYGTS/lg46vo6LDQvS0mv4 VqNsKz2QpnN/incPMVYXduon3GZYUPpNGSE3G4yAAW0VQtT94U5zkOy12P5UUToWl0OP ZyYQYMy0/0nJpfL2pd77KeJ7bMIvyIXclDDE1GU5lsTE82iyz9It+BJfD6eXlIGk+OcC nkkA== X-Gm-Message-State: APjAAAVd7+IHKznnkkIhOZemn64MQahVHiwzUqkVYCXH9RZQiuj1YLqg WnPXOix2IqZjscOO2Ll4ciHGZvPQ X-Google-Smtp-Source: APXvYqzBSEcJOfjE4yqv8V5iRnFU49ekXQu/Wx0Xty2TriLcz5fDckhAkltXSKDYXqm99sDQ0PIHcQ== X-Received: by 2002:a9d:1c96:: with SMTP id l22mr30641975ota.322.1582322837309; Fri, 21 Feb 2020 14:07:17 -0800 (PST) Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com. [209.85.167.169]) by smtp.gmail.com with ESMTPSA id l207sm1371898oih.25.2020.02.21.14.07.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Feb 2020 14:07:17 -0800 (PST) Received: by mail-oi1-f169.google.com with SMTP id b18so3141554oie.2; Fri, 21 Feb 2020 14:07:16 -0800 (PST) X-Received: by 2002:aca:cf12:: with SMTP id f18mr3896392oig.81.1582322836417; Fri, 21 Feb 2020 14:07:16 -0800 (PST) MIME-Version: 1.0 References: <202002200301.01K31RTk043426@repo.freebsd.org> In-Reply-To: Reply-To: cem@freebsd.org From: Conrad Meyer Date: Fri, 21 Feb 2020 14:07:05 -0800 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-Rspamd-Queue-Id: 48PQYM62qcz4q9s X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Feb 2020 22:07:20 -0000 Given the report and looking at the change, I suspect the problem is the promotion of '-residue' from size_t (unsigned 32-bit on i386) to off_t (signed 64-bit). Something like '-(off_t)residue' or even 'off_t residue;' should fix it. Repro: static void myoff(off_t foo) { printf("%jd\n", (intmax_t)foo); } void main(int argc, char **argv) { uint32_t sz = 1023; myoff(-sz); } Prints: "4294966273" (not: "-1023"). Either proposed fix above produces the expected -1023. Best, Conrad On Fri, Feb 21, 2020 at 1: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. > > Thanks, > Li-Wen