[PATCH 2 of 8 V6] perf: add a new `perfhelper-tracecopies` command

Boris Feld boris.feld at octobus.net
Mon Nov 19 11:49:41 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1542636896 0
#      Mon Nov 19 14:14:56 2018 +0000
# Node ID 633fcd53410ff023898f19539f1e5fe50edfd68d
# Parent  40c285f3b12012727bcdfd11984d81fe56386316
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 633fcd53410f
perf: add a new `perfhelper-tracecopies` command

The command is not measuring performance itself, it digs interesting statistic
to help pick good arguments for the `perfcopytrace` command.

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1164,6 +1164,54 @@ def perftracecopies(ui, repo, source, de
     timer(runone)
     fm.end()
 
+ at command(b'perfhelper-tracecopies', formatteropts +
+         [
+          (b'r', b'revs', [], b'restrict search to these revisions'),
+         ])
+def perfhelpertracecopies(ui, repo, revs=[], **opts):
+    """find statistic about potential parameters for the `perftracecopies`
+
+    This command find source-destination pair relevant for copytracing testing.
+    It report value for some of the parameters that impact copy tracing time.
+    """
+    opts = _byteskwargs(opts)
+    fm = ui.formatter(b'perf', opts)
+    header = '%12s %12s %12s %12s\n'
+    output = ("%(source)12s %(destination)12s "
+              "%(nbrevs)12d %(nbmissingfiles)12d\n")
+    fm.plain(header % ("source", "destination", "nb-revs", "nb-files"))
+
+    if not revs:
+        revs = ['all()']
+    revs = scmutil.revrange(repo, revs)
+
+    roi = repo.revs('merge() and %ld', revs)
+    for r in roi:
+        ctx = repo[r]
+        p1 = ctx.p1().rev()
+        p2 = ctx.p2().rev()
+        bases = repo.changelog._commonancestorsheads(p1, p2)
+        for p in (p1, p2):
+            for b in bases:
+                base = repo[b]
+                parent = repo[p]
+                missing = copies._computeforwardmissing(base, parent)
+                if not missing:
+                    continue
+                fm.startitem()
+                data = {
+                    b'source': base.hex(),
+                    b'destination': parent.hex(),
+                    b'nbrevs': len(repo.revs('%d::%d', b, p)),
+                    b'nbmissingfiles': len(missing),
+                }
+                fm.data(**data)
+                out = data.copy()
+                out['source'] = fm.hexfunc(base.node())
+                out['destination'] = fm.hexfunc(parent.node())
+                fm.plain(output % out)
+    fm.end()
+
 @command(b'perfcca', formatteropts)
 def perfcca(ui, repo, **opts):
     opts = _byteskwargs(opts)
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -83,6 +83,9 @@ perfstatus
    perffncachewrite
                  (no help text available)
    perfheads     (no help text available)
+   perfhelper-tracecopies
+                 find statistic about potential parameters for the
+                 'perftracecopies'
    perfindex     (no help text available)
    perflinelogedits
                  (no help text available)


More information about the Mercurial-devel mailing list