Patchwork [2,of,8,V3] revlog: more efficient implementation for issnapshot

login
register
mail settings
Submitter Boris Feld
Date Dec. 28, 2018, 6:12 p.m.
Message ID <d313cef8450897c3abf2.1546020768@pc62.home>
Download mbox | patch
Permalink /patch/37380/
State Accepted
Headers show

Comments

Boris Feld - Dec. 28, 2018, 6:12 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 d313cef8450897c3abf201940f73f57b5dfe8b37
# Parent  e7865a9776d5f676b2c49390e533bca293be6f9e
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d313cef84508
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%)
Yuya Nishihara - Dec. 30, 2018, 8:39 a.m.
On Fri, 28 Dec 2018 19:12:48 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1545040296 -3600
> #      Mon Dec 17 10:51:36 2018 +0100
> # Node ID d313cef8450897c3abf201940f73f57b5dfe8b37
> # Parent  e7865a9776d5f676b2c49390e533bca293be6f9e
> # EXP-Topic sparse-revlog
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d313cef84508
> 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%)
> 
> 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

Can you update the commit message to describe that the original implementation
was wrong if generaldelta is off?

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)