Patchwork [3,of,4] perf: cache revlog file handle during perfrevlog

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 16, 2016, 8:35 p.m.
Message ID <9e2f957b05ac5c765952.1476650136@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17148/
State Deferred
Headers show

Comments

Gregory Szorc - Oct. 16, 2016, 8:35 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1476649617 25200
#      Sun Oct 16 13:26:57 2016 -0700
# Node ID 9e2f957b05ac5c76595280a6084ba01d7b369a05
# Parent  ee7144d686de700d60cb2a78adac3aab43f2a71d
perf: cache revlog file handle during perfrevlog

The aim of perfrevlog is to measure how fast revlog revisions
can be resolved, not I/O. Since we now have a mechanism to cache
an open file handle on a revlog instance, let's use it.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -788,18 +788,19 @@  def perfrevlog(ui, repo, file_=None, sta
         startrev = 0
         endrev = _len(r)
         dist = opts['dist']
 
         if reverse:
             startrev, endrev = endrev, startrev
             dist = -1 * dist
 
-        for x in xrange(startrev, endrev, dist):
-            r.revision(r.node(x))
+        with r.cachefilehandle():
+            for x in xrange(startrev, endrev, dist):
+                r.revision(r.node(x))
 
     timer(d)
     fm.end()
 
 @command('perfrevlogrevision', revlogopts + formatteropts +
          [('', 'cache', False, 'use caches instead of clearing')],
          '-c|-m|FILE REV')
 def perfrevlogrevision(ui, repo, file_, rev=None, cache=None, **opts):