From owner-freebsd-stable@FreeBSD.ORG Tue Oct 4 11:15:25 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAF0C106566C; Tue, 4 Oct 2011 11:15:25 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8511C8FC13; Tue, 4 Oct 2011 11:15:25 +0000 (UTC) Received: by ggeq3 with SMTP id q3so178883gge.13 for ; Tue, 04 Oct 2011 04:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=kZ40Jos8Rqd8K71Sgc8OjgrrIKBZNbhJqnAbrvGdTRU=; b=vrhftg89CLWBPUleOGzFHFjPLOWMl7RBKgYLCyhvqgH3cVStBIMo1+ZtA+im9hWMMU 9pQM1lLwcAFavtaBI44BKwgRrq8tMktoldGy1+aiFqMBljDmjPWA8yCL9pXv9GRICUDf vIxTEJEVSxqGlJmF1IoEFGFkQZWMNxB7wYTNQ= MIME-Version: 1.0 Received: by 10.42.149.74 with SMTP id u10mr1664563icv.215.1317726924688; Tue, 04 Oct 2011 04:15:24 -0700 (PDT) Received: by 10.42.241.4 with HTTP; Tue, 4 Oct 2011 04:15:24 -0700 (PDT) In-Reply-To: <86d3eydsmf.fsf@kopusha.home.net> References: <20110918045413.GA63773@DataIX.net> <20110918053901.GA31617@icarus.home.lan> <86d3eydsmf.fsf@kopusha.home.net> Date: Tue, 4 Oct 2011 14:15:24 +0300 Message-ID: From: Mikolaj Golub To: Ronald Klop Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Chris Torek , "freebsd-stable@freebsd.org" , Jeremy Chadwick , cperciva@freebsd.org Subject: Re: /usr/bin/script eating 100% cpu with portupgrade and xargs X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 11:15:25 -0000 On Sun, Sep 18, 2011 at 1:58 PM, Mikolaj Golub wrote: > > On Sun, 18 Sep 2011 08:47:13 +0200 Ronald Klop wrote: > > =A0RK> On Sun, 18 Sep 2011 07:39:01 +0200, Jeremy Chadwick > =A0RK> wrote: > > =A0>> On Sun, Sep 18, 2011 at 12:54:13AM -0400, Jason Hellenthal wrote: > =A0>>> On Sun, Sep 18, 2011 at 01:49:15AM +0200, Ronald Klop wrote: > =A0>>> > Hi, > =A0>>> > > =A0>>> > I'm running portupgrade in screen to update all the ports for > =A0>>> > 9-BETA2/9-CURRENT on amd64. While doing this script eats 100% cp= u. > =A0>>> > Because portupgrade -fa crashed I'm running this command to upda= te the > =A0>>> > remaining non-updates ports. > =A0>>> > find /var/db/pkg -name +DESC -mtime +2 |cut -d / -f 5 | xargs > =A0>>> time nice -n > =A0>>> > 20 portupgrade -f > =A0>>> > > =A0>>> > The output of truss -p `pgrep script` is this: > =A0>>> > clock_gettime(13,{1316301104.000000000 }) =A0 =A0 =A0 =A0=3D 0 (= 0x0) > =A0>>> > select(5,{0 4},0x0,0x0,{30.000000 }) =A0 =A0 =A0 =A0 =A0 =A0 =3D= 1 (0x1) > =A0>>> > read(0,0x7fffffffcdf0,1024) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0=3D 0 (0x0) > =A0>>> > write(4,0x7fffffffcdf0,0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0=3D 0 (0x0) > =A0>>> > clock_gettime(13,{1316301104.000000000 }) =A0 =A0 =A0 =A0=3D 0 (= 0x0) > =A0>>> > select(5,{0 4},0x0,0x0,{30.000000 }) =A0 =A0 =A0 =A0 =A0 =A0 =3D= 1 (0x1) > =A0>>> > read(0,0x7fffffffcdf0,1024) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0=3D 0 (0x0) > =A0>>> > write(4,0x7fffffffcdf0,0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0=3D 0 (0x0) > =A0>>> > clock_gettime(13,{1316301104.000000000 }) =A0 =A0 =A0 =A0=3D 0 (= 0x0) > =A0>>> > select(5,{0 4},0x0,0x0,{30.000000 }) =A0 =A0 =A0 =A0 =A0 =A0 =3D= 1 (0x1) > =A0>>> > read(0,0x7fffffffcdf0,1024) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0=3D 0 (0x0) > =A0>>> > write(4,0x7fffffffcdf0,0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0=3D 0 (0x0) > =A0>>> > clock_gettime(13,{1316301104.000000000 }) =A0 =A0 =A0 =A0=3D 0 (= 0x0) > =A0>>> > select(5,{0 4},0x0,0x0,{30.000000 }) =A0 =A0 =A0 =A0 =A0 =A0 =3D= 1 (0x1) > =A0>>> > read(0,0x7fffffffcdf0,1024) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0=3D 0 (0x0) > =A0>>> > write(4,0x7fffffffcdf0,0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0=3D 0 (0x0) > =A0>>> > > =A0>>> > So it is really fast in reading and writing 0 bytes most of the = time. > =A0>>> > > =A0>>> > I also found > =A0>>> http://web.archiveorange.com/archive/v/6ETvLvjo60Gj9geAUAb6 > =A0>>> > and I think I am better of by rewriting my command so stdin/stdo= ut is > =A0>>> > still the terminal. Although the link is a couple of years old. > =A0>>> > > =A0>>> > Is this known? Can somebody explain me why my xargs command is > =A0>>> not working > =A0>>> > well? > =A0>>> > > =A0>>> > =A0>>> Are you absolutely sure that its script(1) causing this ? 100% CPU= usage > =A0>>> has been a known side effect of screen(1) for quite some time. Reb= uild > =A0>>> it and try again. > =A0>> > =A0>> Jason's referring to this, I believe: > =A0>> http://www.freebsd.org/cgi/cvsweb.cgi/ports/sysutils/screen/Makefil= e#rev1.55 > =A0>> > =A0>> To clarify the what the commit message means: it does not mean "whe= n the > =A0>> package is installed the installation takes up 100% CPU". =A0It mea= ns > =A0>> "once the package is installed and screen is used, screen takes up = 100% > =A0>> CPU". =A0I know because I've seen this behaviour in the past (one o= f the > =A0>> many, many reasons I build ports from source). > =A0>> > =A0>> However: > =A0>> http://www.freebsd.org/cgi/cvsweb.cgi/ports/sysutils/screen/Makefil= e#rev1.78 > =A0>> > =A0>> So: If a binary package is being installed through your above > =A0>> portupgrade command, and you're seeing this problem, then it sounds= to > =A0>> me like commit revision 1.78 is a regression and NO_PACKAGE should = be > =A0>> put back into place + packages removed from all mirrors. > =A0>> > =A0>> There are many reasons to not use GNU screen at all, or if you must= have > =A0>> something like it, use tmux. =A0I recently had to provide an analys= is of > =A0>> how GNU screen destroys one's terminal[1]; so if the above problem = turns > =A0>> out to be caused by GNU screen as well, I'll just add it to my > =A0>> ever-growing list of reasons the software should be nuked from orbi= t. > =A0>> > =A0>> Otherwise, if this turns out to be a problem with portupgrade (whic= h you > =A0>> found some evidence supporting such), then the solution is simple: = stop > =A0>> using portupgrade, use portmaster (if it lacks things you need ask = Doug > =A0>> Barton, he's incredibly receptive to adding new features/fixing thi= ngs). > =A0>> Two databases that aren't compatible, ruby shims, and other crap = =3D not > =A0>> worth it. =A0Think the database ordeal is long over with/fixed/what= ever? > =A0>> It isn't[2]. > =A0>> > =A0>> [1]: > =A0>> http://lists.freebsd.org/pipermail/freebsd-stable/2011-June/063052.= html > =A0>> [2]: > =A0>> http://www.dslreports.com/forum/r26304856-FreeBSD-defining-portmast= er-alias > =A0>> > > =A0RK> I have a repeatable test. Run top in a window and this command in = another. > =A0RK> $ echo test | script /tmp/script-test sleep 1000 > =A0RK> Script started, output file is /tmp/script-test > =A0RK> test > > =A0RK> =A0 PID USERNAME =A0 =A0 =A0 THR PRI NICE =A0 SIZE =A0 =A0RES STAT= E =A0 C =A0 TIME > =A0RK> CPU COMMAND > =A0RK> 29656 ronald =A0 =A0 =A0 =A0 =A0 1 103 =A0 =A00 12324K =A01244K CP= U4 =A0 =A04 =A0 1:03 > =A0RK> 100.00% script > > =A0RK> So it has nothing to do with portupgrade or screen. The output of > =A0RK> truss -p29656 is the same as posted previously. > > I believe the behaviour is after this commit: > > http://svnweb.freebsd.org/base?view=3Drevision&revision=3D125848 > > I think we should skip select on STDIN after reading EOF from it, like in= the > patch below. For the record. The issue has been fixed in CURRENT and the fix has been merged to STABLE. Thanks Kostik and Chris for their comments and suggestions. --=20 Mikolaj Golub