258 Commits

Author SHA1 Message Date
Alexey Tourbin
2d3c3cef27 removed ancient dependency loop whiteout mechanism (rpm.org) 2011-01-23 02:30:59 +03:00
Alexey Tourbin
42b139d1eb removed --fileid query selector and Filemd5s rpmdb index (rpm.org) 2011-01-22 17:35:13 +03:00
Alexey Tourbin
fad9df878b set.c: tweak LRU first-time insertion policy
Pushing new elements to the front tends to assign extra weight to that
elements, at the expense of other elements that are already in the cache.
The idea is then to try first-time insertion somewhere in the middle.
Further attempts suggest that the "pivot" should be closer to the end.

Cache performance for "apt-shell <<<unmet", previous commit:
hit=62375 miss=17252

Cache performance for "apt-shell <<<unmet", this commit:
hit=65085 miss=14542
2011-01-07 06:45:38 +03:00
Alexey Tourbin
add6349fea system.h: moved AUTO_REALLOC from depends.h 2011-01-06 03:26:09 +03:00
Alexey Tourbin
523b00db6e depends.c (rpmRangesOverlap): avoid extra strcmp calls 2011-01-06 03:24:14 +03:00
Alexey Tourbin
cf36274cb9 header.h: shut up -Wextra warning
header.h: In function 'headerFreeData':
header.h:705:11: error: comparison between signed and unsigned integer expressions
2011-01-03 09:52:38 +03:00
Alexey Tourbin
42db4e0a9d set.c: final touches 2011-01-03 09:24:15 +03:00
Alexey Tourbin
73adeec07e set.c: cache short deltas
After base62+golomb decoding, most deltas are under 65536 (in Provides
versions, average delta should be around 1536).  So the whole version
can be stored using short deltas, effectively halving memory footprint.
However, this seems to be somewhat slower: per-delta copying and
decode_golomb must be invoked to recover hash values.  On the other
hand, this allows to increase cache size (128 -> 192).  But note that,
with larger cache sizes, LRU linear search will take longer.  So this is
a compromise - and apparently a favourable one.
2011-01-03 09:04:50 +03:00
Alexey Tourbin
b674d2bc31 set.c: tweak delta routines and maskv 2011-01-03 08:21:13 +03:00
Alexey Tourbin
ebe77a46cd set.c: avoid extra strcmp calls in the caching code 2011-01-03 08:21:12 +03:00
Alexey Tourbin
46f3968205 set.c: optimize array access in rpmsetcmp
callgrind results for "apt-cache unmet", 4.0.4-alt100.6:
2,198,298,537  PROGRAM TOTALS
1,115,738,267  lib/set.c:decode_set
  484,035,006  lib/set.c:rpmsetcmp
  143,078,002  ???:strcmp
   79,477,321  ???:strlen
   61,780,572  ???:0x0000000000033080'2
   54,466,947  ???:memcpy
   31,161,399  ???:strcpy
   24,438,336  ???:pkgCache::DepIterator::AllTargets()

callgrind results for "apt-cache unmet", this commit:
1,755,431,664  PROGRAM TOTALS
764,189,271  lib/set.c:decode_base62_golomb
404,493,494  lib/set.c:rpmsetcmp
143,076,968  ???:strcmp
 70,833,953  ???:strlen
 61,780,572  ???:0x0000000000033080'2
 54,466,947  ???:memcpy
 31,161,399  ???:strcpy
 24,438,336  ???:pkgCache::DepIterator::AllTargets()
2011-01-03 08:21:10 +03:00
Alexey Tourbin
d1ad36aef1 set.c: implemented combined base62+golomb decoding routine 2011-01-03 08:20:55 +03:00
Alexey Tourbin
bb21779d02 set.c: facilitate base62 decoding with table lookup 2011-01-03 02:06:07 +03:00
Alexey Tourbin
61866ee15a set.c: minor base62 tweaks 2011-01-03 02:05:11 +03:00
Alexey Tourbin
a2f26af268 set.c: reverted Kirill's changes 2011-01-02 06:39:32 +03:00
Kirill A. Shutemov
4b05315a84 set.c: optimize decode_golomb()
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
4d9409cb9c set.c: optimize putbits()
Use bit operations instead of cycles.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
6a9ce451bc set.c: use packed bitmap for bit vector
Currently, set.c uses array of chars to store bit vector. Each char
stores one bit: 0 or 1.

