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

login
register
mail settings
Submitter Boris Feld
Date Nov. 26, 2018, 6:26 p.m.
Message ID <568c6a0abb650b9c0949.1543256768@localhost.localdomain>
Download mbox | patch
Permalink /patch/36783/
State Accepted
Headers show

Comments

Boris Feld - Nov. 26, 2018, 6:26 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 568c6a0abb650b9c0949e2231f0d8ff51cf40ece
# Parent  e5c18b7087cdeac2a1213c3499e9a8215b252af6
# EXP-Topic perf-tags
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 568c6a0abb65
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.

running `hg perftags` in a large private repository
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)

Patch

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