From owner-freebsd-hackers@FreeBSD.ORG Sun Feb 3 13:13:12 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0719416A418 for ; Sun, 3 Feb 2008 13:13:12 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:610:652::211]) by mx1.freebsd.org (Postfix) with ESMTP id C5BC313C46B for ; Sun, 3 Feb 2008 13:13:11 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 599091CC4E; Sun, 3 Feb 2008 14:13:22 +0100 (CET) Date: Sun, 3 Feb 2008 14:13:22 +0100 From: Ed Schouten To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Message-ID: <20080203131322.GK1179@hoeg.nl> References: <8663x6mc2o.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aqWxf8ydqYKP8htK" Content-Disposition: inline In-Reply-To: <8663x6mc2o.fsf@ds4.des.no> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: hackers@freebsd.org Subject: Re: sort(1) memory usage X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2008 13:13:12 -0000 --aqWxf8ydqYKP8htK Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Dag-Erling Sm=F8rgrav wrote: > I've been trying to figure out why some periodic scripts consume so much > memory. I've narrowed it down to sort(1). >=20 > At first, I thought the scripts were using it inefficiently, feeding it > more data than was really needed. Then I discovered this: >=20 > des@ds4 ~% (sleep 10 | sort) & (sleep 5 ; top -o res | grep sort) > [1] 66024 > 66024 des 1 -8 5 54796K 52680K piperd 1 0:00 0.88% sort >=20 > That's right - sort(1) consumes 50+ MB of memory doing *nothing*. >=20 > (roughly half that on a 32-bit box) >=20 > Something is rotten in the state of GNU... On my i386 box it spends 27M, but when I replace `sort' with `sed', without any arguments, it's only 1.4 MB. I tried this on RELENG_6. I can also reproduce this on Linux. --=20 Ed Schouten WWW: http://g-rave.nl/ --aqWxf8ydqYKP8htK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkelvfIACgkQ52SDGA2eCwVMMgCfSr+69jompdlAkN3rkIc3UZIA iqEAn3YNc1ShXVZ6JkvgKXSddX7aOHZs =8rpC -----END PGP SIGNATURE----- --aqWxf8ydqYKP8htK--