[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why does not rgrep use "grep -r"?
From: |
Stefan Monnier |
Subject: |
Re: Why does not rgrep use "grep -r"? |
Date: |
Sat, 03 Nov 2007 10:01:27 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) |
>> If grep can do recursive searches then why not use that in rgrep?
> I don't know the reason of the rgrep authors (though I suspect it was
> portability concerns), but I have noticed something odd about "grep -r":
> -- sometimes it seems _much_ slower than "find ... -type f | xargs grep"
> on very large trees (I think I noticed with trees in NFS, where speed is
> a perennial issue). Dunno why this...
I don't know why that is, but the difference may come from diferences in
the way the tree is traversed. There are many tricks that one can try
to use to speed up tree traversal and unless both commands share their
tree-traversal code, it's likely that find's tree traversal has been
better optimized.
Some of the tricks that can be used:
- A dir without subdirs has a refcount of 2 (one ref from the parent,
one from its "." entry). If you know a dir has no subdirs you can
avoid calling `stat' on each file to determine whether it's a subdir
or not.
- some filesystems can provide the "dir/notdir" info without going
through `stat', but that requires the use of a separate syscall.
- assuming the inodes numbers are related to the position of the inode
on the drive (which is not the case for log-structured filesystems but
is the case for many others) you can reorder your traversal to try and
produce a more sequential scan of your disk.
- if the OS&filesystem gives you access to disk-block-numbers instead of only
inode numbers, you can use that to do the above.
- ...
Stefan
- Re: Why does not rgrep use "grep -r"?, (continued)
- Re: Why does not rgrep use "grep -r"?, Miles Bader, 2007/11/02
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, David Kastrup, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Lennart Borgman (gmail), 2007/11/03
- Re: Why does not rgrep use "grep -r"?, David Kastrup, 2007/11/04
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/05
- Re: Why does not rgrep use "grep -r"?, Ken Raeburn, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/03
Re: Why does not rgrep use "grep -r"?,
Stefan Monnier <=
Re: Why does not rgrep use "grep -r"?, Kim F. Storm, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Lennart Borgman (gmail), 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Miles Bader, 2007/11/03
- Re: Why does not rgrep use "grep -r"?, Jason Rumney, 2007/11/04
- Re: Why does not rgrep use "grep -r"?, Lennart Borgman (gmail), 2007/11/04
- Re: Why does not rgrep use "grep -r"?, Jason Rumney, 2007/11/04
- Re: Why does not rgrep use "grep -r"?, Lennart Borgman (gmail), 2007/11/04
- Re: Why does not rgrep use "grep -r"?, Eli Zaretskii, 2007/11/05