Commit Graph

4 Commits

Author SHA1 Message Date
Pulkit Goyal
c2e90cbe3b tests: optimize test-copytrace-heuristics.t
test-copytrace-heuristics.t tests the heuristics algorithm of copytracing. The
test has a pattern of making a server repo first and then cloning into a local
repo for each test to have public and draft commits. This is done because if we
have all draft commits and we have very less commits, heuristics will fallback
to full copytracing as that will be fast.

To avoid creating the server repo, we set the commit limit to -1 so that
everytime we perform the heuristics algorithm even when having full drafts and
tweak the config setting when we need to test the ability to fallback to full
copytracing.

This optimizes this test by 3 seconds.

Before:

real    0m41.503s
user    0m36.068s
sys     0m3.900s

After:

real    0m38.826s
user    0m33.884s
sys     0m3.396s

Differential Revision: https://phab.mercurial-scm.org/D991
2017-10-10 01:03:24 +05:30
Pulkit Goyal
ee400fb169 copytrace: add a a new config to limit the number of drafts in heuristics
The heuristics options tries to the default full copytracing algorithm if both
the source and destination branches contains of non-public changesets only. But
this can be slow in cases when we have a lot of drafts.

This patch adds a new config option experimental.copytrace.sourcecommitlimit
which defaults to 100. This value will be the limit of number of drafts from c1
to base. Incase there are more changesets even though they are draft, the
heuristics algorithm will be used.

Differential Revision: https://phab.mercurial-scm.org/D763
2017-09-21 15:58:44 +05:30
Pulkit Goyal
8a6be941c9 copytrace: use the full copytracing method if only drafts are involved
This patch adds the functionality to use the full copytracing even if
`experimental.copytrace = heuristics` in cases when drafts are involved.

This is also a part of copytrace extension in fbext.

This also adds tests which are also taken from fbext.

.. feature::

   The `heuristics` option for `experimental.copytrace` performs full
   copytracing if both source and destination branches contains non-public
   changsets only.

Differential Revision: https://phab.mercurial-scm.org/D625
2017-09-03 20:06:45 +05:30
Pulkit Goyal
a5baff1381 copytrace: move fast heuristic copytracing algorithm to core
copytrace extension in fb-hgext has a heuristic implementation of copy tracing
which is faster than the current copy tracing. The heuristic limits the search
of copies to just files that are either:

1) Renames in the same directory
2) Moved to other directory with same name

The default copytrace implementation is very slow as it finds all the new files
that were added from merge base up to the head commit and for each file it
checks whether it this was copied or moved version of a different file.

Stash@fb did analysis for the above heuristics on the fb repo and found that
among 2,443,768 moves/copies there are only 32,234 moves/copies which does not
fall under the above heuristics which is approx. 0.013 of total copies.

This patch moves the heuristics algorithm under config
`experimental.copytrace=heuristics`.

While moving fbext to core, this patch removes couple of less useful config
options named `sourcecommitlimit` and `maxmovescandidatestocheck`.

Tests are also added for the heuristics algorithm, which are basically copied
from fbext/tests/test-copytrace.t. The tests follow a pattern creating a server
repo and then cloning to a local repo to create public and draft changesets, the
distinction which will be useful in upcoming patches.

After this patch `experimental.copytrace` has the following behaviour:

1) `off`: turns off copytracing
2) `heuristics`: use the heuristic algorithm added in this patch.
3) everything else: use the full copytracing algorithm

.. feature::

   A new fast heuristic algorithm for copytracing which assumes that the files
   moves are either::
   1) Renames in the same directory
   2) Moves in other directories with same names
   You can use this algorithm by setting `experimental.copytrace=heuristics`.

Differential Revision: https://phab.mercurial-scm.org/D623
2017-09-03 03:49:15 +05:30