Date: Fri, 13 Aug 2010 10:41:35 -0500 (CDT) From: "Sean C. Farley" <scf@FreeBSD.org> To: Gabor Kovesdan <gabor@FreeBSD.org> Cc: current@FreeBSD.org Subject: Re: Official request: Please make GNU grep the default Message-ID: <alpine.BSF.2.00.1008131034440.35204@thor.farley.org> In-Reply-To: <4C650B75.3020800@FreeBSD.org> References: <4C6505A4.9060203@FreeBSD.org> <4C650B75.3020800@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Fri, 13 Aug 2010, Gabor Kovesdan wrote: > Em 2010.08.13. 10:43, Doug Barton escreveu: >> My reason is simple, performance. While doing some portmaster work >> recently I was regression testing some changes I made to the --index* >> options and noticed that things were dramatically slower than the >> last time I tested those features. Thinking that I had made a >> programming mistake I dug into my code, and while the regexps that I >> was using could be tuned for slightly better performance the problem >> was not in my code. I then installed textproc/gnugrep to compare, >> and the differences were very dramatic using a highly pessimized test >> case (finding a match on the last line of INDEX). The script I used >> to test is at http://people.freebsd.org/~dougb/grep-time-trial.sh.txt >> and a typical result was: >> >> GNU grep >> Elapsed time: 2 seconds >> >> BSD grep >> Elapsed time: 47 seconds >> > Ok, I'll take care of this soon, and make GNU grep default, again with > a knob to build BSD grep. I agree with you that we cannot allow such a > big performance drawback but I my measures only showed significant > differences for very big searches and I didn't imagine that it could > add up to such a big diference. I'm sorry for the bad decision I took > making it default. This should trim some time off BSD grep. It removes the lock/unlock for each fgetc() by locking/unlocking the file once. stdio can be slow. You probably want to replace flockfile() with ftrylockfile() if threads will be involved at some point (threading or making a libgrep that may be used in a threaded process). Sean -- scf@FreeBSD.org [-- Attachment #2 --] Index: file.c =================================================================== --- file.c (revision 210862) +++ file.c (working copy) @@ -74,7 +74,7 @@ switch (filebehave) { case FILE_STDIO: - return (fgetc(f->f)); + return (getc_unlocked(f->f)); case FILE_GZIP: return (gzgetc(f->gzf)); case FILE_BZIP: @@ -189,6 +189,7 @@ f = grep_malloc(sizeof *f); if ((f->f = fdopen(STDIN_FILENO, "r")) != NULL) { + flockfile(f->f); f->stdin = true; return (f); } @@ -238,6 +239,7 @@ switch (filebehave) { case FILE_STDIO: + funlockfile(f->f); fclose(f->f); break; case FILE_GZIP:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1008131034440.35204>