Let's use packed bitmap instead. It creates room for optimizations.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
6afa2793f8 set.c: cleanup self-tests
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
82a064020b set.c: use function-like syntax for sizeof.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
d7ece41758 set.c: do not mix declarations and code
Let's move variable declarations to the begin of blocks.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:58:43 +00:00
Kirill A. Shutemov
82da3b0f49 set.c: slightly reformat code to increase its readability
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:57:43 +00:00
Kirill A. Shutemov
5c39279236 set.c: fixup self-test functions declaration
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:56:19 +00:00
Kirill A. Shutemov
4226027fbb set.c: get rid of nested functions
Nested function in C is GCC extension.
Let's try to follow ANSI C syntax.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:56:19 +00:00
Kirill A. Shutemov
75a4506d75 set.c, set.h: get rid of C++-style comments
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2010-12-07 16:56:19 +00:00
c7167f0395 lib/depends.c (rpmRangesOverlap): optimize out unneeded calls to printDepend()
This optimization speeds up rpmRangesOverlap() by 10%.
2010-12-04 17:30:16 +00:00
Alexey Tourbin
fc5b5a5f7d set.c: implemented LRU caching (2x speed-up, 1M footprint) 2010-12-04 13:11:45 +03:00
7c35077bf5 Link librpm with libbeecrypt 2010-10-20 09:04:43 +00:00
Alexey Tourbin
2463074998 set.c: corrected set_free() return type 2010-10-12 03:14:10 +04:00
Alexey Tourbin
50a7eb6602 set.c: minor fixes, no changes 2010-09-19 09:56:00 +04:00
Alexey Tourbin
ca83cfb381 set.c (rpmsetcmp): set2 err fix 2010-09-13 18:54:45 +04:00
Alexey Tourbin
9fabff6e7a rpmlibprov.c: added rpmlib(SetVersions) feature 2010-09-11 01:58:23 +04:00
Alexey Tourbin
3e9adcff64 depends.c (rpmRangesOverlap): added support for set-versions 2010-09-11 01:58:13 +04:00
Alexey Tourbin
a6d2902271 set.c: implemented base62, golomb, and set-string routines 2010-09-11 01:34:05 +04:00
Mikhail Efremov
f92be4b40e Added SELinux support
Mostly backported from rpm-4.8
2010-08-24 16:59:07 +00:00
Alexey Tourbin
0e2e506379 depends.c: do not check installed Conflicts against addedPackages names
In build.c:checkSpec(), build dependencies are checked by creating
a transaction, adding source header to the transaction and then running
rpmdepCheck().  Source headers have only BuildRequies and BuildConflicts
types of dependencies (no regular Requires and Conflicts).  Also, source
packages have no Provides, but they have NAMES.  When a self-conflicting
package is installed, its self conflict will be triggered by the source
package name.

To fix the problem, note that binary packages explicitly provide
their N=EVR among Provides; and source packages provides nothing,
even the name.  So the solution is as simple as not to check
the dependencies against package names.

