Bug 529233 - YumBase.bestPackagesFromList() very slow in yum versions 3.2.22 and 3.2.23
Summary: YumBase.bestPackagesFromList() very slow in yum versions 3.2.22 and 3.2.23
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: yum
Version: 5.4
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
: ---
Assignee: James Antill
QA Contact: Jan Hutař
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-10-15 15:56 UTC by Steve Rotolo
Modified: 2014-01-21 06:15 UTC (History)
2 users (show)

Fixed In Version: yum-3.2.22-23.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-03-30 08:30:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
python script to demostrate poor performance of YumBase.bestPackagesFromList() on RHEL (2.28 KB, text/plain)
2009-10-15 15:56 UTC, Steve Rotolo
no flags Details
python script to demostrate poor performance of YumBase.bestPackagesFromList() on Fedora (2.43 KB, text/plain)
2009-10-15 15:57 UTC, Steve Rotolo
no flags Details
F8 yum-3.2.20 results (874 bytes, text/plain)
2009-10-15 15:58 UTC, Steve Rotolo
no flags Details
F10 yum-3.2.21 results (1002 bytes, text/plain)
2009-10-15 15:59 UTC, Steve Rotolo
no flags Details
F10 yum-3.2.23 results (1002 bytes, text/plain)
2009-10-15 16:00 UTC, Steve Rotolo
no flags Details
RHEL 5.2 yum-3.2.8 results (2.25 KB, text/plain)
2009-10-15 16:02 UTC, Steve Rotolo
no flags Details
RHEL 5.4 yum-3.2.22 results (2.22 KB, text/plain)
2009-10-15 16:02 UTC, Steve Rotolo
no flags Details
F10 yum.conf (791 bytes, text/plain)
2009-10-15 19:06 UTC, Steve Rotolo
no flags Details
F10 fedora repo (1.06 KB, text/plain)
2009-10-15 19:07 UTC, Steve Rotolo
no flags Details
F10 updates repo (1.08 KB, text/plain)
2009-10-15 19:08 UTC, Steve Rotolo
no flags Details
New depsolve.py file ... put in /usr/lib/python2.4/site-packages/yum (49.28 KB, text/plain)
2009-10-15 19:43 UTC, James Antill
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2010:0254 0 normal SHIPPED_LIVE yum bug fix update 2010-03-29 12:46:52 UTC

Description Steve Rotolo 2009-10-15 15:56:16 UTC
Created attachment 364946 [details]
python script to demostrate poor performance of YumBase.bestPackagesFromList() on RHEL

An application using YumBase.bestPackagesFromList() shows significant performance degradation in yum versions greater or equal to version 3.2.22, compared to earlier versions.  A quick glance at the code shows the internal implementation changed radically in or around 3.2.22.

I will attach a small python program that demonstrates the problem on both RHEL 5.4 and Fedora 10.  It is useful for comparing results with earlier versions.

I will also attach the output of runs for the following:
   RHEL 5.2 yum 3.2.8    (good)
   RHEL 5.4 yum 3.2.22   (bad)
   FC8      yum 3.2.20   (good)
   F10      yum 3.2.21   (good)
   F10      yum 3.2.23   (bad)

Comment 1 Steve Rotolo 2009-10-15 15:57:07 UTC
Created attachment 364948 [details]
python script to demostrate poor performance of YumBase.bestPackagesFromList() on Fedora

Comment 2 Steve Rotolo 2009-10-15 15:58:27 UTC
Created attachment 364949 [details]
F8 yum-3.2.20 results

Comment 3 Steve Rotolo 2009-10-15 15:59:15 UTC
Created attachment 364950 [details]
F10 yum-3.2.21 results

Comment 4 Steve Rotolo 2009-10-15 16:00:01 UTC
Created attachment 364951 [details]
F10 yum-3.2.23 results

Comment 5 Steve Rotolo 2009-10-15 16:02:03 UTC
Created attachment 364952 [details]
RHEL 5.2 yum-3.2.8 results

Comment 6 Steve Rotolo 2009-10-15 16:02:34 UTC
Created attachment 364953 [details]
RHEL 5.4 yum-3.2.22 results

Comment 7 seth vidal 2009-10-15 16:10:03 UTC
and can you post the yum.conf and .repo files you're using for each of these cases? Just to be sure on a few things.

Comment 8 Steve Rotolo 2009-10-15 16:21:41 UTC
The attached program performs several calls to YumBase.bestPackagesFromList()
with lists of several versions of some package.  The function call is timed and
the result is displayed.  It is easy to diff output from different versions to
see changes in times.  For example:

$ diff yum-demo-F10-3.2.21.out yum-demo-F10-3.2.23.out
1c1
< Yum Version: 3.2.21
---
> Yum Version: 3.2.23
13c13
<     time: 0.000000
---
>     time: 0.360000
20c20
<     time: 0.000000
---
>     time: 0.920000

The times seem to indicate that the new impl of the function does not scale
well with the number of items in the input list.  The old version seemed to be
almost instantaneous.

