Patchwork [2,of,6,frozen-repos] perf: support obtaining contexts from perfrevset

mail settings
Submitter Gregory Szorc
Date Nov. 22, 2015, 1:13 a.m.
Message ID <2dd44d0377a2a9f7266e.1448154839@ubuntu-main>
Download mbox | patch
Permalink /patch/11566/
State Accepted
Delegated to: Pierre-Yves David
Headers show


Gregory Szorc - Nov. 22, 2015, 1:13 a.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1448149158 28800
#      Sat Nov 21 15:39:18 2015 -0800
# Node ID 2dd44d0377a2a9f7266e156dc262737e0139c7af
# Parent  e6778f6f5ada8a50bfd7e154334692c404383315
perf: support obtaining contexts from perfrevset

Previously, perfrevset called repo.revs(), which only returns integer
revisions. Many revset consumers call repo.set(), which returns
changectx instances. Or they obtain a context manually later.

Since obtaining changectx instances when evaluating revsets is common,
this patch adds support for benchmarking this use case.

While we added an if conditional for every benchmark loop, it
doesn't appear to matter since revset evaluation dwarfs the cost
of a single if.


diff --git a/contrib/ b/contrib/
--- a/contrib/
+++ b/contrib/
@@ -458,29 +458,33 @@  def perfrevlog(ui, repo, file_, **opts):
         r = revlog.revlog(lambda fn: open(fn, 'rb'), file_)
         for x in xrange(0, len(r), dist):
-         [('C', 'clear', False, 'clear volatile cache between each call.')]
+         [('C', 'clear', False, 'clear volatile cache between each call.'),
+          ('x', 'contexts', False, 'obtain changectx for each revision')]
          + formatteropts, "REVSET")
-def perfrevset(ui, repo, expr, clear=False, **opts):
+def perfrevset(ui, repo, expr, clear=False, contexts=False, **opts):
     """benchmark the execution time of a revset
     Use the --clean option if need to evaluate the impact of build volatile
     revisions set cache on the revset execution. Volatile cache hold filtered
     and obsolete related cache."""
     timer, fm = gettimer(ui, opts)
     def d():
         if clear:
-        for r in repo.revs(expr): pass
+        if contexts:
+            for ctx in repo.set(expr): pass
+        else:
+            for r in repo.revs(expr): pass
 @command('perfvolatilesets', formatteropts)
 def perfvolatilesets(ui, repo, *names, **opts):
     """benchmark the computation of various volatile set
     Volatile set computes element related to filtering and obsolescence."""