Update: also, do not check installed Requires against erasedPackages names.
2010-08-22 03:20:50 +04:00
Alexey Tourbin
6684fd8ee5 verify.c: updated verifyDependencies() for self-conflicting packages
To check the dependencies of an installed package, a "transaction" is
created, and the package is added to the transaction.  The transaction
is then checked with rpmdepCheck().  However, since the installed
package has not been marked for removal, a conflict can be triggered
between the installed and that of transaction copies of the package.
The right thing to do is to mark package for removal, re-add it to
the transaction, and then to check the dependencies.
2010-08-22 02:30:13 +04:00
Alexey Tourbin
de60ab01a3 header.c: backported headerSetInstance() and headerGetInstance() from rpm.org
Header instance is its number in /var/lib/rpm/Packages database.
When a header comes from the database, it is sometimes useful to know
its instance (I need this to adjust verify.c:verifyDependencies() for
self-conflicting packages).  On the contrary, setting instance numbers
should happen only within librpmdb, which is why headerSetInstance()
comes with hidden visibility.
2010-08-22 02:16:02 +04:00
Alexey Tourbin
e8c5b7ad21 depends.c: permit self-conflicting packages
Only for the last two weeks or so, the issues has been raised twice.
By specifying "Provides: foo, Conflicts: foo", people expect that
other packages which provide "foo" will not be installed along with
the package.  What people don't anticipate is that the package will
conflict with itself, and will not be installed at all.  This is where
apt and rpm differ.  In apt, "conflicts may never self match".  In rpm,
Requires and Conflicts are handled in exactly the same way, except that
Requires should match, and Conflicts should not match (I call this
a symmetry).  Both can match against the package they come from.

So, to permit self-conflicting packages, I have to break the symmetry
and pass additional argument which indicates the type of dependency
being processed (either Requires or Conflicts).  The code is then
adjusted to discard self-matching Conflicts.

Obsoletes should be handled specially, too.  In tsSatisfiesDepend(),
I attempt to handle the Obsoletes case as well.  It is rather
unfortunate that, in rpmdepCheck(), Obsoletes are simply not checked
just yet.
2010-08-22 01:04:41 +04:00
Alexey Tourbin
682646a657 depends.c: made dbProvCache global (static __thread)
Passing this "implicit" argument from a toplevel API function
down to dbSatisfiesDepends() looks too ugly.
2010-08-19 00:37:23 +04:00
Alexey Tourbin
adce826c53 depends.c: better solution for dbProvCache dangling pointers without resorting to strdup 2010-08-18 14:28:08 +04:00
Alexey Tourbin
da0408ae20 Revert "depends.c (dbSatisfiesDepend): strdup dbProvCache keys (ALT#23811)"
This reverts commit c9b1f0e2ec156048afb40bb6deaaa0ed6a2a8f89.
2010-08-18 11:56:59 +04:00
Kirill A. Shutemov
0ed9eed845 Migrate to new libbeecrypt
Let's try to use recent libbeectypt in our World Best RPM.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2010-08-12 20:41:06 +00:00
Alexey Tourbin
c9b1f0e2ec depends.c (dbSatisfiesDepend): strdup dbProvCache keys (ALT#23811)
My previous assumption that strdup() was not needed for dbProvCache keys
was wrong.  The keys point to header memory, which is right.  However,
those are not only ts->addedPackages and ts->erasedPackages headers.
In checkDependent(), headers come from rpmdb and are disposed immediately
after the check.
2010-08-05 18:27:02 +04:00
Alexey Tourbin
b08133537b al.c: lazy creation of al->dirIndex and al->provIndex
For erasedPackages, the dirIndex and provIndex are unused, and
thus should not be created at all.  There is arguably a better
option - to provide explicit alMakeIndex and alFreeIndex API.
2010-07-12 11:39:28 +04:00
Alexey Tourbin
7a1f3ed06d depends.c: provided actual dbProvCache implementation
Based on rpm.org 2e76d0e6 by Panu Matilainen:
> Add in-memory hash for caching rpmdb dependency lookups
> - worst case behavior for uncached dependency lookups can be disastrous,
>   eg > 35s vs < 1s on my laptop for trying to remove /bin/sh provider
> - we only bother caching rpmdb lookups, the other cases plenty fast already
> - using in-memory cache avoids nasty in vs out of chroot issues with
>   temporary db files, which otherwise were about as fast

However, we do not use full-blown printDepend-based caching (i.e.
we no longer cache depends with versions).  This is because, well,
dependency versions are likely to differ.  This is especially true
if we consider upcoming set-versions for soname symbols - hashing
symbol sets here will be just a waste of time and memory.  And so
now we cache satisfied/unsatisfied depends by just name.  Thus,
"yes" hit can be used immediately only for unversioned dependences.

Top 10 dependencies which will be handled by the cache:
$ rpm -qaR |grep -v rpmlib |grep -v = |sort |uniq -c |sort -n |tail
    245 /usr/lib/perl5/vendor_perl
    311 libm.so.6(GLIBC_2.2.5)(64bit)
    386 libpthread.so.0(GLIBC_2.2.5)(64bit)
    454 /lib64/ld-linux-x86-64.so.2
    548 libc.so.6(GLIBC_2.3)(64bit)
    587 /bin/sh
    828 libc.so.6(GLIBC_2.3.4)(64bit)
    906 libc.so.6(GLIBC_2.4)(64bit)
   1128 rtld(GNU_HASH)
   1140 libc.so.6(GLIBC_2.2.5)(64bit)
$

Top 10 dependencies which will not be handled by the cache:
$ rpm -qaR |grep -v rpmlib |grep -e = |sort |uniq -c |sort -n |tail
     13 python-base = 2.6.5-alt2
     14 mono(mscorlib) = 1.0
     15 qt4-common = 4.6.2-alt6
     16 mono(mscorlib) = 2.0
     18 mktemp >= 1:1.3.1
     20 koffice-common = 4:2.2.0-alt2
     20 perl-base >= 1:5.8.0
     23 alternatives >= 0:0.4
     49 libqt4-core >= 4.6.2
     54 perl-base >= 1:5.6.0
$

Here's a simple test to see if the cache works (using Panu's example -
trying to remove /bin/sh).

