Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/deltas.py @ 39494:e72130f58f5d
snapshot: consider all snapshots in the parents' chains
There are no reasons to only consider full snapshot as a possible base for an
intermediate snapshot. Now that the basic principles have been set, we can
start adding more levels of snapshots.
We now consider all snapshots in the parent's chains (full or intermediate).
This creates a chain of intermediate snapshots, each smaller than the previous
one.
# Effect On The Test Repository
In the test repository, we can see a decrease in the revlog size and slightly
shorter delta chain.
However, that approach creates snapshots more frequently, increasing the risk
of ending into problematic cases in very branchy repositories (not triggered
by the test repository). The next changesets will remove that risk by adding
logic that increases deltas reuse.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 07 Sep 2018 11:17:30 -0400 |
parents | 3ca144f1c8dd |
children | 6a53842727c1 |
comparison
equal
deleted
inserted
replaced
39493:3ca144f1c8dd | 39494:e72130f58f5d |
---|---|
659 elif len(parents) > 0: | 659 elif len(parents) > 0: |
660 # Test all parents (1 or 2), and keep the best candidate | 660 # Test all parents (1 or 2), and keep the best candidate |
661 yield parents | 661 yield parents |
662 | 662 |
663 if sparse and parents: | 663 if sparse and parents: |
664 snapshots = collections.defaultdict(list) # map: base-rev: snapshot-rev | |
664 # See if we can use an existing snapshot in the parent chains to use as | 665 # See if we can use an existing snapshot in the parent chains to use as |
665 # a base for a new intermediate-snapshot | 666 # a base for a new intermediate-snapshot |
666 bases = [] | 667 # |
668 # search for snapshot in parents delta chain | |
669 # map: snapshot-level: snapshot-rev | |
670 parents_snaps = collections.defaultdict(set) | |
667 for p in parents: | 671 for p in parents: |
668 bases.append(deltachain(p)[0]) | 672 for idx, s in enumerate(deltachain(p)): |
669 yield tuple(sorted(bases)) | 673 if not revlog.issnapshot(s): |
674 break | |
675 parents_snaps[idx].add(s) | |
676 # Test them as possible intermediate snapshot base | |
677 # We test them from highest to lowest level. High level one are more | |
678 # likely to result in small delta | |
679 for idx, snaps in sorted(parents_snaps.items(), reverse=True): | |
680 yield tuple(sorted(snaps)) | |
670 # No suitable base found in the parent chain, search if any full | 681 # No suitable base found in the parent chain, search if any full |
671 # snapshots emitted since parent's base would be a suitable base for an | 682 # snapshots emitted since parent's base would be a suitable base for an |
672 # intermediate snapshot. | 683 # intermediate snapshot. |
673 # | 684 # |
674 # It give a chance to reuse a delta chain unrelated to the current | 685 # It give a chance to reuse a delta chain unrelated to the current |
675 # revisions instead of starting our own. Without such re-use, | 686 # revisions instead of starting our own. Without such re-use, |
676 # topological branches would keep reopening new full chains. Creating | 687 # topological branches would keep reopening new full chains. Creating |
677 # more and more snapshot as the repository grow. | 688 # more and more snapshot as the repository grow. |
678 snapfloor = min(bases) + 1 | 689 snapfloor = min(parents_snaps[0]) + 1 |
679 snapshots = collections.defaultdict(list) | |
680 _findsnapshots(revlog, snapshots, snapfloor) | 690 _findsnapshots(revlog, snapshots, snapfloor) |
681 yield tuple(snapshots[nullrev]) | 691 yield tuple(snapshots[nullrev]) |
682 | 692 |
683 # other approach failed try against prev to hopefully save us a | 693 # other approach failed try against prev to hopefully save us a |
684 # fulltext. | 694 # fulltext. |