[PATCH] manifest: cache parsed fulltext during find
Durham Goode
durham at fb.com
Mon Mar 11 19:25:09 CDT 2013
On 3/11/13 2:17 PM, "Bryan O'Sullivan" <bos at serpentine.com> wrote:
>
>diff --git a/mercurial/manifest.py b/mercurial/manifest.py
>--- a/mercurial/manifest.py
>+++ b/mercurial/manifest.py
>@@ -107,6 +107,7 @@ class manifest(revlog.revlog):
> mapping = self._mancache[node][0]
> return mapping.get(f), mapping.flags(f)
> text = self.revision(node)
>+ self._mancache[node] = self.parse(text), array.array('c', text)
> start, end = self._search(text, f)
> if start == end:
> return None, None
>From looking at the find() function, it looks like it was written with the
purpose of not parsing the whole manifest. So I worry that this fix will
have a negative affect somewhere else. Looks like the find() function was
originally added as part of looking up tags
(http://selenic.com/hg/rev/dbdce3b99988). 'hg tags' reads the manifest
for each head and looks for the .hgtags file. So 'hg tags' will now be
slower by (number of heads) * (speed of self.parse()).
If that perf hit is acceptable, we might as well just write find as:
def find(self, node, f):
mapping = self.read(node)
Return mapping.get(f), mapping.flags(f)
If that perf hit is not acceptable, we should just change 'hg grep' to use
manifest.read() and do the .get() and .flags() itself.
Durham
More information about the Mercurial-devel
mailing list