Optimize depgraph/portdbapi cache handling.
authorZac Medico <zmedico@gentoo.org>
Tue, 5 Oct 2010 03:14:17 +0000 (20:14 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 5 Oct 2010 03:14:17 +0000 (20:14 -0700)
pym/_emerge/depgraph.py
pym/portage/dbapi/porttree.py

index 3b0fdbec9084000f8b2908526a610b84ee1fa79e..ac23f4ba09af17894ac4afa9e352e9b61e69763a 100644 (file)
@@ -2468,7 +2468,14 @@ class depgraph(object):
                db = root_config.trees[self.pkg_tree_map[pkg_type]].dbapi
 
                if hasattr(db, "xmatch"):
-                       cpv_list = db.xmatch("match-all", atom)
+                       # For portdbapi we match only against the cpv, in order
+                       # to bypass unecessary cache access for things like IUSE
+                       # and SLOT. Later, we cache the metadata in a Package
+                       # instance, and use that for further matching. This
+                       # optimization is especially relevant since
+                       # pordbapi.aux_get() does not cache calls that have
+                       # myrepo or mytree arguments.
+                       cpv_list = db.xmatch("match-all-cpv-only", atom)
                else:
                        cpv_list = db.match(atom)
 
index 317d4a01eaf7430f8be3ff9f90ffe1f22f12b013..2d515e07cf59f53e32aa6d67942b87c7287e88a2 100644 (file)
@@ -759,7 +759,8 @@ class portdbapi(dbapi):
 
        def freeze(self):
                for x in "bestmatch-visible", "cp-list", "list-visible", "match-all", \
-                       "match-visible", "minimum-all", "minimum-visible":
+                       "match-all-cpv-only", "match-visible", "minimum-all", \
+                       "minimum-visible":
                        self.xcache[x]={}
                self.frozen=1
 
@@ -782,7 +783,18 @@ class portdbapi(dbapi):
                        mydep = dep_expand(origdep, mydb=self, settings=self.settings)
                        mykey = mydep.cp
 
-               if level == "list-visible":
+               if level == "match-all-cpv-only":
+                       # match *all* packages, only against the cpv, in order
+                       # to bypass unecessary cache access for things like IUSE
+                       # and SLOT.
+                       if mydep == mykey:
+                               # Share cache with match-all/cp_list
+                               # when the result is the same.
+                               level = "match-all"
+                               myval = self.cp_list(mykey)
+                       else:
+                               myval = match_from_list(mydep, self.cp_list(mykey))
+               elif level == "list-visible":
                        #a list of all visible packages, not called directly (just by xmatch())
                        #myval = self.visible(self.cp_list(mykey))