Mercurial > hg
diff mercurial/hgweb/webcommands.py @ 26894:41957e50e109
hgweb: compute changeset parents and children for log pages lazily
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
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 10 Nov 2015 23:02:59 +0800 |
parents | 7c1b4840c2cd |
children | f5faef7e9119 |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Sun Nov 08 23:42:44 2015 -0800 +++ b/mercurial/hgweb/webcommands.py Tue Nov 10 23:02:59 2015 +0800 @@ -264,8 +264,8 @@ 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 @@ "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()),