comparison 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
comparison
equal deleted inserted replaced
26893:19c4b93cb7d6 26894:41957e50e109
262 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) 262 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
263 263
264 yield tmpl('searchentry', 264 yield tmpl('searchentry',
265 parity=parity.next(), 265 parity=parity.next(),
266 author=ctx.user(), 266 author=ctx.user(),
267 parent=webutil.parents(ctx), 267 parent=lambda **x: webutil.parents(ctx),
268 child=webutil.children(ctx), 268 child=lambda **x: webutil.children(ctx),
269 changelogtag=showtags, 269 changelogtag=showtags,
270 desc=ctx.description(), 270 desc=ctx.description(),
271 extra=ctx.extra(), 271 extra=ctx.extra(),
272 date=ctx.date(), 272 date=ctx.date(),
273 files=files, 273 files=files,
998 "file": f, 998 "file": f,
999 "node": iterfctx.hex(), 999 "node": iterfctx.hex(),
1000 "author": iterfctx.user(), 1000 "author": iterfctx.user(),
1001 "date": iterfctx.date(), 1001 "date": iterfctx.date(),
1002 "rename": webutil.renamelink(iterfctx), 1002 "rename": webutil.renamelink(iterfctx),
1003 "parent": webutil.parents(iterfctx), 1003 "parent": lambda **x: webutil.parents(iterfctx),
1004 "child": webutil.children(iterfctx), 1004 "child": lambda **x: webutil.children(iterfctx),
1005 "desc": iterfctx.description(), 1005 "desc": iterfctx.description(),
1006 "extra": iterfctx.extra(), 1006 "extra": iterfctx.extra(),
1007 "tags": webutil.nodetagsdict(repo, iterfctx.node()), 1007 "tags": webutil.nodetagsdict(repo, iterfctx.node()),
1008 "bookmarks": webutil.nodebookmarksdict( 1008 "bookmarks": webutil.nodebookmarksdict(
1009 repo, iterfctx.node()), 1009 repo, iterfctx.node()),