[PATCH 2 of 2 V2] perf: add a --[no-]clear-caches option to `perfnodemap`

Boris Feld boris.feld at octobus.net
Tue Jan 29 10:47:04 EST 2019


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1548664893 18000
#      Mon Jan 28 03:41:33 2019 -0500
# Node ID 4ecd8c3fa0df874dcae358025c160b0bbbaf57d1
# Parent  3414a69b2e99e8fa605f63f9973894c80dd144b3
# EXP-Topic perf-ext
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4ecd8c3fa0df
perf: add a --[no-]clear-caches option to `perfnodemap`

The option is useful to look at pure lookup performance on a warm data
structure.

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1068,7 +1068,8 @@ def perfindex(ui, repo, **opts):
     fm.end()
 
 @command(b'perfnodemap', [
-            (b'', b'rev', [], b'revision to be looked up (default tip)'),
+          (b'', b'rev', [], b'revision to be looked up (default tip)'),
+          (b'', b'clear-caches', True, b'clear revlog cache between calls'),
     ] + formatteropts)
 def perfnodemap(ui, repo, **opts):
     """benchmark the time necessary to look up revision from a cold nodemap
@@ -1093,6 +1094,7 @@ def perfnodemap(ui, repo, **opts):
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
 
     unfi = repo.unfiltered()
+    clearcaches = opts['clear_caches']
     # find the filecache func directly
     # This avoid polluting the benchmark with the filecache logic
     makecl = unfi.__class__.changelog.func
@@ -1109,13 +1111,18 @@ def perfnodemap(ui, repo, **opts):
         clearchangelog(unfi)
         nodeget[0] = makecl(unfi).nodemap.get
 
-    def setup():
-        setnodeget()
     def d():
         get = nodeget[0]
         for n in nodes:
             get(n)
 
+    setup = None
+    if clearcaches:
+        def setup():
+            setnodeget()
+    else:
+        setnodeget()
+        d() # prewarm the data structure
     timer(d, setup=setup)
     fm.end()
 


More information about the Mercurial-devel mailing list