From: Zac Medico Date: Fri, 16 Nov 2007 08:43:10 +0000 (-0000) Subject: Speed up LibraryPackageMap.update() by pulling NEEDED from the X-Git-Tag: v2.2_pre1~385 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05a388421c57c36f704b669d724567f9cfa81aaf;p=portage.git Speed up LibraryPackageMap.update() by pulling NEEDED from the vardbapi.aux_get() cache. This greatly reduces the amount of needless IO that has been happening just prior to the postinst phase in dblink.treewalk(). We may want to consider having LibraryPackageMap work directly from the vardbapi instead of creating the intermediate /var/cache/edb/library_consumers file. svn path=/main/trunk/; revision=8516 --- diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index a35fcee4e..aa8c75a50 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -146,8 +146,9 @@ class LibraryPackageMap(object): def update(self): """ Update the global library->consumer map for the given vdb instance. """ obj_dict = {} + aux_get = self._dbapi.aux_get for cpv in self._dbapi.cpv_all(): - needed_list = grabfile(self._dbapi.getpath(cpv, "NEEDED")) + needed_list = aux_get(cpv, ["NEEDED"])[0].splitlines() for l in needed_list: mysplit = l.split() if len(mysplit) < 2: @@ -517,6 +518,12 @@ class vardbapi(dbapi): cache_valid = cache_mtime == mydir_mtime if cache_valid: cache_incomplete = self._aux_cache_keys.difference(metadata) + needed = metadata.get("NEEDED") + if needed is None or "\n" not in needed: + # Cached value has whitespace filtered, so it has to be pulled + # again. This is temporary migration code which can be removed + # later, since it only affects users who are running trunk. + cache_incomplete.add("NEEDED") if cache_incomplete: # Allow self._aux_cache_keys to change without a cache version # bump and efficiently recycle partial cache whenever possible. @@ -558,7 +565,8 @@ class vardbapi(dbapi): myd = myf.read() finally: myf.close() - myd = " ".join(myd.split()) + if x != "NEEDED": + myd = " ".join(myd.split()) except IOError: myd = "" if x == "EAPI" and not myd: