Commit Graph

26 Commits

Author SHA1 Message Date
Augie Fackler
9f876f6c89 cleanup: move stdlib imports to their own import statement
There are a few warnings still produced by my import checker, but
those are false positives produced by modules that share a name with
stdlib modules.
2013-11-06 16:48:06 -05:00
Bryan O'Sullivan
59b785a485 revlog: choose a consistent ancestor when there's a tie
Previously, we chose a rev based on numeric ordering, which could
cause "the same merge" in topologically identical but numerically
different repos to choose different merge bases.

We now choose the lexically least node; this is stable across
different revlog orderings.
2013-04-16 10:08:19 -07:00
Bryan O'Sullivan
4a3a46aff6 ancestor: a new algorithm that is faster for nodes near tip
Instead of walking all the way to the root of the DAG, we generate
a set of candidate GCA revs, then figure out which ones will win
the race to the root (usually without needing to traverse all the
way to the root).

In the common case of nodes that are close to each other in both
revision number and topology, this is usually a big win: it makes
"hg --time debugancestors" up to 9 times faster than the more general
ancestor function when measured on heads of the linux-2.6 hg repo.

Victory is not assured, however. The older function can still win
by a large margin if one node is much closer to the root than the
other, or by a much smaller amount if one is an ancestor of the
other.

For now, we've also got a small paranoid harness function that calls
both ancestor functions on every input and ensures that they give
equivalent answers.

Even without the checker function, the old ancestor function needs
to stay alive for the time being, as its generality is used by
context.filectx.merge.
2013-04-16 10:08:18 -07:00
Siddharth Agarwal
4fdbea480f ancestor: add lazy membership testing to lazyancestors
This also makes the perfancestorset command use lazy membership testing. In a
linear repository with over 400,000 commits, without this patch, hg
perfancestorset takes 0.80 seconds no matter how far behind we're looking.
With this patch, hg perfancestorset -- X takes:

    Rev X       Time
       -1      0.00s
    -4000      0.01s
   -20000      0.04s
   -80000      0.17s
  -200000      0.43s
  -300000      0.69s
        0      0.88s

Thus, for revisions close to tip, we're up to several orders of magnitude
faster. At 0 we're around 10% slower.
2012-12-18 12:47:20 -08:00
Siddharth Agarwal
4d560304bb revlog: move ancestor generation out to a new class
This refactoring is to prepare for implementing lazy membership.
2012-12-18 10:14:01 -08:00
Siddharth Agarwal
40a1b50c25 ancestor: move missingancestors doctest out into a separate file
This is in preparation for upcoming patches which will reuse the same graph
for tests.
2012-12-11 14:47:33 -08:00
Siddharth Agarwal
de26481ded ancestor: fix a comment (followup to 17e6f4c8dcfb) 2012-11-28 10:35:12 -08:00
Siddharth Agarwal
a0694d4a53 ancestor: faster algorithm for difference of ancestor sets
One of the major reasons rebase is slow in large repositories is
the computation of the detach set: the set of ancestors of the
changesets to rebase not in the destination parent. This is currently
done via a revset that does two walks all the way to the root of
the DAG. Instead of doing that, to find ancestors of a set <revs>
not in another set <common> we walk up the tree in reverse revision
number order, maintaining sets of nodes visited from <revs>, <common>
or both.

For the common case where the sets are close both topologically and
in revision number (relative to repository size), this has been
found to speed up rebase by around 15-20%. When the nodes are farther
apart and the DAG is highly branching, it is harder to say which
would win.

Here's how long computing the detach set takes in a linear repository
with over 400000 changesets, rebasing near tip:

Rebasing across 4 changesets
Revset method: 2.2s
New algorithm: 0.00015s

Rebasing across 250 changesets
Revset method: 2.2s
New algorithm: 0.00069s

Rebasing across 10000 changesets
Revset method: 2.4s
New algorithm: 0.019s
2012-11-26 11:46:51 -08:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Matt Mackall
112f27426d ancestor: improve description 2011-03-07 15:45:10 -06:00
Matt Mackall
51b3b09c8f backout most of 26e0b9a8ce0d 2010-09-24 12:46:54 -05:00
Brodie Rao
7362459729 cleanup: use x in (a, b) instead of x == a or x == b 2010-09-23 00:02:31 -05:00
Matt Mackall
299b7254c4 merge: sort arguments to stabilize the ancestor search 2010-06-21 13:25:42 -05:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Sune Foldager
910782bf26 ancestor: improve docstring
The term "least common ancestor" is highly ambiguous.
2009-11-24 09:49:23 +01:00
Benoit Boissinot
1f59ef6f81 ancestor: use set instead of dict 2009-05-17 03:53:13 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Nicolas Dumazet
5c8c0a663b ancestor: caching the parent list to improve performance
When computing the DAG depth, we walk through all ancestors: this commit adds
memoization during that first step. Then, the memorized parents are fetched
from a dict instead of calling parents() on each vertex.

This tweak, according to Kcachegrind, improves ancestor() performance by 16%
when cloning a big repository.
2009-03-23 15:36:30 +01:00
Matt Mackall
56e621f7bc symmetricdifference: move back to copies
It's too tightly dependent on known revlog ordering to fit well in ancestors
2008-03-29 12:39:47 -05:00
Matt Mackall
ab64062215 symmetricdifference: change colors to sides 2008-03-29 12:39:47 -05:00
Matt Mackall
469b176973 ancestors: simplify symmetric difference
- n_wanted/wanted -> interesting
- scan colors rather than managing ret
2008-03-29 12:39:47 -05:00
Matt Mackall
5c5200eb63 diff: use copy smarts from copies.py 2008-03-15 10:02:31 -05:00
Matt Mackall
ce54a3ea46 merge: move symmetricdifferences to ancestor.py 2008-03-15 10:02:31 -05:00
Thomas Arendsen Hein
411d64ce3e white space and line break cleanups 2006-11-17 08:06:54 +01:00
Matt Mackall
79aed53c85 Abstract ancestor algorithm into generic function
Make depth calculation non-recursive
Add simple shortcut for linear ancestry

Convert context to use ancestor function
 make memoized parents function

Convert revlog to use ancestor function
2006-09-20 16:50:50 -05:00