Patchwork [1,of,8] perfrevflogwrite: clear revlog cache between each write

login
register
mail settings
Submitter Boris Feld
Date Dec. 17, 2018, noon
Message ID <bfc00ea63c21a3027537.1545048043@localhost.localdomain>
Download mbox | patch
Permalink /patch/37217/
State Accepted
Headers show

Comments

Boris Feld - Dec. 17, 2018, noon
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1545039442 -3600
#      Mon Dec 17 10:37:22 2018 +0100
# Node ID bfc00ea63c21a3027537206c8c6fc39a22a71875
# Parent  2393c40442144eb96712e97b426990706cd94ef0
# EXP-Topic sparse-revlog-corner-cases
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r bfc00ea63c21
perfrevflogwrite: clear revlog cache between each write

We want to measure write time from a cold cache (similar to commit). So we
need to clear the cache to prevent computation from rev N-1 to interfere with
rev N.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1722,6 +1722,7 @@  def perfrevlogrevisions(ui, repo, file_=
           (b'', b'details', False, b'print timing for every revisions tested'),
           (b'', b'source', b'full', b'the kind of data feed in the revlog'),
           (b'', b'lazydeltabase', True, b'try the provided delta first'),
+          (b'', b'clear-caches', True, b'clear revlog cache between calls'),
          ],
          b'-c|-m|FILE')
 def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts):
@@ -1746,6 +1747,7 @@  def perfrevlogwrite(ui, repo, file_=None
 
     lazydeltabase = opts['lazydeltabase']
     source = opts['source']
+    clearcaches = opts['clear_cache']
     validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest',
                    b'storage')
     if source not in validsource:
@@ -1758,7 +1760,8 @@  def perfrevlogwrite(ui, repo, file_=None
     allresults = []
     for c in range(count):
         timing = _timeonewrite(ui, rl, source, startrev, stoprev, c + 1,
-                               lazydeltabase=lazydeltabase)
+                               lazydeltabase=lazydeltabase,
+                               clearcaches=clearcaches)
         allresults.append(timing)
 
     ### consolidate the results in a single list
@@ -1825,7 +1828,7 @@  class _faketr(object):
         return None
 
 def _timeonewrite(ui, orig, source, startrev, stoprev, runidx=None,
-                  lazydeltabase=True):
+                  lazydeltabase=True, clearcaches=True):
     timings = []
     tr = _faketr()
     with _temprevlog(ui, orig, startrev) as dest:
@@ -1838,6 +1841,9 @@  def _timeonewrite(ui, orig, source, star
         for idx, rev in enumerate(revs):
             ui.progress(topic, idx, unit='revs', total=total)
             addargs, addkwargs = _getrevisionseed(orig, rev, tr, source)
+            if clearcaches:
+                dest.index.clearcaches()
+                dest.clearcaches()
             with timeone() as r:
                 dest.addrawrevision(*addargs, **addkwargs)
             timings.append((rev, r[0]))