From: Alan McKinnon <alan.mckinnon@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Finding orphaned libs
Date: Tue, 9 Jun 2009 17:30:58 +0200 [thread overview]
Message-ID: <200906091730.58440.alan.mckinnon@gmail.com> (raw)
In-Reply-To: <200906091720.49610.shrdlu@unlimitedmail.org>
On Tuesday 09 June 2009 17:20:49 Etaoin Shrdlu wrote:
> On Tuesday 9 June 2009, 16:36, Neil Bothwick wrote:
> > On Tue, 09 Jun 2009 16:15:21 +0200, Joerg Schilling wrote:
> > > > find -H /usr/lib /lib -type f | xargs -d'\n' qfile --orphans
> > >
> > > No, this is definitely wrong: the right way to handle this is
> > > execplus (since 19 years).
> >
> > If it's been around 19 years, why doesn't Google know anything about
> > it? What is it?
>
> Well, google does not know everything :)
>
> Basically, using + instead of ; after -exec allows to run the specified
> command less times, each time with the highest possible number of
> arguments (instead of running it once per file, which is what happens
> with ;). And yes, that's been in POSIX for a long time now. Example:
>
>
> $ ls
> file1 file2 file3 file4 file5
>
> $ find . -type f -exec sh -c 'echo "number of arguments: $#"' sh {} \;
> number of arguments: 1
> number of arguments: 1
> number of arguments: 1
> number of arguments: 1
> number of arguments: 1
>
> $ find . -type f -exec sh -c 'echo "number of arguments: $#"' sh {} +
> number of arguments: 5
>
> So when you have to run a command on a very big number of files, say 1000
> or more, with ; you spawn 1000 processes, with + you span just one or
> two (well, depending on the maximum command line length on the system
> anyway). This is of course much less resource intensive.
Some numbers.
These are from memory, I ran these commands today while preparing a machine
for an installation of a package. The directory tree at the starting point had
about 5000 files, more than 80% with a UID not attached to an account:
chown -R <user>:<group> *
about 2 seconds
find . -nouser -o -nogroup -exec chown <user>:<group> {} +
about 30 seconds (wild guess)
find . -nouser -o -nogroup -exec chown <user>:<group> {} \;
I killed this one after 5 minutes and it was nowhere near complete
Admittedly, this was on a vmware guest with a rather poor disk configuration,
but it does illustrate that the naive "find \;" performs extremely poorly.
chown on it's own is foolish as the whole point of the exercise was to find
files meeting certain criteria, and there was definitely some that didn't.
execplus is a fine middle ground giving the best possible bang for buck.
--
alan dot mckinnon at gmail dot com
next prev parent reply other threads:[~2009-06-09 15:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 20:44 [gentoo-user] Finding orphaned libs Alan McKinnon
2009-06-08 20:54 ` Neil Bothwick
2009-06-08 22:10 ` Alan McKinnon
2009-06-08 22:57 ` Dale
2009-06-08 23:31 ` Willie Wong
2009-06-09 10:05 ` Joerg Schilling
2009-06-09 10:54 ` Neil Bothwick
2009-06-08 23:52 ` Dale
2009-06-09 0:18 ` Willie Wong
2009-06-09 0:27 ` Dale
2009-06-09 7:03 ` Alan McKinnon
2009-06-09 13:01 ` Mike Kazantsev
2009-06-10 7:53 ` Dale
2009-06-10 8:37 ` Mike Kazantsev
2009-06-09 13:33 ` Volker Armin Hemmann
2009-06-09 13:48 ` Joerg Schilling
2009-06-09 14:04 ` Volker Armin Hemmann
2009-06-09 14:34 ` Neil Bothwick
2009-06-09 14:51 ` Joerg Schilling
2009-06-09 14:08 ` Mickaël Bucas
2009-06-09 14:15 ` Joerg Schilling
2009-06-09 14:36 ` Neil Bothwick
2009-06-09 14:42 ` Paul Hartman
2009-06-09 14:52 ` Neil Bothwick
2009-06-09 14:59 ` Joerg Schilling
2009-06-09 15:29 ` Neil Bothwick
2009-06-09 15:21 ` Etaoin Shrdlu
2009-06-09 15:28 ` Neil Bothwick
2009-06-09 15:20 ` Etaoin Shrdlu
2009-06-09 15:30 ` Alan McKinnon [this message]
2009-06-09 14:39 ` Mickaël Bucas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200906091730.58440.alan.mckinnon@gmail.com \
--to=alan.mckinnon@gmail.com \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox