1 |
commit: a983fc1c83402dbfe0a423bf729c72eeb795388c |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon May 9 04:51:47 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon May 9 04:51:47 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a983fc1c |
7 |
|
8 |
vardbapi: disable subprocess vdb cache updates |
9 |
|
10 |
Since commit 7535cabdf2fab76fc55df83643157613dfd66be9, |
11 |
vardbapi.flush_cache() is often called within subprocesses spawned |
12 |
from MergeProcess. The _aux_cache_threshold doesn't work as designed |
13 |
if the cache is flushed from a subprocess like this, can lead to the |
14 |
vdb cache being flushed for every single merge. This is a waste of |
15 |
disk IO, so disable vdb cache updates in subprocesses. |
16 |
|
17 |
--- |
18 |
pym/portage/dbapi/_MergeProcess.py | 3 +++ |
19 |
pym/portage/dbapi/vartree.py | 8 +++++++- |
20 |
2 files changed, 10 insertions(+), 1 deletions(-) |
21 |
|
22 |
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py |
23 |
index afb2e08..12a0baf 100644 |
24 |
--- a/pym/portage/dbapi/_MergeProcess.py |
25 |
+++ b/pym/portage/dbapi/_MergeProcess.py |
26 |
@@ -176,6 +176,9 @@ class MergeProcess(SpawnProcess): |
27 |
# is triggered when mylink._scheduler is None. |
28 |
mylink._scheduler = None |
29 |
|
30 |
+ # Avoid wastful updates of the vdb cache. |
31 |
+ self.vartree.dbapi._flush_cache_enabled = False |
32 |
+ |
33 |
# In this subprocess we don't want PORTAGE_BACKGROUND to |
34 |
# suppress stdout/stderr output since they are pipes. We |
35 |
# also don't want to open PORTAGE_LOG_FILE, since it will |
36 |
|
37 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
38 |
index a34f1ec..c81e99b 100644 |
39 |
--- a/pym/portage/dbapi/vartree.py |
40 |
+++ b/pym/portage/dbapi/vartree.py |
41 |
@@ -108,6 +108,11 @@ class vardbapi(dbapi): |
42 |
# have been added or removed. |
43 |
self._pkgs_changed = False |
44 |
|
45 |
+ # The _aux_cache_threshold doesn't work as designed |
46 |
+ # if the cache is flushed from a subprocess, so we |
47 |
+ # use this to avoid waste vdb cache updates. |
48 |
+ self._flush_cache_enabled = True |
49 |
+ |
50 |
#cache for category directory mtimes |
51 |
self.mtdircache = {} |
52 |
|
53 |
@@ -467,7 +472,8 @@ class vardbapi(dbapi): |
54 |
superuser privileges (since that's required to obtain a lock), but all |
55 |
users have read access and benefit from faster metadata lookups (as |
56 |
long as at least part of the cache is still valid).""" |
57 |
- if self._aux_cache is not None and \ |
58 |
+ if self._flush_cache_enabled and \ |
59 |
+ self._aux_cache is not None and \ |
60 |
len(self._aux_cache["modified"]) >= self._aux_cache_threshold and \ |
61 |
secpass >= 2: |
62 |
self._owners.populate() # index any unindexed contents |