comparison mercurial/hgweb/webutil.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 268b39770c28
children c8cbef073645
comparison
equal deleted inserted replaced
26893:19c4b93cb7d6 26894:41957e50e109
295 showtags = showtag(repo, tmpl, 'changelogtag', n) 295 showtags = showtag(repo, tmpl, 'changelogtag', n)
296 files = listfilediffs(tmpl, ctx.files(), n, web.maxfiles) 296 files = listfilediffs(tmpl, ctx.files(), n, web.maxfiles)
297 297
298 return { 298 return {
299 "author": ctx.user(), 299 "author": ctx.user(),
300 "parent": parents(ctx, rev - 1), 300 "parent": lambda **x: parents(ctx, rev - 1),
301 "child": children(ctx, rev + 1), 301 "child": lambda **x: children(ctx, rev + 1),
302 "changelogtag": showtags, 302 "changelogtag": showtags,
303 "desc": ctx.description(), 303 "desc": ctx.description(),
304 "extra": ctx.extra(), 304 "extra": ctx.extra(),
305 "date": ctx.date(), 305 "date": ctx.date(),
306 "files": files, 306 "files": files,