[PATCH] hgweb: compute changeset parents and children for log pages lazily

Augie Fackler raf at durin42.com
Tue Nov 10 16:18:06 CST 2015


> On Nov 10, 2015, at 10:47 AM, Anton Shestakov <av6 at dwimlabs.net> wrote:
> 
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1447167779 -28800
> #      Tue Nov 10 23:02:59 2015 +0800
> # Node ID 6501f73ee550ccb6b73be8b0c611706ceaf666bd
> # Parent  8b2fbe3f59b1b969878691cb472369ad0067f165
> hgweb: compute changeset parents and children for log pages lazily
> 

Queued this, many thanks. Nice catch!

> Log pages, i.e. changelog, filelog and search results page computed children
> and parents for each changeset shown, because spartan hgweb style shows this
> info. Turns out, computing all this is heavy and also unnecessary for log pages
> in all other hgweb styles.
> 
> Luckily, templates allow an easy way to do computations on demand: just pass
> the heavy part of code as a callable and it will be only called when needed.
> 
> Here are some benchmarks on the mercurial repository (best of 3):
> 
> time wget http://127.0.0.1:8021/
> 
> before: 0m0.050s
> after:  0m0.040s
> 
> time wget http://127.0.0.1:8021/?revcount=960
> 
> before: 0m1.164s
> after:  0m0.389s
> 
> time wget http://127.0.0.1:8021/log/tip/mercurial/commands.py
> 
> before: 0m0.047s
> after:  0m0.042s
> 
> time wget http://127.0.0.1:8021/log/tip/mercurial/commands.py?revcount=960
> 
> before: 0m0.830s
> after:  0m0.434s
> 
> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py
> +++ b/mercurial/hgweb/webcommands.py
> @@ -264,8 +264,8 @@ def _search(web, req, tmpl):
>             yield tmpl('searchentry',
>                        parity=parity.next(),
>                        author=ctx.user(),
> -                       parent=webutil.parents(ctx),
> -                       child=webutil.children(ctx),
> +                       parent=lambda **x: webutil.parents(ctx),
> +                       child=lambda **x: webutil.children(ctx),
>                        changelogtag=showtags,
>                        desc=ctx.description(),
>                        extra=ctx.extra(),
> @@ -1000,8 +1000,8 @@ def filelog(web, req, tmpl):
>                       "author": iterfctx.user(),
>                       "date": iterfctx.date(),
>                       "rename": webutil.renamelink(iterfctx),
> -                      "parent": webutil.parents(iterfctx),
> -                      "child": webutil.children(iterfctx),
> +                      "parent": lambda **x: webutil.parents(iterfctx),
> +                      "child": lambda **x: webutil.children(iterfctx),
>                       "desc": iterfctx.description(),
>                       "extra": iterfctx.extra(),
>                       "tags": webutil.nodetagsdict(repo, iterfctx.node()),
> diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
> --- a/mercurial/hgweb/webutil.py
> +++ b/mercurial/hgweb/webutil.py
> @@ -297,8 +297,8 @@ def changelistentry(web, ctx, tmpl):
> 
>     return {
>         "author": ctx.user(),
> -        "parent": parents(ctx, rev - 1),
> -        "child": children(ctx, rev + 1),
> +        "parent": lambda **x: parents(ctx, rev - 1),
> +        "child": lambda **x: children(ctx, rev + 1),
>         "changelogtag": showtags,
>         "desc": ctx.description(),
>         "extra": ctx.extra(),
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151110/4e6a6400/attachment.pgp>


More information about the Mercurial-devel mailing list