From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 2 17:25:40 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7F7922A7 for ; Sun, 2 Jun 2013 17:25:40 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-ie0-x22f.google.com (mail-ie0-x22f.google.com [IPv6:2607:f8b0:4001:c03::22f]) by mx1.freebsd.org (Postfix) with ESMTP id 53FEA10C0 for ; Sun, 2 Jun 2013 17:25:40 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id tp5so8415227ieb.34 for ; Sun, 02 Jun 2013 10:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=25SdHFSHOuTDszYb0KnmpcdRMkfzH8qQOHQ8tE+LIeY=; b=v4CAbGM44flw4JwHRWMG5glJyYAwrLd5oKFzu/bnjdGTsdyAy9HuqGewc4hMMIyxO6 UpXQNuYyQ9XcrMGarnzhX4lNs18AjTj03WvWCGnfrx4Oykk8pX47160LJJC4fbYsTbs8 SvZcNtyrFK2obrYmU7x+91WseXFIMAFXHNXf6rws3y2NYtna0hC4pSdAgY+T4TAXc3Gi mWkz6mEgwTqOy2Ph7/4os+fRgRZasirTBOO+l8e3BPXedS5JuuQ4gc4V+c+QeRwBtWsb /EQQ0g3vW2Gwk8nn0ghoTfMaPu4oIHEEBhR/xVulPe3LTpyjOClu0HMbItpKBxtuSwAk ZxaQ== X-Received: by 10.42.78.136 with SMTP id n8mr8929018ick.52.1370193940077; Sun, 02 Jun 2013 10:25:40 -0700 (PDT) MIME-Version: 1.0 Sender: utisoft@gmail.com Received: by 10.64.71.101 with HTTP; Sun, 2 Jun 2013 10:25:10 -0700 (PDT) In-Reply-To: <51AB7DCD.90104@peterschmitt.fr> References: <20130602124127.6c3a847ea5ddb116a69d4814@yahoo.es> <51AB7DCD.90104@peterschmitt.fr> From: Chris Rees Date: Sun, 2 Jun 2013 18:25:10 +0100 X-Google-Sender-Auth: 0MnFVla9JNeeRicHm-BHHlsXh9U Message-ID: Subject: Re: sed query To: florent+FreeBSD-hackers@peterschmitt.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list 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:25:40 -0000 On 2 June 2013 18:15, Florent Peterschmitt wrote: > 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 t= he second times. >>> >> >> Nope, same. >> >> [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 >> >> I also get the same on head; >> >> [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 >> >> 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 ? > BSD sed, GNU sed doesn't show this; [crees@pegasus]/usr/ports/textproc/gsed% time gsed -ne "s,^BitchX-[0-9][^|]*[\|]/usr/por,," /var/db/pkg/INDEX-9 0.019u 0.009s 0:00.04 25.0% 408+6132k 1+0io 2pf+0w Chris