Patchwork [3,of,5] tags: cache `repo.changelog` access when checking tags nodes

login
register
mail settings
Submitter Boris Feld
Date Nov. 20, 2018, 7:18 p.m.
Message ID <1ad7353bec2584a53f2b.1542741487@localhost.localdomain>
Download mbox | patch
Permalink /patch/36674/
State Accepted
Headers show

Comments

Boris Feld - Nov. 20, 2018, 7:18 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542710295 0
#      Tue Nov 20 10:38:15 2018 +0000
# Node ID 1ad7353bec2584a53f2bb4fbca44310fa827f2d0
# Parent  7760b12bd4fb467f4fb7e4d0d5094fc324f30f49
# EXP-Topic perf-tags
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1ad7353bec25
tags: cache `repo.changelog` access when checking tags nodes

The tags reading process checks if the nodes referenced in tags exist. Caching
the access to `repo.changelog` provides a large speedup for repositories with
many tags.

before: ! wall 0.393464 comb 0.390000 user 0.330000 sys 0.060000 (median of 25)
after:  ! wall 0.267711 comb 0.270000 user 0.210000 sys 0.060000 (median of 38)
Pulkit Goyal - Nov. 21, 2018, 10:42 a.m.
On Tue, Nov 20, 2018 at 10:23 PM Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542710295 0
> #      Tue Nov 20 10:38:15 2018 +0000
> # Node ID 1ad7353bec2584a53f2bb4fbca44310fa827f2d0
> # Parent  7760b12bd4fb467f4fb7e4d0d5094fc324f30f49
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 1ad7353bec25
> tags: cache `repo.changelog` access when checking tags nodes
>
> The tags reading process checks if the nodes referenced in tags exist.
> Caching
> the access to `repo.changelog` provides a large speedup for repositories
> with
> many tags.
>
> before: ! wall 0.393464 comb 0.390000 user 0.330000 sys 0.060000 (median
> of 25)
> after:  ! wall 0.267711 comb 0.270000 user 0.210000 sys 0.060000 (median
> of 38)
>

Can you please add the perf command of which these results are in this
patch also?

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1416,13 +1416,11 @@  class localrepository(object):
             tags, tt = self._findtags()
         else:
             tags = self._tagscache.tags
+        rev = self.changelog.nodemap.get
         for k, v in tags.iteritems():
-            try:
-                # ignore tags to unknown nodes
-                self.changelog.rev(v)
+            # ignore tags to unknown nodes
+            if rev(v) is not None:
                 t[k] = v
-            except (error.LookupError, ValueError):
-                pass
         return t
 
     def _findtags(self):