vardbapi: disable subprocess vdb cache updates
authorZac Medico <zmedico@gentoo.org>
Mon, 9 May 2011 04:51:47 +0000 (21:51 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 9 May 2011 04:51:47 +0000 (21:51 -0700)
Since commit 7535cabdf2fab76fc55df83643157613dfd66be9,
vardbapi.flush_cache() is often called within subprocesses spawned
from MergeProcess. The _aux_cache_threshold doesn't work as designed
if the cache is flushed from a subprocess like this, can lead to the
vdb cache being flushed for every single merge. This is a waste of
disk IO, so disable vdb cache updates in subprocesses.

pym/portage/dbapi/_MergeProcess.py
pym/portage/dbapi/vartree.py

index afb2e084db07d443a5d3f797e4d06363bb428e89..12a0baf55f296f49a52d712650c434d7cd1e0be3 100644 (file)
@@ -176,6 +176,9 @@ class MergeProcess(SpawnProcess):
                # is triggered when mylink._scheduler is None.
                mylink._scheduler = None
 
+               # Avoid wastful updates of the vdb cache.
+               self.vartree.dbapi._flush_cache_enabled = False
+
                # In this subprocess we don't want PORTAGE_BACKGROUND to
                # suppress stdout/stderr output since they are pipes. We
                # also don't want to open PORTAGE_LOG_FILE, since it will
index a34f1ec017ab83e4deae071f90dfc21a01668863..c81e99b9e30f912b398e0c86238b260305ebbb7c 100644 (file)
@@ -108,6 +108,11 @@ class vardbapi(dbapi):
                # have been added or removed.
                self._pkgs_changed = False
 
+               # The _aux_cache_threshold doesn't work as designed
+               # if the cache is flushed from a subprocess, so we
+               # use this to avoid waste vdb cache updates.
+               self._flush_cache_enabled = True
+
                #cache for category directory mtimes
                self.mtdircache = {}
 
@@ -467,7 +472,8 @@ class vardbapi(dbapi):
                superuser privileges (since that's required to obtain a lock), but all
                users have read access and benefit from faster metadata lookups (as
                long as at least part of the cache is still valid)."""
-               if self._aux_cache is not None and \
+               if self._flush_cache_enabled and \
+                       self._aux_cache is not None and \
                        len(self._aux_cache["modified"]) >= self._aux_cache_threshold and \
                        secpass >= 2:
                        self._owners.populate() # index any unindexed contents