Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 40152:adbf8ca239e4
revlog: optimize ancestors() to not check filtered revisions for each
While reviewing the Rust implementation, I noticed iter(ancestors) doesn't
need to check filtering state for each parent revision. And doing that appears
to have some measurable perf win.
$ hg perfancestors -R mercurial
(orig) wall 0.038093 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
(this) wall 0.024795 comb 0.020000 user 0.020000 sys 0.000000 (best of 117)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 12 Oct 2018 06:22:43 +0200 |
parents | 324b4b10351e |
children | ba70e3acf58a |
comparison
equal
deleted
inserted
replaced
40151:38ac525b44c9 | 40152:adbf8ca239e4 |
---|---|
646 raise error.WdirUnsupported | 646 raise error.WdirUnsupported |
647 raise | 647 raise |
648 | 648 |
649 return entry[5], entry[6] | 649 return entry[5], entry[6] |
650 | 650 |
651 # fast parentrevs(rev) where rev isn't filtered | |
652 _uncheckedparentrevs = parentrevs | |
653 | |
651 def node(self, rev): | 654 def node(self, rev): |
652 try: | 655 try: |
653 return self.index[rev][7] | 656 return self.index[rev][7] |
654 except IndexError: | 657 except IndexError: |
655 if rev == wdirrev: | 658 if rev == wdirrev: |
745 """Generate the ancestors of 'revs' in reverse topological order. | 748 """Generate the ancestors of 'revs' in reverse topological order. |
746 Does not generate revs lower than stoprev. | 749 Does not generate revs lower than stoprev. |
747 | 750 |
748 See the documentation for ancestor.lazyancestors for more details.""" | 751 See the documentation for ancestor.lazyancestors for more details.""" |
749 | 752 |
750 return ancestor.lazyancestors(self.parentrevs, revs, stoprev=stoprev, | 753 # first, make sure start revisions aren't filtered |
751 inclusive=inclusive) | 754 revs = list(revs) |
755 checkrev = self.node | |
756 for r in revs: | |
757 checkrev(r) | |
758 # and we're sure ancestors aren't filtered as well | |
759 return ancestor.lazyancestors(self._uncheckedparentrevs, revs, | |
760 stoprev=stoprev, inclusive=inclusive) | |
752 | 761 |
753 def descendants(self, revs): | 762 def descendants(self, revs): |
754 return dagop.descendantrevs(revs, self.revs, self.parentrevs) | 763 return dagop.descendantrevs(revs, self.revs, self.parentrevs) |
755 | 764 |
756 def findcommonmissing(self, common=None, heads=None): | 765 def findcommonmissing(self, common=None, heads=None): |