From owner-freebsd-current@FreeBSD.ORG Mon Aug 16 13:52:20 2010 Return-Path: Delivered-To: current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B010F1065670; Mon, 16 Aug 2010 13:52:20 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from mail.farley.org (mail.farley.org [IPv6:2001:470:1f0f:20:2::11]) by mx1.freebsd.org (Postfix) with ESMTP id 691738FC15; Mon, 16 Aug 2010 13:52:20 +0000 (UTC) Received: from thor.farley.org (HPooka@thor.farley.org [IPv6:2001:470:1f0f:20:1::5]) by mail.farley.org (8.14.4/8.14.4) with ESMTP id o7GDqFep050015; Mon, 16 Aug 2010 08:52:16 -0500 (CDT) (envelope-from scf@FreeBSD.org) Date: Mon, 16 Aug 2010 08:52:15 -0500 (CDT) From: "Sean C. Farley" To: =?ISO-8859-15?Q?Dag-Erling_Sm=F8rgrav?= In-Reply-To: <86y6c7bse5.fsf@ds4.des.no> Message-ID: References: <4C6505A4.9060203@FreeBSD.org> <4C650B75.3020800@FreeBSD.org> <86y6c7bse5.fsf@ds4.des.no> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="56599777-1799541866-1281964549=:21804" Content-ID: X-Spam-Status: No, score=-1.3 required=4.0 tests=AWL,BAYES_00,SPF_SOFTFAIL, T_FRT_PROFILE2 autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.farley.org Cc: Gabor Kovesdan , current@FreeBSD.org Subject: Re: Official request: Please make GNU grep the default X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2010 13:52:20 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --56599777-1799541866-1281964549=:21804 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT Content-ID: On Sun, 15 Aug 2010, Dag-Erling Smørgrav wrote: > "Sean C. Farley" writes: >> This should trim some time off BSD grep. > > Did you actually test your patch? It makes absolutely no measurable > difference. Yes, I saw a reduction, using the first test script Doug provided, from 36 to 27 seconds. I only sent the patch after profiling confirmed a reduction. The script ran non-profiled grep 100 times. "Trim" did not imply it would reduce the time from 36 to 2 seconds. Here are profiles of one execution of bsdgrep using the parameters from the script. Non-patched grep (cumulative time 4.17 seconds): % cumulative self self total time seconds seconds calls ms/call ms/call name 79.5 3.32 3.32 0 100.00% _mcount [1] 7.9 3.65 0.33 0 100.00% .mcount (106) 4.5 3.83 0.19 21971711 0.00 0.00 fgetc [7] 3.5 3.98 0.15 21993762 0.00 0.00 grep_feof [8] 2.5 4.09 0.10 21971711 0.00 0.00 grep_fgetc [6] 1.5 4.15 0.06 22051 0.00 0.02 grep_fgetln [5] 0.5 4.17 0.02 1352 0.02 0.02 read [9] 0.0 4.17 0.00 67 0.02 0.02 memset [14] 0.0 4.17 0.00 61 0.01 0.01 arena_run_split [17] 0.0 4.17 0.00 1 0.50 522.57 procfile [4] ... Patched grep (cumulative time 2.82 seconds): % cumulative self self total time seconds seconds calls ms/call ms/call name 77.4 2.19 2.19 0 100.00% _mcount [1] 8.4 2.42 0.24 0 100.00% .mcount (109) 6.1 2.60 0.17 21971711 0.00 0.00 grep_fgetc [6] 4.9 2.74 0.14 21993762 0.00 0.00 grep_feof [7] 2.7 2.81 0.08 22051 0.00 0.02 grep_fgetln [5] 0.3 2.82 0.01 1352 0.01 0.01 _read [10] 0.1 2.82 0.00 67 0.03 0.03 memset [13] 0.1 2.82 0.00 10 0.15 0.15 free [16] 0.0 2.82 0.00 1 1.00 398.11 procfile [4] ... getc_unlocked() is merely a macro around __sgetr() as opposed to calling into getc(). My patch was to show it could be reduced by removing some of stdio's overhead (one function call and unneeded locking). I did not have time to do a complete removal of stdio as I was unsure of any dependencies this version of bsdgrep had on stdio. For some reason, I thought there was mention of making bsdgrep into an application and library. If threading became involved, losing fgetc() would help more. Without threading, the test for locking would still be performed in getc(). Sean -- scf@FreeBSD.org --56599777-1799541866-1281964549=:21804--