4 ms·
'why GNU grep is fast' from the FreeBSD mailing list: http://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html http://lists.freebsd.org/piperm
by martinp 14y ago
'why GNU grep is fast' from the FreeBSD mailing list: http://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html http://lists.freebsd.org/pipermail/freebsd-current/2010-Augu...
- georgebashi 14y agoWhich was discussed previously on HN, here: http://news.ycombinator.com/item?id=1626305 http://news.ycombinator.com/item?id=1626305
- chanux 14y agoAlso relevant: The Treacherous Optimization http://ridiculousfish.com/blog/posts/old-age-and-treachery.html http://ridiculousfish.com/blog/posts/old-age-and-treachery.h...
- haberman 14y agoAlso classic: http://ridiculousfish.com/blog/posts/old-age-and-treachery.html http://ridiculousfish.com/blog/posts/old-age-and-treachery.h...
- Mordor 14y ago> The key to making programs fast is to make them do practically nothing.
- deleted 14y ago[deleted]
- achille 14y agoI just replicated the test and I can confirm the FreeBSD grep compiled on Darwin is about 30x slower. % /usr/local/bin/grep --version /usr/local/bin/grep (GNU grep) 2.14 <snip> % time find . -type f | xargs /usr/local/bin/grep 83ba find . -type f 0.01s user 0.06s system 8% cpu 0.870 total xargs /usr/local/bin/grep 83ba 0.66s user 0.31s system 95% cpu 1.017 total % /usr/bin/grep --version grep (BSD grep) 2.5.1-FreeBSD % time find . -type f | xargs /usr/bin/grep 83ba find . -type f 0.01s user 0.06s system 0% cpu 28.434 total xargs /usr/bin/grep 83ba 31.65s user 0.40s system 99% cpu 32.113 total
- jasomill 14y agoThere was also some discussion about this on one of the Apple mailing lists a few months ago, and it turns out there are major differences in how the two grep implementations on OS X interact with the buffer cache. In particular, empirical evidence suggests 10.6's GNU grep build caches its input, while 10.7+ BSD grep does not. Incidentally, on OS X, you can commonly get another order of magnitude improvement over even GNU grep with Spotlight's index: use xargs to grep only through files that pass a looser mdfind "pre-screen".