From owner-freebsd-hackers Fri Jul 30 10:28: 7 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from metriclient-2.uoregon.edu (metriclient-2.uoregon.edu [128.223.172.2]) by hub.freebsd.org (Postfix) with ESMTP id 0784014D04 for ; Fri, 30 Jul 1999 10:27:56 -0700 (PDT) (envelope-from gurney_j@efn.org) Received: (from jmg@localhost) by metriclient-2.uoregon.edu (8.9.1/8.8.7) id KAA10966; Fri, 30 Jul 1999 10:27:26 -0700 (PDT) Message-ID: <19990730102726.34286@hydrogen.fircrest.net> Date: Fri, 30 Jul 1999 10:27:26 -0700 From: John-Mark Gurney To: "Daniel C. Sobral" Cc: Dag-Erling Smorgrav , freebsd-hackers@FreeBSD.ORG Subject: Re: replacing grep(1) References: <19990729182229.E24296@mad> <19990729164533.36798@hydrogen.fircrest.net> <37A1BD1A.59DF842E@newsguy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.69 In-Reply-To: <37A1BD1A.59DF842E@newsguy.com>; from Daniel C. Sobral on Fri, Jul 30, 1999 at 11:56:26PM +0900 Reply-To: John-Mark Gurney Organization: Cu Networking X-Operating-System: FreeBSD 3.0-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Daniel C. Sobral scribbled this message on Jul 30: > Dag-Erling Smorgrav wrote: > > > > To be precise, I experience a 30% decrease in system time and a 100% > > increase in user time when I use RE_STARTEND and eliminate the > > malloc() / memcpy() calls in procfile(). > > Could you please test my patch that removes malloc() but bot > memcpy()? Here it is again, though against an old version: wierd, I was running your patch, and at first I would get from .69 up to 1.03 seconds run time, but I can't seem to generate that problem right now... w/ your patches I'm getting around .67 to .7 seconds for: time ./grep THIS /tmp/ports/freegrep/work/grep-0.10/termcap.long > /dev/null 0.68 real 0.63 user 0.03 sys 0.67 real 0.65 user 0.01 sys 0.67 real 0.63 user 0.03 sys 0.67 real 0.63 user 0.03 sys 0.67 real 0.66 user 0.00 sys 0.67 real 0.64 user 0.02 sys summary of gprof output: [3] 50.1 0.02 0.21 108213 procline [3] [4] 46.7 0.02 0.19 108213 regexec [4] [7] 28.5 0.13 0.00 108214 mmfgetln [7] [10] 4.8 0.00 0.02 2393 grep_realloc [10] with my patch and the exact same command, I get .58 to .59 seconds... 0.58 real 0.54 user 0.03 sys 0.58 real 0.53 user 0.04 sys 0.58 real 0.55 user 0.02 sys 0.58 real 0.57 user 0.00 sys 0.59 real 0.55 user 0.02 sys 0.58 real 0.55 user 0.02 sys summary of gprof output: [3] 57.1 0.04 0.19 108213 procline [3] [4] 48.0 0.02 0.17 108213 regexec [4] [7] 34.1 0.13 0.00 108214 mmfgetln [7] [10] 2.0 0.01 0.00 1 _munmap [10] (I include _munmap because realloc/malloc/free are in the 0.0% on my patch) and grep 0.10 w/o patches: 2.82 real 1.63 user 1.12 sys 2.79 real 1.53 user 1.20 sys 2.80 real 1.65 user 1.08 sys 2.84 real 1.67 user 1.10 sys 2.82 real 1.67 user 1.08 sys 2.91 real 1.66 user 1.14 sys summary of gprof output: [5] 55.1 1.12 0.00 74985 _madvise [5] [7] 13.3 0.04 0.23 108213 regexec [7] [9] 8.4 0.00 0.17 108217 grep_malloc [9] [13] 6.5 0.13 0.00 108214 mmfgetln [13] all of the programs were compiled w/ the exact same options... that is I added -g -pg to the CFLAGS in the Makefile to generate profiling info.. I'm not sure about you, but on my k6/200, the STARTEND is more efficient than the memcpy/realloc, and to tell you the truth, I can't see why it'd be more effecient to copy possible multiple kilobytes of data than to just use indexes instead of modifing a ptr... right now, I'm trying to think of a way to eliminate the fgetln searching for end of line... of course this would eliminate some of the simplicity of design, but we can get a BIG speed increase if we simply don't scan for the new line unless we NEED to... and if we do, why not use regexec to search for us? -- John-Mark Gurney Voice: +1 541 684 8449 Cu Networking P.O. Box 5693, 97405 "The soul contains in itself the event that shall presently befall it. The event is only the actualizing of its thought." -- Ralph Waldo Emerson To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message