From owner-freebsd-hackers@FreeBSD.ORG Fri May 31 14:02:30 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 283DC589 for ; Fri, 31 May 2013 14:02:30 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-ie0-x232.google.com (mail-ie0-x232.google.com [IPv6:2607:f8b0:4001:c03::232]) by mx1.freebsd.org (Postfix) with ESMTP id 037CF5F4 for ; Fri, 31 May 2013 14:02:29 +0000 (UTC) Received: by mail-ie0-f178.google.com with SMTP id f4so3930805iea.23 for ; Fri, 31 May 2013 07:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=ztOGiTh1PVlCdo77I1KqQrJajSFYPdUtFqBzIcgQLMI=; b=pob5lmN+Mr4I6DbRbtbVS6T41lmPK0dtPy2fa3cr4y1hoKIKysUigtoFjXXGTLJHlH zmWVX4uMuYOvOpKKu80+xsp1BRpB3/hEWrhSAT4kzr2YmTmEJ/rST5P3kSk4Fl4rFOvc EIBxmD9A7EdJUjOZMZPHWucejoDoQ6F98Ci0ODGXDqIt1R5f5xj3DpLUau7wCOUP51Ps sOgTUlSOLbQGhKWZ0ItuTKTcBnqcfZeYcvUnVBbD//mllsn0xUC8Q0BmH+WiTULipo/I /BQHeDElbxd5oaNeWRqwQvNvU1HQwOWJbCCYhKGKH550VLoQI14tXa5KxYdpw/+LkuLG 1s8A== X-Received: by 10.43.106.202 with SMTP id dv10mr5047561icc.37.1370008949717; Fri, 31 May 2013 07:02:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.71.101 with HTTP; Fri, 31 May 2013 07:01:59 -0700 (PDT) From: Chris Rees Date: Fri, 31 May 2013 15:01:59 +0100 Message-ID: Subject: sed query To: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 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: Fri, 31 May 2013 14:02:30 -0000 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? Chris