Re: [PATCH 2 of 4 V2] tags: cache `repo.changelog` access when checking tags nodes

2018-11-24 Thread Yuya Nishihara
On Fri, 23 Nov 2018 18:25:48 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1542710295 0
> #  Tue Nov 20 10:38:15 2018 +
> # Node ID 832048aabff97aa43cd306cd70cea00227f5e19e
> # Parent  2e15140b7b18f40ebbcf71e82c99acf8edadb69b
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 832048aabff9
> 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.39 user 0.33 sys 0.06 (median of 
> 25)
> after:  ! wall 0.267711 comb 0.27 user 0.21 sys 0.06 (median of 
> 38)
> 
> 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:

It doesn't work if a tagged node is hidden.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 4 V2] tags: cache `repo.changelog` access when checking tags nodes

2018-11-23 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1542710295 0
#  Tue Nov 20 10:38:15 2018 +
# Node ID 832048aabff97aa43cd306cd70cea00227f5e19e
# Parent  2e15140b7b18f40ebbcf71e82c99acf8edadb69b
# EXP-Topic perf-tags
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
832048aabff9
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.39 user 0.33 sys 0.06 (median of 25)
after:  ! wall 0.267711 comb 0.27 user 0.21 sys 0.06 (median of 38)

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):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel