Patchwork [13,of,13] perf: add a `--clear-caches` to `perfbranchmapupdate`

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 2:09 p.m.
Message ID <fb12c8325cea684942d9.1542982149@localhost.localdomain>
Download mbox | patch
Permalink /patch/36742/
State Accepted
Headers show

Comments

Boris Feld - Nov. 23, 2018, 2:09 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542931777 -3600
#      Fri Nov 23 01:09:37 2018 +0100
# Node ID fb12c8325cea684942d949ff5ee913d90bf2d6e0
# Parent  ef17ac4ed0534a809c978c5677355d436ce90db9
# EXP-Topic perf-branchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fb12c8325cea
perf: add a `--clear-caches` to `perfbranchmapupdate`

This flag will help to measure the time we spend loading various cache that
support the branchmap update.

Example for an 500 000 revisions repository:

hg perfbranchmapupdate --base 'not tip' --target 'tip'
! wall 0.000860 comb 0.000000 user 0.000000 sys 0.000000 (best of 336)
hg perfbranchmapupdate --base 'not tip' --target 'tip' --clear-caches
! wall 0.029494 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -2186,10 +2186,16 @@  def perfbranchmap(ui, repo, *filternames
 @command(b'perfbranchmapupdate', [
      (b'', b'base', [], b'subset of revision to start from'),
      (b'', b'target', [], b'subset of revision to end with'),
+     (b'', b'clear-caches', False, b'clear cache between each runs')
     ] + formatteropts)
 def perfbranchmapupdate(ui, repo, base=(), target=(), **opts):
     """benchmark branchmap update from for <base> revs to <target> revs
 
+    if `--clear-caches` is passed, the following items will be reset before
+    each update:
+        * the changelog instance and associated indexes
+        * the rev-branch-cache instance
+
     Examples:
 
        # update for the one last revision
@@ -2202,6 +2208,7 @@  def perfbranchmapupdate(ui, repo, base=(
     from mercurial import repoview
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
+    clearcaches = opts['clear_caches']
     unfi = repo.unfiltered()
     x = [None] # used to pass data between closure
 
@@ -2267,6 +2274,9 @@  def perfbranchmapupdate(ui, repo, base=(
 
         def setup():
             x[0] = base.copy()
+            if clearcaches:
+                unfi._revbranchcache = None
+                clearchangelog(repo)
 
         def bench():
             x[0].update(targetrepo, newrevs)