Re: code cleanup

From: Bruce Evans <bde_at_zeta.org.au>
Date: Fri, 30 Apr 2004 23:28:09 +1000 (EST)
On Thu, 29 Apr 2004, Kris Kennaway wrote:

> On Thu, Apr 29, 2004 at 04:56:02PM -0400, John Baldwin wrote:
> > On Thursday 29 April 2004 02:55 pm, Brian Fundakowski Feldman wrote:
> > > For what it's worth, I don't think it is good to hide things as much as
> > > FOREACH_PROC_IN_SYSTEM() -- this specific instance -- does, but grep is not
> > > a good tool for a tree as large as FreeBSD's.  Try using cscope instead.
> >
> > I've used glimpse in the past but it is buggy.  Actually, grep -r on ssc/sys
> > doesn't take that long, esp. if you do it multiple times as most of the tree
> > is still in cache for subsequent grep's (at least on my laptop).  I also tend
> > to have lots (around 7 or so) trees that have work going on in them at any
> > one time.
>
> The problem with grep -r in src/sys is that it chokes on the symlinks
> created by module builds and pollutes the output with hundreds of
> lines of errors unless you remember to first remove the module build
> files.

Use find(1) to not follow symlinks.  E.g.:

%%%
Script started on Fri Apr 30 23:15:17 2004
ttyp0:bde_at_besplex:/tmp> cd /sys
ttyp0:bde_at_besplex:/sys> time find . -type f | time xargs grep fooo
        0.42 real         0.01 user         0.06 sys
        0.49 real         0.11 user         0.29 sys
ttyp0:bde_at_besplex:/sys> exit

Script done on Fri Apr 30 23:15:33 2004
%%%

This was fast because /sys was already in the disk cache.  It would have
taken 15 seconds with a cold cache.

I also have:

lrwxrwxrwx  1 bde  wheel  28 Mar  6 06:57 /sys/i386/compile_at_ -> /usr/obj/usr/src/sys/compile

(see Makefile.i386 rev.1.28)

so I don't have any object files under /sys to slow down the search,
except grep -r would follow this symlink too.

Perhaps it is a bug for grep -r to follow symlinks by default, especially
since there is no way to change the default and whether symlinks are
followed is not mentioned in the man page.  diff -r has the same problem.

Bruce
Received on Fri Apr 30 2004 - 04:28:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:52 UTC