Mercurial > hg-stable
changeset 18710:49ef9d0ca815
cmdutil: use a small initial window with --limit
In a large repo, running a command like "log -l1 -p" was expensive because
it would always traverse 8 commits, as 8 was the initial window size.
We now choose the lesser of 8 or the limit, speeding up the "log -l1 -p"
case by a factor of 5.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Wed, 20 Feb 2013 11:31:38 -0800 |
parents | 9955fc5ee24b |
children | 6b786dc88612 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Feb 20 11:31:34 2013 -0800 +++ b/mercurial/cmdutil.py Wed Feb 20 11:31:38 2013 -0800 @@ -1210,6 +1210,13 @@ if ff.match(x): wanted.discard(x) + # Choose a small initial window if we will probably only visit a + # few commits. + limit = loglimit(opts) + windowsize = 8 + if limit: + windowsize = min(limit, windowsize) + # Now that wanted is correctly initialized, we can iterate over the # revision range, yielding only revisions in wanted. def iterate(): @@ -1221,7 +1228,7 @@ def want(rev): return rev in wanted - for i, window in increasingwindows(0, len(revs)): + for i, window in increasingwindows(0, len(revs), windowsize): nrevs = [rev for rev in revs[i:i + window] if want(rev)] for rev in sorted(nrevs): fns = fncache.get(rev)