Optimize repoman to share portdbapi.cp_list() results
authorZac Medico <zmedico@gentoo.org>
Fri, 26 Oct 2007 18:06:07 +0000 (18:06 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 26 Oct 2007 18:06:07 +0000 (18:06 -0000)
between all profiles since those results never change.
The cached results also propagate to the xmatch
match-all when appropriate (old-style virtuals are
excluded since they are profile dependent).

svn path=/main/trunk/; revision=8313

bin/repoman
pym/portage/dbapi/porttree.py

index a57c30052808034dcd3e3823b478884aceac6329..fec17e1387f58dfbb5e043d793098635dcdf5985 100755 (executable)
@@ -810,6 +810,8 @@ if isCvs:
 dofail = 0
 arch_caches={}
 arch_xmatch_caches = {}
+shared_xmatch_caches = {"cp-list":{}}
+
 for x in scanlist:
        #ebuilds and digests added to cvs respectively.
        logging.info("checking package %s" % x)
@@ -1430,6 +1432,7 @@ for x in scanlist:
                                        portdb.melt()
                                        portdb.freeze()
                                        xcache = portdb.xcache
+                                       xcache.update(shared_xmatch_caches)
                                        arch_xmatch_caches[xmatch_cache_key] = xcache
 
                                trees["/"]["porttree"].settings = dep_settings
index f0cc49ac27c0ed227c37570cebbfa5a15e6b8ce2..4f9b1cbbe3a9dd030503db310d8657465a6e89dc 100644 (file)
@@ -494,10 +494,15 @@ class portdbapi(dbapi):
 
        def cp_list(self, mycp, use_cache=1, mytree=None):
                if self.frozen and mytree is None:
-                       mylist = self.xcache["match-all"].get(mycp)
-                       # cp_list() doesn't expand old-style virtuals
-                       if mylist and mylist[0].startswith(mycp):
-                               return mylist[:]
+                       cachelist = self.xcache["cp-list"].get(mycp)
+                       if cachelist is not None:
+                               # Try to propagate this to the match-all cache here for
+                               # repoman since he uses separate match-all caches for each
+                               # profile (due to old-style virtuals). Do not propagate
+                               # old-style virtuals since cp_list() doesn't expand them.
+                               if not (not cachelist and mycp.startswith("virtual/")):
+                                       self.xcache["match-all"][mycp] = cachelist
+                               return cachelist[:]
                mysplit = mycp.split("/")
                invalid_category = mysplit[0] not in self._categories
                d={}
@@ -535,12 +540,16 @@ class portdbapi(dbapi):
                                        cpv = cat + "/" + pn + "-" + ver + "-" + rev
                                mylist[i] = cpv
                if self.frozen and mytree is None:
-                       if not (not mylist and mycp.startswith("virtual/")):
-                               self.xcache["match-all"][mycp] = mylist[:]
+                       cachelist = mylist[:]
+                       self.xcache["cp-list"][mycp] = cachelist
+                       # Do not propagate old-style virtuals since
+                       # cp_list() doesn't expand them.
+                       if not (not cachelist and mycp.startswith("virtual/")):
+                               self.xcache["match-all"][mycp] = cachelist
                return mylist
 
        def freeze(self):
-               for x in "bestmatch-visible", "list-visible", "match-all", \
+               for x in "bestmatch-visible", "cp-list", "list-visible", "match-all", \
                        "match-visible", "minimum-all", "minimum-visible":
                        self.xcache[x]={}
                self.frozen=1