Patchwork [05,of,10,V2] revlog: more efficient implementation for issnapshot

login
register
mail settings
Submitter Boris Feld
Date Dec. 21, 2018, 11:47 a.m.
Message ID <4067f496c37ec6d10860.1545392828@localhost.localdomain>
Download mbox | patch
Permalink /patch/37297/
State Accepted
Headers show

Comments

Boris Feld - Dec. 21, 2018, 11:47 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545040296 -3600
#      Mon Dec 17 10:51:36 2018 +0100
# Node ID 4067f496c37ec6d10860504186917bb6be83db46
# Parent  fcf4b48099cb8692a5de920876ce6a6586b96e98
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4067f496c37e
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,11 +1535,17 @@  class revlog(object):
         """
         if rev == nullrev:
             return True
-        deltap = self.deltaparent(rev)
+        entry = self.index[rev]
+        deltap = entry[3]
+        if deltap == rev:
+            return True
+        if not self._generaldelta:
+            return False
         if deltap == nullrev:
             return True
-        p1, p2 = self.parentrevs(rev)
-        if deltap in (p1, p2):
+        p1 = entry[5]
+        p2 = entry[6]
+        if deltap == p1 or deltap == p2:
             return False
         return self.issnapshot(deltap)