[Rpm-maint] How to get RPM requires quickly

Richard W.M. Jones rjones at redhat.com
Mon Sep 15 12:55:24 UTC 2014

On Mon, Sep 15, 2014 at 03:42:37PM +0300, Panu Matilainen wrote:
> On 09/13/2014 04:13 PM, Richard W.M. Jones wrote:
> >
> >We have a program[1] that needs to take a list of installed RPM
> >package names, and quickly generate all of the installed dependencies
> >(recursively).
> >
> >*Note* this is NOT a question about yum/dnf/zypper/etc depsolving.
> >It's about doing 'rpm -qR' quickly on installed packages only.
> >
> >At the moment we run the following command:
> >
> >   rpm -qR <current set of packages> |
> >     awk '{print $1}' |
> >     xargs rpm -q --qf '%%{name}\n' --whatprovides |
> >     grep -v 'no package provides' |
> >     sort -u
> >
> >The output is added to the current set, and we repeat the process
> >until the set of packages reaches a fixpoint.
> >
> >To give you an idea, on a typical starting set this takes around 20 seconds,
> >which is over half the total running time of the program.
> >
> >Does anyone have any suggestions about how to do this more quickly
> >and/or cleverly?  Maybe using rpmlib (which unfortunately seems to
> >lack any documentation)?
> That kind of usage is pretty much worst case behavior for rpm as it
> defies almost all caching etc.

I never claimed it was clever :-)

> For immediate speed gain with no
> other changes, add --nosignature to stop rpm from
> re-re-re-re-revalidating header signatures over and over again. In
> the average 'rpm -qa' time --nodigest doesn't help much but the
> cumulative effect might be worth it here.

That helps a bit.  Just adding --nosignature --nodigest to every
invocation of RPM has reduced the time from 20 seconds to 17 seconds.

I guess the next step is rpmlib ...



Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.

More information about the Rpm-maint mailing list