Patchwork [2,of,7,V4] revlog: more efficient implementation for issnapshot

login
register
mail settings
Submitter Boris Feld
Date Dec. 30, 2018, 6:43 p.m.
Message ID <260f93686b0c2b151b94.1546195429@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/37393/
State Accepted
Headers show

Comments

Boris Feld - Dec. 30, 2018, 6:43 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545040296 -3600
#      Mon Dec 17 10:51:36 2018 +0100
# Node ID 260f93686b0c2b151b94f87881496f5228220ae3
# Parent  88025ac40a127963ea8a186ae5e81f64002db39a
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 260f93686b0c
revlog: more efficient implementation for issnapshot

We avoid multiple method calls and tuple creation, this provides a significant
speedup in some case:

example affected manifest write
before: 0.815520s
after:  0.487767s (-40%)

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1535,15 +1535,19 @@  class revlog(object):
         """
         if rev == nullrev:
             return True
-        deltap = self.deltaparent(rev)
-        if deltap == nullrev:
+        entry = self.index[rev]
+        base = entry[3]
+        if base == rev:
             return True
         elif not self._sparserevlog:
             return False
-        p1, p2 = self.parentrevs(rev)
-        if deltap in (p1, p2):
+        if base == nullrev:
+            return True
+        p1 = entry[5]
+        p2 = entry[6]
+        if base == p1 or base == p2:
             return False
-        return self.issnapshot(deltap)
+        return self.issnapshot(base)
 
     def snapshotdepth(self, rev):
         """number of snapshot in the chain before this one"""