On Fri, 2007-12-14 at 15:07 +0100, Florian Festi wrote:
> James Antill wrote:
> >  Where did the number 10 come from? That seems like a small number of
> > packages to have prco info. for.
> It is the number of packages we have PRCOs in memory. I choose 10 because it 
>   doesn't hurt my test cases. May be we need to increase the number if we 
> run into problem with some cases that are out of my attention right now.
> 
> >  Also it seems weird to have the LRU cache over each of prco as though
> > they are different. It also seems like if we are trying to save memory
> > (esp. for large transactions), then the obvious change is to have
> > packages share prco data (Eg. zlib requires is a subset of glib
> > requires, and I bet that's very common).
> 
> This sounds very expensive as you need to match the prco against each other. 
> The current solution just loads them and discards them if the pkg is ok. Be 
> aware that searching is done in the sqlite and we need the Prcos only when 
> looping over them in Depsolve.check*().

 I meant something like the attached, tested and seems to share a
significant amount of prco data even for "small" updates.

-- 
James Antill <[EMAIL PROTECTED]>
Red Hat
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 0c612fd..6f7ddf8 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -46,6 +46,7 @@ def catchSqliteException(func):
     newFunc.__dict__.update(func.__dict__)
     return newFunc
 
+_reverse_prco = {} # So pacakges can share prco data
 class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
     def __init__(self, repo, db_obj):
         self._checksums = []
@@ -208,9 +209,15 @@ class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
             executeSQL(cur, query)
             self.prco[prcotype] = [ ]
             for ob in cur:
-                self.prco[prcotype].append((ob['name'], ob['flags'],
-                                           (ob['epoch'], ob['version'], 
-                                            ob['release'])))
+                prco_set = (ob['name'], ob['flags'], 
+                            (ob['epoch'], ob['version'], ob['release']))
+                # This saves memory by merging the prco data from multiple
+                # packages. Note that flags etc. need to be the same too.
+                if prco_set in _reverse_prco:
+                    prco_set = _reverse_prco[prco_set]
+                else:
+                    _reverse_prco[prco_set] = prco_set
+                self.prco[prcotype].append(prco_set)
 
         return RpmBase.returnPrco(self, prcotype, printable)
 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to