grep extremely slow

Rich Felker dalias at aerifal.cx
Sat Apr 8 03:22:14 UTC 2006


On Fri, Apr 07, 2006 at 08:56:14PM -0500, Rob Landley wrote:
> On Friday 07 April 2006 3:24 am, Rich Felker wrote:
> > I've observed that busybox grep is still 20x slower than gnu grep,
> > even with the regcomp issue I reported a while back fixed. The problem
> > seems to be the bb_get_chunk_from_file function, which reads a single
> > character at a time from the file using getc. Not sure what's the best
> > way to fix it without breaking semantics needed by other applets..
> > anyone care to take a look?
> 
> In theory this getc should be using fopen() with a FILE *, and thus copying a 
> character at a time from a buffer rather than doing a syscall each time.

Of course it gets it from a buffer, but that doesn't make it fast.

> The problem is we don't want to read more data then we end up using, because 
> there's no guarantee our input is seekable.

That's the whole purpose of fgets...

Rich




More information about the busybox mailing list