changeset 41881:e514799e4e07

discovery: use a lower level but faster way to retrieve parents We already know that no revision in the undecided set are filtered, so we can skip multiple checks and directly access lower level data. In a private pathological case, this improves the timing from about 70 seconds to about 50 seconds. There are other actions to be taken to improve that case, however this gives an idea of the general overhead.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 28 Feb 2019 00:56:27 +0100
parents 55919b96c02a
children c98420914c10
files mercurial/setdiscovery.py
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/setdiscovery.py	Thu Feb 28 00:12:12 2019 +0100
+++ b/mercurial/setdiscovery.py	Thu Feb 28 00:56:27 2019 +0100
@@ -165,6 +165,12 @@
         # common.bases and all its ancestors
         return self._common.basesheads()
 
+    def _parentsgetter(self):
+        getrev = self._repo.changelog.index.__getitem__
+        def getparents(r):
+            return getrev(r)[5:6]
+        return getparents
+
     def takequicksample(self, headrevs, size):
         """takes a quick sample of size <size>
 
@@ -181,7 +187,7 @@
         if len(sample) >= size:
             return _limitsample(sample, size)
 
-        _updatesample(None, headrevs, sample, self._repo.changelog.parentrevs,
+        _updatesample(None, headrevs, sample, self._parentsgetter(),
                       quicksamplesize=size)
         return sample
 
@@ -191,10 +197,11 @@
             return list(revs)
         repo = self._repo
         sample = set(repo.revs('heads(%ld)', revs))
+        parentrevs = self._parentsgetter()
 
         # update from heads
         revsheads = sample.copy()
-        _updatesample(revs, revsheads, sample, repo.changelog.parentrevs)
+        _updatesample(revs, revsheads, sample, parentrevs)
 
         # update from roots
         revsroots = set(repo.revs('roots(%ld)', revs))
@@ -209,7 +216,6 @@
         # this by keeping a persistent cache of children across invocations.
         children = {}
 
-        parentrevs = repo.changelog.parentrevs
         for rev in repo.changelog.revs(start=min(revsroots)):
             # Always ensure revision has an entry so we don't need to worry
             # about missing keys.