Patchwork [2,of,2] perfbranchmap: allow to select the filter to benchmark

login
register
mail settings
Submitter Boris Feld
Date Feb. 21, 2018, 2:38 p.m.
Message ID <ddab5cae846a3e05ec4b.1519223892@FB>
Download mbox | patch
Permalink /patch/28189/
State Accepted
Headers show

Comments

Boris Feld - Feb. 21, 2018, 2:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1519209792 -3600
#      Wed Feb 21 11:43:12 2018 +0100
# Node ID ddab5cae846a3e05ec4b951472e562fce06301ea
# Parent  f40e09835c645bbc0b535228ac743d84e952f866
# EXP-Topic filter-perfbranchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ddab5cae846a
perfbranchmap: allow to select the filter to benchmark

Running the branchmap computation on all filter levels can be expensive.
Narrowing the run to some specific filters can speed up benchmarking time when
working only on a subset of filter levels.
Yuya Nishihara - Feb. 22, 2018, 12:27 p.m.
On Wed, 21 Feb 2018 15:38:12 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1519209792 -3600
> #      Wed Feb 21 11:43:12 2018 +0100
> # Node ID ddab5cae846a3e05ec4b951472e562fce06301ea
> # Parent  f40e09835c645bbc0b535228ac743d84e952f866
> # EXP-Topic filter-perfbranchmap
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ddab5cae846a
> perfbranchmap: allow to select the filter to benchmark

Queued, thanks.

> @@ -1591,6 +1593,9 @@ def perfbranchmap(ui, repo, full=False, 
>          return d
>      # add filter in smaller subset to bigger subset
>      possiblefilters = set(repoview.filtertable)
> +    print("FILTERNAMES", filternames)

Looks like a debug print. Removed in flight.
If you really need it, please use ui.status() or something.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1568,11 +1568,13 @@  def perfvolatilesets(ui, repo, *names, *
           ('', 'clear-revbranch', False,
            'purge the revbranch cache between computation'),
          ] + formatteropts)
-def perfbranchmap(ui, repo, full=False, clear_revbranch=False, **opts):
+def perfbranchmap(ui, repo, *filternames, **opts):
     """benchmark the update of a branchmap
 
     This benchmarks the full repo.branchmap() call with read and write disabled
     """
+    full = opts.get("full", False)
+    clear_revbranch = opts.get("clear_revbranch", False)
     timer, fm = gettimer(ui, opts)
     def getbranchmap(filtername):
         """generate a benchmark function for the filtername"""
@@ -1591,6 +1593,9 @@  def perfbranchmap(ui, repo, full=False, 
         return d
     # add filter in smaller subset to bigger subset
     possiblefilters = set(repoview.filtertable)
+    print("FILTERNAMES", filternames)
+    if filternames:
+        possiblefilters &= set(filternames)
     subsettable = getbranchmapsubsettable()
     allfilters = []
     while possiblefilters:
@@ -1607,8 +1612,9 @@  def perfbranchmap(ui, repo, full=False, 
     if not full:
         for name in allfilters:
             repo.filtered(name).branchmap()
-    # add unfiltered
-    allfilters.append(None)
+    if not filternames or 'unfiltered' in filternames:
+        # add unfiltered
+        allfilters.append(None)
 
     branchcacheread = safeattrsetter(branchmap, 'read')
     branchcachewrite = safeattrsetter(branchmap.branchcache, 'write')