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

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 5:25 p.m.
Message ID <438718ecc3058c55b0d5.1542993949@localhost.localdomain>
Download mbox | patch
Permalink /patch/36750/
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 1542711320 0
#      Tue Nov 20 10:55:20 2018 +0000
# Node ID 438718ecc3058c55b0d5a4a9742b3325b83e78cc
# Parent  832048aabff97aa43cd306cd70cea00227f5e19e
# EXP-Topic perf-tags
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 438718ecc305
perf: add a `clear-revlogs` flag to `perfbookmarks`

This flag (off by default) makes it possible to enable the refresh of the
changelog and revlog. This is useful to check for costly side effects of
bookmark loading.

Usually, these side effects are shared with other logics (eg: tags).

example output in my mercurial repo (with 1 bookmark, so not a great example):
$ hg perfbookmarks
! wall 0.000044
$ hg perfbookmarks --clear-revlogs
! wall 0.001380
Yuya Nishihara - Nov. 25, 2018, 3:22 a.m.
On Fri, 23 Nov 2018 18:25:49 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542711320 0
> #      Tue Nov 20 10:55:20 2018 +0000
> # Node ID 438718ecc3058c55b0d5a4a9742b3325b83e78cc
> # Parent  832048aabff97aa43cd306cd70cea00227f5e19e
> # EXP-Topic perf-tags
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 438718ecc305
> perf: add a `clear-revlogs` flag to `perfbookmarks`
> 
> This flag (off by default) makes it possible to enable the refresh of the
> changelog and revlog. This is useful to check for costly side effects of
> bookmark loading.
> 
> Usually, these side effects are shared with other logics (eg: tags).
> 
> example output in my mercurial repo (with 1 bookmark, so not a great example):
> $ hg perfbookmarks
> ! wall 0.000044
> $ hg perfbookmarks --clear-revlogs
> ! wall 0.001380
> 
> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -577,13 +577,20 @@ def perfancestorset(ui, repo, revset, **
>      timer(d)
>      fm.end()
>  
> -@command(b'perfbookmarks', formatteropts)
> +@command(b'perfbookmarks', formatteropts +
> +        [
> +            (b'', b'clear-revlogs', False, 'refresh changelog and manifest'),
> +        ])
>  def perfbookmarks(ui, repo, **opts):
>      """benchmark parsing bookmarks from disk to memory"""
>      opts = _byteskwargs(opts)
>      timer, fm = gettimer(ui, opts)
>  
> +    svfs = getsvfs(repo)
> +    clearrevlogs = opts['clear_revlogs']
>      def s():
> +        if clearrevlogs:
> +            repo.changelog = mercurial.changelog.changelog(svfs)

Same here. We might want a helper function that discards revlog cache.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -577,13 +577,20 @@  def perfancestorset(ui, repo, revset, **
     timer(d)
     fm.end()
 
-@command(b'perfbookmarks', formatteropts)
+@command(b'perfbookmarks', formatteropts +
+        [
+            (b'', b'clear-revlogs', False, 'refresh changelog and manifest'),
+        ])
 def perfbookmarks(ui, repo, **opts):
     """benchmark parsing bookmarks from disk to memory"""
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
 
+    svfs = getsvfs(repo)
+    clearrevlogs = opts['clear_revlogs']
     def s():
+        if clearrevlogs:
+            repo.changelog = mercurial.changelog.changelog(svfs)
         clearfilecache(repo, b'_bookmarks')
     def d():
         repo._bookmarks