(before this change)
$ time LD_LIBRARY_PATH=$PWD/1 rpm -e --test sh 2>&1 |tail
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by libgnome-sharp-2.24.1-alt1
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kde4libs-4.4.5-alt1
        /bin/sh   is needed by kde4base-runtime-core-4.4.5-alt1
        /bin/sh   is needed by kde4base-konqueror-4.4.5-alt1
        /usr/lib/bash is needed by bash-builtin-lockf-0.3.1-alt1
rpm -e --test sh 2>&1  6.18s user 3.44s system 94% cpu 10.182 total
$

(after this change)
$ time LD_LIBRARY_PATH=$PWD/2 rpm -e --test sh 2>&1 |tail
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by groff-base-1.20.1-alt0.20091013
        /bin/sh   is needed by libgnome-sharp-2.24.1-alt1
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kernel-image-std-def-2.6.32-alt15
        /bin/sh   is needed by kde4libs-4.4.5-alt1
        /bin/sh   is needed by kde4base-runtime-core-4.4.5-alt1
        /bin/sh   is needed by kde4base-konqueror-4.4.5-alt1
        /usr/lib/bash is needed by bash-builtin-lockf-0.3.1-alt1
rpm -e --test sh 2>&1  0.11s user 0.09s system 91% cpu 0.218 total
$
2010-07-12 11:39:27 +04:00
Alexey Tourbin
d35a165dc3 depends.c: pass dbProvCache parameter down to dbSatisfiesDepend
This is a bit ugly but this is probably still a bit better than
extending the ts structure.
2010-07-12 11:39:26 +04:00
Alexey Tourbin
945417c34f depends.c: updated for ts->erasedPackages 2010-07-12 11:39:25 +04:00
Alexey Tourbin
17a1de0d63 transaction.c: updated for ts->erasedPackages 2010-07-12 11:39:24 +04:00
Alexey Tourbin
d392376ed7 depends.c: added initial support for ts->erasedPackages list
Before this change, only rpm headers for addedPackages were loaded
during transaction; for removedPackages, we only stored the list
of rpmdb header numbers (numeric instances).  With this change,
removedPackages' headers are getting loaded, too (the list is called
erasedPackages).  The reason is that, when a header is loaded,
it is possible to use pointers to point e.g. into header strings
without using strdup.  This might come useful as we try to reimplement
the depends cache.
2010-07-12 11:37:40 +04:00