From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 4 12:49:59 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEDE1106566B for ; Wed, 4 Nov 2009 12:49:58 +0000 (UTC) (envelope-from mel.flynn+fbsd.hackers@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 882B58FC1C for ; Wed, 4 Nov 2009 12:49:58 +0000 (UTC) Received: from smoochies.rachie.is-a-geek.net (mailhub.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 93AAB7E853; Wed, 4 Nov 2009 03:49:56 -0900 (AKST) From: Mel Flynn To: freebsd-hackers@freebsd.org, rea-fbsd@codelabs.ru Date: Wed, 4 Nov 2009 13:49:54 +0100 User-Agent: KMail/1.12.1 (FreeBSD/8.0-RC1; KDE/4.3.1; i386; ; ) References: <200911032122.28905.mel.flynn+fbsd.hackers@mailing.thruhere.net> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200911041349.54943.mel.flynn+fbsd.hackers@mailing.thruhere.net> Cc: Subject: Re: Issue with grep -i (on i386 only?) 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: Wed, 04 Nov 2009 12:49:59 -0000 On Wednesday 04 November 2009 04:05:44 Eygene Ryabinkin wrote: > Mel, good day. > > Tue, Nov 03, 2009 at 09:22:28PM +0100, Mel Flynn wrote: > > So on the laptop I modified the testscript as it is attached now and > > while there is still a significant delay, the wallclock time is less > > then half, when the expression is rewritten with the same meaning: > > =>>> 16777216 > > =>>> fgrep > > 0.04 real 0.03 user 0.00 sys > > 0.05 real 0.03 user 0.01 sys > > 0.02 real 0.00 user 0.00 sys > > =>>> pcregrep > > 0.26 real 0.21 user 0.02 sys > > 0.26 real 0.22 user 0.02 sys > > 0.44 real 0.35 user 0.01 sys > > =>>> grep > > 0.04 real 0.04 user 0.00 sys > > 4.45 real 4.15 user 0.01 sys > > 2.00 real 1.81 user 0.00 sys <-- [fF][Oo][Oo] > > Just did a quick test on the 8.0-RC2/i386 with very old Athlon processor: > ----- > =>>> 16777216 > =>>> fgrep > 0,09 real 0,04 user 0,05 sys > 0,18 real 0,06 user 0,03 sys > 0,05 real 0,01 user 0,04 sys > =>>> pcregrep > 0,47 real 0,29 user 0,07 sys > 0,52 real 0,33 user 0,07 sys > 0,77 real 0,45 user 0,03 sys > =>>> grep > 0,09 real 0,08 user 0,01 sys > 0,10 real 0,04 user 0,05 sys > 0,23 real 0,12 user 0,03 sys > ----- > Pattern for the plain 'grep' is stable: first and second variants always > give the same time within a 0.01 second variation and the last variant > gives 2x slowdown. > > I tried sizes up to the 64M -- the pattern stays. The same stuff for > the amd64, so in my case I don't see the difference in behaviour. So, > maybe, the problem isn't 32 vs 64 but lies somewhere else. Well, just ruled out the last commonality: The i386 machines tested all had MAXPHYS to 1M, except the one I just tried: =>>> 16777216 =>>> fgrep 0.04 real 0.03 user 0.00 sys 0.04 real 0.03 user 0.00 sys 0.02 real 0.00 user 0.01 sys =>>> grep 0.04 real 0.02 user 0.02 sys 3.70 real 3.56 user 0.00 sys 1.91 real 1.83 user 0.02 sys Using env MALLOC_OPTIONS= also has no impact at all (just in case defaults aren't that). Since fgrep is fast and basically seeds the cache for grep, I'm ruling out disks/io reads. In fact, /tmp on this laptop is memory disk (one reason I couldn't go up to 64M :)). I honestly can't figure out what my 'local problem' could be or your optimization. Thanks for the fix ups. One more below sig. -- Mel --- grep-test.sh.orig 2009-11-04 03:17:05.000000000 -0900 +++ grep-test.sh 2009-11-04 03:29:55.000000000 -0900 @@ -34,6 +34,10 @@ ;; esac + if [ ! -f ${TMPFILE} ]; then + # signalled + exit 0; + fi jot -r -c ${b} a z |rs -g 0 20 > ${TMPFILE} echo "=>>> ${b}" for prog in fgrep ${PCREGREP} ${BSDGREP} grep ; do