[Yum-devel] self.pkgSack.delPackage()

Tim Lauridsen tla at rasmil.dk
Fri Jul 27 09:37:23 UTC 2007


seth vidal wrote:
> Hey,
>  I was putting together a plugin[1] for something jesse did when I
> noticed that the particular plugin was taking MINUTES to run. And
> considering how little the plugin does - that seemed silly.
>
> so after a little bit of notice - I looked at plugins.py
>
> in the delPackage() method in MainPluginConduit. It calls:
>         self._base.pkgSack.delPackage(po)
>
> b/c of all the functions we end up calling when we call delPackage() on
> the MetaSack  it takes very long (1-2 seconds per package)
>
> the way around this is to call the delPackage() routine per-sack,
> alternatively to call it like this:
>
> po.repo.sack.delPackage(po) (yes, that looks as silly to me, too)
>
> but it gets WAY faster when you do it that way. Anyway there are a
> couple of things we can do to fix this:
>
> 1. patch plugins.py to call the above when 'delPackage() is called. -
> this is easy, it doesn't break api and it kinda makes sense
> 2. add a method exclude() to YumAvailablePackage that will call
> self.repo.sack.delPackage(self) on itself. This seems like a good thing
> for later anyway - but we can't expect things to use this method right
> now.
> 3. patch all the plugins to step around this manually (ick)
>
> Anyone have a preference?
>
> I personally like 1 & 2.
>   
1, Make a lot of sense and it will make other excluding plugins faster to.
2, Make also a lot of sense, it will be logical, if the package object 
know how to exclude itself.

So i think that both 1 & 2, is the way to go.
> Alternatively, if there is something I've missed on why
> pkgSack.delPackage() takes so long - let me know.
>   
I have tried to track it down and i get a little confused, it look like 
the conduit.delPackges ends up calling

po.repo.sack.delPackage(po)

conduit.delPackage(po)
  -> self._base.pkgSack.delPackage(po) = MetaSack.delPackage 
(self._base.pkgSack = self._base._pkgSack = self._base.repos.pkgSack = 
MetaSack())
     -> po.repo.sack.delPackage(po) = YumSqlitePackageSack.delPackage 
(po.repo.sack = YumSqlitePackageSack() )
       ->  def delPackage(self, obj):
                if not self.excludes.has_key(obj.repo):
                   self.excludes[obj.repo] = {}
                self.excludes[obj.repo][obj.pkgId] = 1
                self.pkglist = None


I took a look a the change history for MetaSack, it look like it have be 
fixed a earlier this year.
http://devel.linux.duke.edu/gitweb/?p=yum.git;a=history;f=yum/packageSack.py;h=fce183f6a3450d0bb9f3627607cee5064eb0d20d;hb=HEAD

So now i totally confused, please enligthen me :)

Tim



More information about the Yum-devel mailing list