From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 2 17:15:57 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3AFD6D2E for ; Sun, 2 Jun 2013 17:15:57 +0000 (UTC) (envelope-from florent@peterschmitt.fr) Received: from peterschmitt.fr (peterschmitt.fr [5.135.177.31]) by mx1.freebsd.org (Postfix) with ESMTP id 03D0A1074 for ; Sun, 2 Jun 2013 17:15:57 +0000 (UTC) Received: from [192.168.0.23] (4ab54-4-88-163-248-31.fbx.proxad.net [88.163.248.31]) by peterschmitt.fr (Postfix) with ESMTPSA id 227AFA01A for ; Sun, 2 Jun 2013 19:16:05 +0200 (CEST) Message-ID: <51AB7DCD.90104@peterschmitt.fr> Date: Sun, 02 Jun 2013 19:15:57 +0200 From: Florent Peterschmitt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130518 Icedove/17.0.5 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: Re: sed query References: <20130602124127.6c3a847ea5ddb116a69d4814@yahoo.es> In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2OXNLHBMCPGIXBUFVWDBJ" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: florent+FreeBSD-hackers@peterschmitt.fr List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2013 17:15:57 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2OXNLHBMCPGIXBUFVWDBJ Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Le 02/06/2013 14:16, Chris Rees a =E9crit : > On 2 June 2013 11:41, Eduardo Morras wrote: >> On Fri, 31 May 2013 15:01:59 +0100 >> Chris Rees wrote: >> >>> Hi all, >>> >>> I think I've discovered a strange behaviour of sed perhaps triggered >>> by the length of a regex passed to it. I noticed that a certain >>> expression I passed took a very long time, and suspected the usual >>> backtracking loop, so I started trimming it... and discovered this: >>> >>> [crees@pegasus]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/por,," >>> /var/db/pkg/INDEX-9 >>> 4.699u 0.007s 0:04.70 99.7% 40+2733k 0+0io 0pf+0w >>> [crees@pegasus]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/po,," >>> /var/db/pkg/INDEX-9 >>> 0.042u 0.000s 0:00.04 100.0% 48+3216k 0+0io 0pf+0w >>> >>> I've looked at the code, and can't from a brief glance figure out why= >>> a slightly longer regex makes such a difference-- does it start to >>> split it? >> >> Perhaps second one uses memory cache data? Run both twice and show us = the second times. >> >=20 > Nope, same. >=20 > [crees@pegasus]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/por,," > /var/db/pkg/INDEX-9 > 4.703u 0.007s 0:04.85 96.9% 40+2732k 210+0io 0pf+0w > [crees@pegasus]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/por,," > /var/db/pkg/INDEX-9 > 4.748u 0.007s 0:04.75 99.7% 40+2732k 0+0io 0pf+0w >=20 > I also get the same on head; >=20 > [crees@medusa]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/por,," > /var/db/pkg/INDEX-10 > 7.813u 0.015s 0:07.96 98.2% 40+183k 0+0io 0pf+0w > [crees@medusa]~% time sed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/po,," > /var/db/pkg/INDEX-10 > 0.070u 0.000s 0:00.07 100.0% 45+205k 0+0io 0pf+0w > [crees@medusa]~% uname -a > FreeBSD medusa 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r250009: Thu May > 30 10:11:16 BST 2013 root@medusa:/usr/obj/usr/src/sys/MEDUSA > amd64 >=20 > Chris Yes I tried too on -current. And I tried also on GNU/Linux and there isn't this problem. Is it gnu or bsd sed ? ------enig2OXNLHBMCPGIXBUFVWDBJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQEcBAEBAgAGBQJRq33NAAoJEMtO2Sol0IImXpUH/i53OklcKPgFAfyAnZlZIbjj +vXwrIC6OnnOieZlaLHaCZlD1Aip5mf+yzRsw56m2fyA3uj/fbf0LIqTMhsY3/k/ W+SrNkmUu/PDjFxLlNb9OOrt7zRqsIfqqgM5+C38S+ClvfIVDg47jfMbePooT5+A 8JCNLzIbjHZ8JN4gtVKRkJpW3qBwhVtVJnD5VGYamSeRLIenKt4+UWc3HVqDjNOp es15m2+ZkT5UtQWiGZ3q8h1ujXD3d0P+tDx/PFSl1U9ZNrMH28JlQyI/sEpCl4U7 Tdhdmd7ge3RUL7w/tnESx3mnY2qlL40YyHodWIt2tHGAj4j7Xc2fUVHTRqoIJjQ= =2tGp -----END PGP SIGNATURE----- ------enig2OXNLHBMCPGIXBUFVWDBJ--