Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/
Date: Sun, 30 Oct 2011 05:25:19
Message-Id: 9347995ce3f657263e9216eed34a876a5c02c3d2.zmedico@gentoo
1 commit: 9347995ce3f657263e9216eed34a876a5c02c3d2
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 30 05:24:58 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 30 05:24:58 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9347995c
7
8 egencache: tweak redundant write check condition
9
10 We can use the raise_stat_collision attribute to determine when it is
11 necessary to check for redundant writes.
12
13 ---
14 bin/egencache | 33 ++++++++++++++++-----------------
15 1 files changed, 16 insertions(+), 17 deletions(-)
16
17 diff --git a/bin/egencache b/bin/egencache
18 index afd2baa..02ef4bd 100755
19 --- a/bin/egencache
20 +++ b/bin/egencache
21 @@ -226,18 +226,15 @@ class GenCache(object):
22 raise Exception("cache formats '%s' aren't supported" %
23 (" ".join(conf.cache_formats),))
24
25 - self._avoid_redundant_write = set()
26 - from portage.cache.metadata import database as pms_database
27 - for trg_cache in self._trg_caches:
28 - if not isinstance(trg_cache, pms_database):
29 - self._avoid_redundant_write.add(id(trg_cache))
30 - elif rsync:
31 - trg_cache.raise_stat_collision = True
32 - # Make _metadata_callback write this cache first, in case
33 - # it raises a StatCollision and triggers mtime
34 - # modification.
35 - self._trg_caches = tuple([trg_cache] +
36 - [x for x in self._trg_caches if x is not trg_cache])
37 + if rsync:
38 + for trg_cache in self._trg_caches:
39 + if hasattr(trg_cache, 'raise_stat_collision'):
40 + trg_cache.raise_stat_collision = True
41 + # Make _metadata_callback write this cache first, in case
42 + # it raises a StatCollision and triggers mtime
43 + # modification.
44 + self._trg_caches = tuple([trg_cache] +
45 + [x for x in self._trg_caches if x is not trg_cache])
46
47 self._existing_nodes = set()
48
49 @@ -253,7 +250,7 @@ class GenCache(object):
50
51 def _write_cache(self, trg_cache, cpv, repo_path, metadata, ebuild_hash):
52
53 - if id(trg_cache) in self._avoid_redundant_write:
54 + if not hasattr(trg_cache, 'raise_stat_collision'):
55 # This cache does not avoid redundant writes automatically,
56 # so check for an identical existing entry before writing.
57 # This prevents unecessary disk writes and can also prevent
58 @@ -285,10 +282,12 @@ class GenCache(object):
59 # exception from _setitem() if they detect this type of stat
60 # collision. These exceptions are handled by bumping the
61 # mtime on the ebuild (and the corresponding cache entry).
62 - # This type of cache must not be included in the above
63 - # _avoid_redundant_write set, since __setitem__ must be
64 - # called in order to detect the StatCollision (redundant
65 - # writes will be avoided internally). See bug #139134.
66 + # See bug #139134. It is convenient to include checks for
67 + # redundant writes along with the interal StatCollision
68 + # detection code, so for caches with the
69 + # raise_stat_collision attribute, we do not need to
70 + # explicitly check for redundant writes like we do for the
71 + # other cache types above.
72 max_mtime = sc.mtime
73 for ec, ec_hash in metadata['_eclasses_'].items():
74 if max_mtime < ec_hash.mtime: