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

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

Comments

Boris Feld - Nov. 26, 2018, 6:44 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 d5e0cfcc409ed9f71a7bd85a711f810151ed8c5e
# Parent  41772e57bfc92d38899b24f729d992c39dc32473
# EXP-Topic perf-branchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d5e0cfcc409e
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)
Augie Fackler - Nov. 29, 2018, 10:07 p.m.
On Mon, Nov 26, 2018 at 07:44:39PM +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542931777 -3600
> #      Fri Nov 23 01:09:37 2018 +0100
> # Node ID d5e0cfcc409ed9f71a7bd85a711f810151ed8c5e
> # Parent  41772e57bfc92d38899b24f729d992c39dc32473
> # EXP-Topic perf-branchmap
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r d5e0cfcc409e
> perf: add a `--clear-caches` to `perfbranchmapupdate`

Series LGTM, but needs rebased AFAICT. Could you resend?

Sorry. :/

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -2234,10 +2234,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
@@ -2250,6 +2256,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
 
@@ -2315,6 +2322,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)