Patchwork [6,of,7] perf: support looking up multiple revisions

login
register
mail settings
Submitter Boris Feld
Date Jan. 28, 2019, 8:10 p.m.
Message ID <1e135ddcbdd182a6b7ae.1548706258@localhost.localdomain>
Download mbox | patch
Permalink /patch/38146/
State Accepted
Headers show

Comments

Boris Feld - Jan. 28, 2019, 8:10 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1548663631 18000
#      Mon Jan 28 03:20:31 2019 -0500
# Node ID 1e135ddcbdd182a6b7ae7b121d254fb58c7fd658
# Parent  2518d5acdc4e994193ca5b70f945983a61e22ff5
# EXP-Topic perf-ext
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1e135ddcbdd1
perf: support looking up multiple revisions

The nodemap code has optimisations around the number of lookup we actually made.
As a result, being able to specify multiple revisions to look up is important
when measuring performances. One can now specify full revspecs with the --rev
arguments.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1016,7 +1016,7 @@  def perfignore(ui, repo, **opts):
     fm.end()
 
 @command(b'perfindex', [
-            (b'', b'rev', b'', b'revision to be looked up (default tip)'),
+            (b'', b'rev', [], b'revision to be looked up (default tip)'),
             (b'', b'no-lookup', None, b'do not revision lookup post creation'),
          ] + formatteropts)
 def perfindex(ui, repo, **opts):
@@ -1025,7 +1025,18 @@  def perfindex(ui, repo, **opts):
     The default is to look `tip` up. Depending on the index implementation,
     the revision looked up can matters. For example, an implementation
     scanning the index will have a faster lookup time for `--rev tip` than for
-    `--rev 0`.
+    `--rev 0`. The number of looked up revisions and their order can also
+    matters.
+
+    Example of useful set to test:
+    * tip
+    * 0
+    * -10:
+    * :10
+    * -10: + :10
+    * :10: + -10:
+    * -10000:
+    * -10000: + 0
 
     It is not currently possible to check for lookup of a missing node."""
     import mercurial.revlog
@@ -1033,12 +1044,15 @@  def perfindex(ui, repo, **opts):
     timer, fm = gettimer(ui, opts)
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
     if opts[b'no_lookup']:
-        n = None
-    elif opts[b'rev'] is None:
-        n = repo[b"tip"].node()
+        if opts['rev']:
+            raise error.Abort('--no-lookup and --rev are mutually exclusive')
+        nodes = []
+    elif not opts[b'rev']:
+        nodes = [repo[b"tip"].node()]
     else:
-        rev = scmutil.revsingle(repo, opts[b'rev'])
-        n = repo[rev].node()
+        revs = scmutil.revrange(repo, opts[b'rev'])
+        cl = repo.changelog
+        nodes = [cl.node(r) for r in revs]
 
     unfi = repo.unfiltered()
     # find the filecache func directly
@@ -1049,7 +1063,7 @@  def perfindex(ui, repo, **opts):
         clearchangelog(unfi)
     def d():
         cl = makecl(unfi)
-        if n is not None:
+        for n in nodes:
             cl.rev(n)
     timer(d, setup=setup)
     fm.end()