Patchwork [4,of,9,V3] perf: add the notion of "source" to perfrevlogwrite

login
register
mail settings
Submitter Boris Feld
Date Nov. 6, 2018, 11:27 a.m.
Message ID <e7f2594431ac5fba43ae.1541503652@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/36417/
State Accepted
Headers show

Comments

Boris Feld - Nov. 6, 2018, 11:27 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1539962609 -7200
#      Fri Oct 19 17:23:29 2018 +0200
# Node ID e7f2594431ac5fba43ae345b345d3aab1a4ab47c
# Parent  24f71fdc0551dffb59ad2c29c1183d747122ab64
# EXP-Topic revlog-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e7f2594431ac
perf: add the notion of "source" to perfrevlogwrite

We want to test performance associated witch various way to add a new revision.
They will be specified using this new argument.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1572,10 +1572,14 @@  def perfrevlogrevisions(ui, repo, file_=
           (b'', b'stoprev', -1, b'last revision to write'),
           (b'', b'count', 3, b'last revision to write'),
           (b'', b'details', False, b'print timing for every revisions tested'),
+          (b'', b'source', b'full', b'the kind of data feed in the revlog'),
          ],
          b'-c|-m|FILE')
 def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts):
     """Benchmark writing a series of revisions to a revlog.
+
+    Possible source value are:
+    * `full`: add from a full text (default).
     """
     opts = _byteskwargs(opts)
 
@@ -1586,13 +1590,19 @@  def perfrevlogwrite(ui, repo, file_=None
     if stoprev < 0:
         stoprev = rllen + stoprev
 
+    source = opts['source']
+    validsource = (b'full',)
+    if source not in validsource:
+        raise error.Abort('invalid source type: %s' % source)
+
     ### actually gather results
     count = opts['count']
     if count <= 0:
         raise error.Abort('invalide run count: %d' % count)
     allresults = []
     for c in range(count):
-        allresults.append(_timeonewrite(ui, rl, startrev, stoprev, c + 1))
+        timing = _timeonewrite(ui, rl, source, startrev, stoprev, c + 1)
+        allresults.append(timing)
 
     ### consolidate the results in a single list
     results = []
@@ -1654,7 +1664,7 @@  class _faketr(object):
     def add(s, x, y, z=None):
         return None
 
-def _timeonewrite(ui, orig, startrev, stoprev, runidx=None):
+def _timeonewrite(ui, orig, source, startrev, stoprev, runidx=None):
     timings = []
     tr = _faketr()
     with _temprevlog(ui, orig, startrev) as dest:
@@ -1665,7 +1675,7 @@  def _timeonewrite(ui, orig, startrev, st
             topic += ' (run #%d)' % runidx
         for idx, rev in enumerate(revs):
             ui.progress(topic, idx, unit='revs', total=total)
-            addargs, addkwargs = _getrevisionseed(orig, rev, tr)
+            addargs, addkwargs = _getrevisionseed(orig, rev, tr, source)
             with timeone() as r:
                 dest.addrawrevision(*addargs, **addkwargs)
             timings.append((rev, r[0]))
@@ -1673,13 +1683,16 @@  def _timeonewrite(ui, orig, startrev, st
         ui.progress(topic, None, unit='revs', total=total)
     return timings
 
-def _getrevisionseed(orig, rev, tr):
+def _getrevisionseed(orig, rev, tr, source):
     linkrev = orig.linkrev(rev)
     node = orig.node(rev)
     p1, p2 = orig.parents(node)
     flags = orig.flags(rev)
     cachedelta = None
-    text = orig.revision(rev)
+    text = None
+
+    if source == b'full':
+        text = orig.revision(rev)
 
     return ((text, tr, linkrev, p1, p2),
             {'node': node, 'flags':flags, 'cachedelta': cachedelta})