Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Oct 2011 14:15:24 +0300
From:      Mikolaj Golub <to.my.trociny@gmail.com>
To:        Ronald Klop <ronald-freebsd8@klop.yi.org>
Cc:        Chris Torek <chris.torek@gmail.com>, "freebsd-stable@freebsd.org" <freebsd-stable@freebsd.org>, Jeremy Chadwick <freebsd@jdc.parodius.com>, cperciva@freebsd.org
Subject:   Re: /usr/bin/script eating 100% cpu with portupgrade and xargs
Message-ID:  <CAOnPXZ9z2MoZ7uxyUQzBx3Lz1mhY-2JKxO0mepzMp81J4WEVtw@mail.gmail.com>
In-Reply-To: <86d3eydsmf.fsf@kopusha.home.net>
References:  <op.v1y8gdtf8527sy@pinky> <20110918045413.GA63773@DataIX.net> <20110918053901.GA31617@icarus.home.lan> <op.v1zrszht8527sy@pinky> <86d3eydsmf.fsf@kopusha.home.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 18, 2011 at 1:58 PM, Mikolaj Golub <trociny@freebsd.org> 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> <freebsd@jdc.parodius.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOnPXZ9z2MoZ7uxyUQzBx3Lz1mhY-2JKxO0mepzMp81J4WEVtw>