Patchwork [2,of,4] delta: filter nullrev out first

login
register
mail settings
Submitter Boris Feld
Date Dec. 14, 2018, 9:24 p.m.
Message ID <2ae099bc17b55791398e.1544822676@localhost.localdomain>
Download mbox | patch
Permalink /patch/37161/
State Accepted
Headers show

Comments

Boris Feld - Dec. 14, 2018, 9:24 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1544089145 -3600
#      Thu Dec 06 10:39:05 2018 +0100
# Node ID 2ae099bc17b55791398ebc00d38fb4f988a1e2e3
# Parent  db0227d6f9291d9dac23f6f07699cf1fb7d1ea3d
# EXP-Topic sparse-revlog-corner-cases
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2ae099bc17b5
delta: filter nullrev out first

When picking a potential candidate, we filter them on various criteria. The
"different from nullrev" criteria is very fast to compute and we should
process it first.
Yuya Nishihara - Dec. 15, 2018, 1:52 a.m.
On Fri, 14 Dec 2018 21:24:36 +0000, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1544089145 -3600
> #      Thu Dec 06 10:39:05 2018 +0100
> # Node ID 2ae099bc17b55791398ebc00d38fb4f988a1e2e3
> # Parent  db0227d6f9291d9dac23f6f07699cf1fb7d1ea3d
> # EXP-Topic sparse-revlog-corner-cases
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2ae099bc17b5
> delta: filter nullrev out first
> 
> When picking a potential candidate, we filter them on various criteria. The
> "different from nullrev" criteria is very fast to compute and we should
> process it first.
> 
> diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
> --- a/mercurial/revlogutils/deltas.py
> +++ b/mercurial/revlogutils/deltas.py
> @@ -633,6 +633,10 @@ def _candidategroups(revlog, textlen, p1
>                              or deltalength(rev))):
>                  tested.add(rev)
>                  rev = deltaparent(rev)
> +            # no need to try a delta against nullrev, this will be done as a
> +            # last resort.
> +            if rev == nullrev:
> +                continue

Maybe we can remove nullrev from the initial tested set.

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -633,6 +633,10 @@  def _candidategroups(revlog, textlen, p1
                             or deltalength(rev))):
                 tested.add(rev)
                 rev = deltaparent(rev)
+            # no need to try a delta against nullrev, this will be done as a
+            # last resort.
+            if rev == nullrev:
+                continue
             # filter out revision we tested already
             if rev in tested:
                 continue
@@ -640,10 +644,6 @@  def _candidategroups(revlog, textlen, p1
             # filter out delta base that will never produce good delta
             if deltas_limit < revlog.length(rev):
                 continue
-            # no need to try a delta against nullrev, this will be done as a
-            # last resort.
-            if rev == nullrev:
-                continue
             # no delta for rawtext-changing revs (see "candelta" for why)
             if revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
                 continue