summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-06-04 01:37:28 +0000
committerZac Medico <zmedico@gentoo.org>2008-06-04 01:37:28 +0000
commit747b37f258d3dc60a56cf8b009e4748119b592e8 (patch)
treea4643bcc06b4dcaf53f6c6bb4d77c35e7d2ea19d
parentd3d74ba390a663c5585090875fcb26d30ad3a824 (diff)
downloadportage-747b37f258d3dc60a56cf8b009e4748119b592e8.tar.gz
portage-747b37f258d3dc60a56cf8b009e4748119b592e8.tar.bz2
portage-747b37f258d3dc60a56cf8b009e4748119b592e8.zip
Add modification threshold for BlockerCache.flush(), to avoid wasteful IO.
(trunk r10549) svn path=/main/branches/2.1.2/; revision=10569
-rwxr-xr-xbin/emerge16
1 files changed, 10 insertions, 6 deletions
diff --git a/bin/emerge b/bin/emerge
index 5513eacf9..217608437 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -1585,6 +1585,11 @@ class BlockerCache(DictMixin):
1) the set of installed packages (including COUNTER) has changed
2) the old-style virtuals have changed
"""
+
+ # Number of uncached packages to trigger cache update, since
+ # it's wasteful to update it for every vdb change.
+ _cache_threshold = 5
+
class BlockerData(object):
__slots__ = ("__weakref__", "atoms", "counter")
@@ -1600,7 +1605,7 @@ class BlockerCache(DictMixin):
portage.CACHE_PATH.lstrip(os.path.sep), "vdb_blockers.pickle")
self._cache_version = "1"
self._cache_data = None
- self._modified = False
+ self._modified = 0
self._load()
def _load(self):
@@ -1669,7 +1674,7 @@ class BlockerCache(DictMixin):
self._cache_data = {"version":self._cache_version}
self._cache_data["blockers"] = {}
self._cache_data["virtuals"] = self._virtuals
- self._modified = False
+ self._modified = 0
def flush(self):
"""If the current user has permission and the internal blocker cache
@@ -1687,7 +1692,7 @@ class BlockerCache(DictMixin):
"virtuals" : vardb.settings.getvirtuals()
}
"""
- if self._modified and \
+ if self._modified >= self._cache_threshold and \
secpass >= 2:
try:
f = portage_util.atomic_ofstream(self._cache_filename)
@@ -1697,7 +1702,7 @@ class BlockerCache(DictMixin):
self._cache_filename, gid=portage.portage_gid, mode=0644)
except (IOError, OSError), e:
pass
- self._modified = False
+ self._modified = 0
def __setitem__(self, cpv, blocker_data):
"""
@@ -1711,14 +1716,13 @@ class BlockerCache(DictMixin):
"""
self._cache_data["blockers"][cpv] = \
(blocker_data.counter, tuple(str(x) for x in blocker_data.atoms))
- self._modified = True
+ self._modified += 1
def __iter__(self):
return iter(self._cache_data["blockers"])
def __delitem__(self, cpv):
del self._cache_data["blockers"][cpv]
- self._modified = True
def __getitem__(self, cpv):
"""