[PATCH 2 of 2] treemanifest: speed up 4x tree to flat manifest conversion

Martin von Zweigbergk martinvonz at google.com
Thu Feb 4 13:43:30 EST 2016


And why is this important? I know many others like the perf commands, but I
prefer to know what commands it speeds up. Could you please people like me
too by including timings for an end-user command?

On Thu, Feb 4, 2016, 10:04 Laurent Charignon <lcharignon at fb.com> wrote:

> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1454606782 28800
> #      Thu Feb 04 09:26:22 2016 -0800
> # Branch stable
> # Node ID b163d0993d788fb7c5a55a8a052b1115ba7b66e6
> # Parent  241c38b8b3acbf8d2ab57fa85a38e337ef4e2472
> treemanifest: speed up 4x tree to flat manifest conversion
>
> On our big repos we have a 4x speed improvement in tree to flat manifest
> conversion:
>
> Before this patch
> ~/hg/hg perftreemanifesttotext
> ! wall 25.622450 comb 25.590000 user 25.410000 sys 0.180000 (best of 3)
>
> After this patch
> ~/hg/hg perftreemanifesttotext
> ! wall 6.541120 comb 6.540000 user 6.470000 sys 0.070000 (best of 3)
>
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -848,10 +848,20 @@
>
>      def text(self, usemanifestv2=False):
>          """Get the full data of this manifest as a bytestring."""
> -        self._load()
> -        flags = self.flags
> -        return _text(((f, self[f], flags(f)) for f in self.keys()),
> -                     usemanifestv2)
> +        tovisit = []
> +        visit = tovisit.pop
> +        tovisit.append(self)
> +        res = []
> +
> +        while tovisit:
> +            n = visit()
> +            n._load()
> +            tovisit.extend(n._dirs.values())
> +            dirpath = n._dir
> +            getflags = n._flags.get
> +            res.extend([(dirpath + f, u, getflags(f, ''))
> +                       for (f, u) in n._files.items()])
> +        return _text(sorted(res), usemanifestv2)
>
>      def dirtext(self, usemanifestv2=False):
>          """Get the full data of this directory as a bytestring. Make sure
> that
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160204/08b0ee4a/attachment.html>


More information about the Mercurial-devel mailing list