Patchwork [1,of,4,V2] perf: add a `clear-revlogs` flag to `perftags`

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 5:25 p.m.
Message ID <2e15140b7b18f40ebbcf.1542993947@localhost.localdomain>
Download mbox | patch
Permalink /patch/36751/
State New
Headers show

Comments

Boris Feld - Nov. 23, 2018, 5:25 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542710780 0
#      Tue Nov 20 10:46:20 2018 +0000
# Node ID 2e15140b7b18f40ebbcf71e82c99acf8edadb69b
# Parent  4369c00a8ee168565fba97112283bbc00be8ce44
# EXP-Topic perf-tags
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2e15140b7b18
perf: add a `clear-revlogs` flag to `perftags`

This flag (on by default) makes it possible to disable the refresh of the
changelog and revlog. This is useful to check for the time spent in the core
tags logic without the associated side effects. Usually, these side effects
are shared with other logics (eg: bookmarks).

Example output in my Mercurial repository

$ hg perftags
! wall 0.017919 comb 0.020000 user 0.020000 sys 0.000000 (best of 141)
$ hg perftags --no-clear-revlogs
! wall 0.012982 comb 0.010000 user 0.010000 sys 0.000000 (best of 207)
Yuya Nishihara - Nov. 25, 2018, 3:19 a.m.
On Fri, 23 Nov 2018 18:25:47 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542710780 0
> #      Tue Nov 20 10:46:20 2018 +0000
> # Node ID 2e15140b7b18f40ebbcf71e82c99acf8edadb69b
> # Parent  4369c00a8ee168565fba97112283bbc00be8ce44
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2e15140b7b18
> perf: add a `clear-revlogs` flag to `perftags`
> 
> This flag (on by default) makes it possible to disable the refresh of the
> changelog and revlog. This is useful to check for the time spent in the core
> tags logic without the associated side effects. Usually, these side effects
> are shared with other logics (eg: bookmarks).
> 
> Example output in my Mercurial repository
> 
> $ hg perftags
> ! wall 0.017919 comb 0.020000 user 0.020000 sys 0.000000 (best of 141)
> $ hg perftags --no-clear-revlogs
> ! wall 0.012982 comb 0.010000 user 0.010000 sys 0.000000 (best of 207)
> 
> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -528,7 +528,10 @@ def perfheads(ui, repo, **opts):
>      timer(d)
>      fm.end()
>  
> -@command(b'perftags', formatteropts)
> +@command(b'perftags', formatteropts+
> +        [
> +            (b'', b'clear-revlogs', True, 'refresh changelog and manifest'),
> +        ])
>  def perftags(ui, repo, **opts):
>      import mercurial.changelog
>      import mercurial.manifest
> @@ -537,11 +540,13 @@ def perftags(ui, repo, **opts):
>      timer, fm = gettimer(ui, opts)
>      svfs = getsvfs(repo)
>      repocleartagscache = repocleartagscachefunc(repo)
> +    clearrevlogs = opts['clear_revlogs']
>      def s():
> -        repo.changelog = mercurial.changelog.changelog(svfs)
> -        rootmanifest = mercurial.manifest.manifestrevlog(svfs)
> -        repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
> -                                                          rootmanifest)
> +        if clearrevlogs:
> +            repo.changelog = mercurial.changelog.changelog(svfs)
> +            rootmanifest = mercurial.manifest.manifestrevlog(svfs)
> +            repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
> +                                                              rootmanifest)

Can you update these to discard cached properties? It isn't your fault, but
it doesn't seem correct to replace repo attributes by new revlogs.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -528,7 +528,10 @@  def perfheads(ui, repo, **opts):
     timer(d)
     fm.end()
 
-@command(b'perftags', formatteropts)
+@command(b'perftags', formatteropts+
+        [
+            (b'', b'clear-revlogs', True, 'refresh changelog and manifest'),
+        ])
 def perftags(ui, repo, **opts):
     import mercurial.changelog
     import mercurial.manifest
@@ -537,11 +540,13 @@  def perftags(ui, repo, **opts):
     timer, fm = gettimer(ui, opts)
     svfs = getsvfs(repo)
     repocleartagscache = repocleartagscachefunc(repo)
+    clearrevlogs = opts['clear_revlogs']
     def s():
-        repo.changelog = mercurial.changelog.changelog(svfs)
-        rootmanifest = mercurial.manifest.manifestrevlog(svfs)
-        repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
-                                                          rootmanifest)
+        if clearrevlogs:
+            repo.changelog = mercurial.changelog.changelog(svfs)
+            rootmanifest = mercurial.manifest.manifestrevlog(svfs)
+            repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
+                                                              rootmanifest)
         repocleartagscache()
     def t():
         return len(repo.tags())