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

login
register
mail settings
Submitter Boris Feld
Date Jan. 29, 2019, 3:47 p.m.
Message ID <4ecd8c3fa0df874dcae3.1548776824@localhost.localdomain>
Download mbox | patch
Permalink /patch/38154/
State Accepted
Headers show

Comments

Boris Feld - Jan. 29, 2019, 3:47 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.
Augie Fackler - Jan. 30, 2019, 9:26 p.m.
queued, thanks 

> On Jan 29, 2019, at 10:47, Boris Feld <boris.feld@octobus.net> wrote:
> 
> # HG changeset patch
> # User Boris Feld <boris.feld@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()
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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()