From 05a388421c57c36f704b669d724567f9cfa81aaf Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 16 Nov 2007 08:43:10 +0000 Subject: 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 --- pym/portage/dbapi/vartree.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22