Comment 9 Steve Rotolo 2009-10-15 16:26:31 UTC
(In reply to comment #7)
> and can you post the yum.conf and .repo files you're using for each of these
> cases? Just to be sure on a few things.  

Sure thing.  Working on it...

Comment 10 James Antill 2009-10-15 16:33:13 UTC
Is the test program representative of what you are doing?

It looks like you are using it as a really slow way of doing:

        packages = packagesNewestByNameArch(packages)

...compare_providers is used more for working out which package(s) that provide(s) "MTA" is/are the best to install.
 Note that on x86_64 it will return an .i?86 and .x86_64 package, so the assert it wrong.

 Also why do you have getAllPackageVersions() walking the entire list of pkgs?

Comment 11 James Antill 2009-10-15 16:35:44 UTC
It's also worth nothing that current HEAD (very close to the just released 3.2.25, and what is in F12 GA) gives me:

    versions: openssl-0.9.8k-1.fc11.i686, openssl-0.9.8k-1.fc11.i586, openssl-0.9.8k-5.fc11.i686, openssl-0.9.8k-1.fc11.x86_64, openssl-0.9.8k-5.fc11.i586, openssl-0.9.8k-5.fc11.x86_64

    best: openssl-0.9.8k-5.fc11.x86_64
    time: 0.000000

...after removing the assert. So this may be a bug we've already fixed.

Comment 12 James Antill 2009-10-15 16:37:24 UTC
 Can you see if this patch fixes it for you:

http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=b81f0b56a68fec5f4b33e28570f3613784e75a7d

Comment 14 Steve Rotolo 2009-10-15 17:47:56 UTC
(In reply to comment #10)
> Is the test program representative of what you are doing?
> 
No not really.  I tried to create a minimal test case that shows the problem.

> It looks like you are using it as a really slow way of doing:
> 
>         packages = packagesNewestByNameArch(packages)
> 
> ...compare_providers is used more for working out which package(s) that
> provide(s) "MTA" is/are the best to install.
>  Note that on x86_64 it will return an .i?86 and .x86_64 package, so the assert
> it wrong.
> 

Oh, interesting.  In the real app I am using pkgSack.getProvides() to get all providers of some dependency, and then using bestPackagesFromList() to find the best provider.  As in:

    for dep in some_package.returnPrco('requires'):
        providers = self.pkgSack.getProvides(*dep).keys()
        best_providers = self.bestPackagesFromList(providers)
        assert(len(best_providers) == 1)
        best_provider = best_providers[0]

Yeah, I guess I have to cope with multiple best providers.  But which is correct to use, bestPackagesFromList or packagesNewestByNameArch?  Or none of the above ;-)?

>  Also why do you have getAllPackageVersions() walking the entire list of pkgs?  

Hmm, yeah that is a bit cheesy.  I do have something like that in the real app but it's hasn't proven to be a performance problem.  Generally though, for what I am doing, I find it *much* faster to carry around lists of package names rather than a sack of package objects.  Occasionally I have to map the name back to an object to something with it but that's ok.

Comment 15 Steve Rotolo 2009-10-15 18:38:44 UTC
(In reply to comment #12)
>  Can you see if this patch fixes it for you:
> 
> http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=b81f0b56a68fec5f4b33e28570f3613784e75a7d  

Well I don't have an F12 system.  The latest version of yum I have is yum-3.2.23-3.fc10.noarch.  So I patched that and manually resolved the reject.  But it made no difference in the timing.

Comment 16 Steve Rotolo 2009-10-15 18:57:36 UTC
(In reply to comment #13)
> Dito.
> 
> http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=332fba3e9c92abe8b62dfce29c458d43087317bc  

This patch applied cleaner to my version.  The numbers are much better, but still not all 0, for example:

    versions: glibc-2.9-3.i386, glibc-2.9-3.i686, glibc-2.9-2.i686, glibc-2.9-2.i386

    best: glibc-2.9-3.i686
    time: 0.230000

    versions: openssl-0.9.8g-11.fc10.i386, openssl-0.9.8g-14.fc10.i686, openssl-0.9.8g-14.fc10.i386, openssl-0.9.8g-11.fc10.i686

    best: openssl-0.9.8g-14.fc10.i686
    time: 0.220000

Not bad though!

Comment 17 Steve Rotolo 2009-10-15 19:06:17 UTC
Created attachment 364977 [details]
F10 yum.conf

Comment 18 Steve Rotolo 2009-10-15 19:07:59 UTC
Created attachment 364978 [details]
F10 fedora repo

Comment 19 Steve Rotolo 2009-10-15 19:08:28 UTC
Created attachment 364979 [details]
F10 updates repo

Comment 20 James Antill 2009-10-15 19:41:19 UTC
I just checked on RHEL-5, and the results I get are:

** RHEL-5.4 == yum-3.2.22-20 ...

Package 'openssl':

    versions: openssl-0.9.8b-10.el5_2.1.i686, openssl-0.9.8b-8.3.el5.i386, openssl-0.9.8b-8.3.el5_0.2.i386, openssl-0.9.8e-7.el5.i686, openssl-0.9.8e-12.el5.i386, openssl-0.9.8b-10.el5_2.1.i386, openssl-0.9.8b-8.3.el5_0.2.i686, openssl-0.9.8b-8.3.el5.i686, openssl-0.9.8b-10.el5.i686, openssl-0.9.8e-7.el5.i386, openssl-0.9.8e-12.el5.i686, openssl-0.9.8b-10.el5.i386
JDBG: 1 [<YumAvailablePackageSqlite : openssl-0.9.8e-12.el5.i686 (0x92723ac)>]

    best: openssl-0.9.8e-12.el5.i686
    time: 0.870000

** Latest upstream (basically yum-3.2.25) ...

Package 'openssl':

    versions: openssl-0.9.8b-10.el5_2.1.i686, openssl-0.9.8b-8.3.el5.i386, openssl-0.9.8b-8.3.el5_0.2.i386, openssl-0.9.8e-7.el5.i686, openssl-0.9.8e-12.el5.i386, openssl-0.9.8b-10.el5_2.1.i386, openssl-0.9.8b-8.3.el5_0.2.i686, openssl-0.9.8b-8.3.el5.i686, openssl-0.9.8b-10.el5.i686, openssl-0.9.8e-7.el5.i386, openssl-0.9.8e-12.el5.i686, openssl-0.9.8b-10.el5.i386
JDBG: 1 [<YumAvailablePackageSqlite : openssl-0.9.8e-12.el5.i686 (0x9747e0c)>]

    best: openssl-0.9.8e-12.el5.i686
    time: 0.020000

** RHEL-5.4 == yum-3.2.22-20 + the two patches ...

Package 'openssl':

    versions: openssl-0.9.8b-10.el5_2.1.i686, openssl-0.9.8b-8.3.el5.i386, openssl-0.9.8b-8.3.el5_0.2.i386, openssl-0.9.8e-7.el5.i686, openssl-0.9.8e-12.el5.i386, openssl-0.9.8b-10.el5_2.1.i386, openssl-0.9.8b-8.3.el5_0.2.i686, openssl-0.9.8b-8.3.el5.i686, openssl-0.9.8b-10.el5.i686, openssl-0.9.8e-7.el5.i386, openssl-0.9.8e-12.el5.i686, openssl-0.9.8b-10.el5.i386
JDBG: 1 [<YumAvailablePackageSqlite : openssl-0.9.8e-12.el5.i686 (0xa42022c)>]

    best: openssl-0.9.8e-12.el5.i686
    time: 0.010000

Comment 21 James Antill 2009-10-15 19:43:08 UTC
Created attachment 364982 [details]
New depsolve.py file ... put in /usr/lib/python2.4/site-packages/yum

 Here is the depsolve.py with all the patches applied to compare_provides, can you double check this?

Comment 22 James Antill 2009-10-15 19:45:26 UTC
 Oh, and...

        providers = self.pkgSack.getProvides(*dep).keys()
        best_providers = self.bestPackagesFromList(providers)

...that's fine, that's pretty much exactly what yum does when you do "yum install MTA".

Comment 23 Steve Rotolo 2009-10-15 20:33:02 UTC
(In reply to comment #22)
>  Oh, and...
> 
>         providers = self.pkgSack.getProvides(*dep).keys()
>         best_providers = self.bestPackagesFromList(providers)
> 
> ...that's fine, that's pretty much exactly what yum does when you do "yum
> install MTA".  

Thanks!  Sorry but what is "MTA"?  I'm trying the new depsolve.py now...

Comment 24 Steve Rotolo 2009-10-15 20:52:30 UTC
(In reply to comment #21)
> Created an attachment (id=364982) [details]
> New depsolve.py file ... put in /usr/lib/python2.4/site-packages/yum
> 
>  Here is the depsolve.py with all the patches applied to compare_provides, can
> you double check this?  

Awesome!  I plunked this down on RHEL 5.4 and it works great.  So should I expect an official update for this on RHEL 5.4 (eventually)?

Comment 25 James Antill 2009-10-16 02:31:50 UTC
I'll propose it for RHEL-5.5, but I can't guarantee anything yet ... obviously if you have a support contact then a push from a paying customer always helps :).

Comment 27 Jan Hutař 2009-12-15 10:21:11 UTC
(In reply to comment #23)
> Thanks!  Sorry but what is "MTA"?  I'm trying the new depsolve.py now...  

MTA is Mail Transport Agent. I guess it is one of these fake provides:

# yum whatprovides MTA
[...]
sendmail-8.14.3-3.fc10.x86_64 : A widely used Mail Transport Agent (MTA)
[...]
2:postfix-2.5.6-1.fc10.x86_64 : Postfix Mail Transport Agent
[...]

Comment 31 errata-xmlrpc 2010-03-30 08:30:07 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0254.html


Note You need to log in before you can comment on or make changes to this bug.