changelog-v2: add a configuration to disable rank computation
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 22 Nov 2022 12:44:22 +0100
changeset 49778 45d7b8c380d7
parent 49777 7aea9babac5d
child 49779 f56873a7284c
changelog-v2: add a configuration to disable rank computation We encountered a graph where rank computation was pathologically slow. We add an option to disable this computation while this is getting fixed. Disabling the rank computation should allow for testing other changelog-v2 features undisturbed (like changeset-based copy tracing). I am purposely not adding a test for the new non-default code path, as this is a temporary work around of an experimental feature.
mercurial/configitems.py
mercurial/localrepo.py
mercurial/revlog.py
--- a/mercurial/configitems.py	Mon Nov 21 15:04:19 2022 +0100
+++ b/mercurial/configitems.py	Tue Nov 22 12:44:22 2022 +0100
@@ -923,6 +923,13 @@
     b'changegroup4',
     default=False,
 )
+
+# might remove rank configuration once the computation has no impact
+coreconfigitem(
+    b'experimental',
+    b'changelog-v2.compute-rank',
+    default=True,
+)
 coreconfigitem(
     b'experimental',
     b'cleanup-as-archived',
--- a/mercurial/localrepo.py	Mon Nov 21 15:04:19 2022 +0100
+++ b/mercurial/localrepo.py	Tue Nov 22 12:44:22 2022 +0100
@@ -1068,6 +1068,8 @@
         options[b'revlogv2'] = True
     if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
         options[b'changelogv2'] = True
+        cmp_rank = ui.configbool(b'experimental', b'changelog-v2.compute-rank')
+        options[b'changelogv2.compute-rank'] = cmp_rank
 
     if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
         options[b'generaldelta'] = True
--- a/mercurial/revlog.py	Mon Nov 21 15:04:19 2022 +0100
+++ b/mercurial/revlog.py	Tue Nov 22 12:44:22 2022 +0100
@@ -365,6 +365,11 @@
         self._srdensitythreshold = 0.50
         self._srmingapsize = 262144
 
+        # other optionnals features
+
+        # might remove rank configuration once the computation has no impact
+        self._compute_rank = False
+
         # Make copy of flag processors so each revlog instance can support
         # custom flags.
         self._flagprocessors = dict(flagutil.flagprocessors)
@@ -406,6 +411,7 @@
 
         if b'changelogv2' in opts and self.revlog_kind == KIND_CHANGELOG:
             new_header = CHANGELOGV2
+            self._compute_rank = opts.get(b'changelogv2.compute-rank', True)
         elif b'revlogv2' in opts:
             new_header = REVLOGV2
         elif b'revlogv1' in opts:
@@ -2499,7 +2505,7 @@
             sidedata_offset = 0
 
         rank = RANK_UNKNOWN
-        if self._format_version == CHANGELOGV2:
+        if self._compute_rank:
             if (p1r, p2r) == (nullrev, nullrev):
                 rank = 1
             elif p1r != nullrev and p2r == nullrev: