Date: Wed, 18 Aug 2010 23:02:31 +0200 From: Gabor Kovesdan <gabor@FreeBSD.org> To: mdf@FreeBSD.org Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r211463 - head/usr.bin/grep Message-ID: <4C6C4A67.4000002@FreeBSD.org> In-Reply-To: <AANLkTimjHt9NZa0-vU%2Bm2dkY2pTciUDLGd0Qut=uhFTq@mail.gmail.com> References: <201008181740.o7IHeA4c075984@svn.freebsd.org> <AANLkTimjHt9NZa0-vU%2Bm2dkY2pTciUDLGd0Qut=uhFTq@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Em 2010.08.18. 22:48, mdf@FreeBSD.org escreveu: > On Wed, Aug 18, 2010 at 10:40 AM, Gabor Kovesdan<gabor@freebsd.org> wrote: >> Author: gabor >> Date: Wed Aug 18 17:40:10 2010 >> New Revision: 211463 >> URL: http://svn.freebsd.org/changeset/base/211463 >> >> Log: >> - Refactor file reading code to use pure syscalls and an internal buffer >> instead of stdio. This gives BSD grep a very big performance boost, >> its speed is now almost comparable to GNU grep. > I didn't read all of the details in the profiling mails in the thread, > but does this mean that work on stdio would give a performance boost > to many apps? Or is there something specific about how grep(1) is > using its input that makes it a horse of a different color? In stdio, there is some overhead of FILE * locking but in first phase we reduced that overhead by locking once after opening and releasing the lock once before closing (it's fine given that grep isn't threaded). In the previous code, grep read data by character (calling fgetc_unlocked) and now it reads in bigger chunks, this is another difference, which may have improved the performance. We haven't checked using stdio in chunks, because dealing directly with file descriptors made it easier to handle gzip/bzip2 files, so after having seen that the old solution was wrong, this idea came directly. So I cannot surely answer the question. It would be an interesting task to run a benchmark on this, though. Gabor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C6C4A67.4000002>