mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
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.
This commit is contained in:
parent
0aa6f05307
commit
e37e16da0f
@ -1210,6 +1210,13 @@ def walkchangerevs(repo, match, opts, prepare):
|
||||
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 walkchangerevs(repo, match, opts, prepare):
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user