[Rpm-maint] [PATCH] rpmdbCountPackagesArch

Thomas Fitzsimmons fitzsim at redhat.com
Mon Jun 30 21:45:08 UTC 2008


Pixel wrote:
 > Thomas Fitzsimmons <fitzsim at redhat.com> writes:
 >
 >> I'm working on a way to pass per-architecture package counts to
 >> scriptlets [1].  Jeff Johnson suggested creating a new database index
 >> for this purpose [2].
 >>
 >> Attached are two patches against Fedora 9's rpm.  The first adds a
 >> Namearch index to the RPM database.  The second uses Namearch to
 >> implement a new rpmlib function, rpmdbCountPackagesArch.
 >
 > One question on this patch: is Namearch really worth it?

 > In the typical case, rpmtsRun() is already doing 2 iterations on
 > "Name" doing headerLoad. And there are a few more.
 >
 > IMO if we look at optimisations, there are many things that should be
 > done before this. For example, it would be far more effective to
 > introduce a "Packages-light" with only the more interesting piece of
 > information (EVRA and maybe a few more). This would make "rpm -qa"
 > much much more faster/lighter (I/O accesses on Packages are really
 > killing it).
 >
 > So i would say, implement rpmdbCountPackagesArch() using
 > rpmdbSetIteratorRE() for now.

I've attached tests that benchmark name-only lookups versus
rpmdbSetIteratorRE-based name-arch lookups.  On my Fedora 9 32-bit x86
machine:

$ /usr/bin/time ./count-packages
0.14user 0.00system 0:00.20elapsed 69%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+492minor)pagefaults 0swaps

$ /usr/bin/time ./count-packages-arch-nameindex
24.15user 0.08system 0:24.56elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1100minor)pagefaults 0swaps

So over many transactions, using rpmdbSetIteratorRE is much slower
than using the Namearch index.

 > As for "change $1 and $2 to be per-arch", i wonder if it won't break
 > some things in case of "shared files": the %preun|%postun will think
 > it is the last, whereas in fact the other arch package is still
 > installed and providing the files. Uh? (this is only wild guess since
 > i've no experience on this, since once again Mandriva is handling this
 > differently, without rpm help)

I'm in favour of maintaining the current $1 and $2 behaviour and
providing the extra information via either extra arguments or
environment variables.  Jeff Johnson suggested redefining the meaning
of the existing arguments [1], so I included that approach in the
option list for completeness.

Tom

1. https://lists.dulug.duke.edu/pipermail/rpm-devel/2007-February/002073.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: count-packages.c
Type: text/x-csrc
Size: 524 bytes
Desc: not available
Url : http://lists.rpm.org/pipermail/rpm-maint/attachments/20080630/564ffe19/attachment-0002.c 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: count-packages-arch-nameindex.c
Type: text/x-csrc
Size: 725 bytes
Desc: not available
Url : http://lists.rpm.org/pipermail/rpm-maint/attachments/20080630/564ffe19/attachment-0003.c 


More information about the Rpm-maint mailing list