Patchwork perf: allow to clear the obsstore in 'perfvolatilesets'

login
register
mail settings
Submitter Pierre-Yves David
Date May 21, 2017, 11:44 a.m.
Message ID <94371c6bd54f4dd50ba3.1495367088@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20786/
State Accepted
Headers show

Comments

Pierre-Yves David - May 21, 2017, 11:44 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1495366327 -7200
#      Sun May 21 13:32:07 2017 +0200
# Node ID 94371c6bd54f4dd50ba3fe7c4e86759407312d85
# Parent  eb7674b12d5a15fc53f10b075dcac7bee91379d2
# EXP-Topic obscache
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 94371c6bd54f
perf: allow to clear the obsstore in 'perfvolatilesets'

Loading the obsstore can become a large part of the time necessary to compute
the important volatile set. We add a flag purging all known obsstore related
data.

For example, computing the 'bumped' set currently requires reading the full
obsstore, so timing greatly differ with or without that flag:

Without:
! bumped
! wall 0.005047 comb 0.000000 user 0.000000 sys 0.000000 (best of 446)

With:
! bumped
! wall 0.512367 comb 0.510000 user 0.480000 sys 0.030000 (best of 15)
Yuya Nishihara - May 22, 2017, 1:01 p.m.
On Sun, 21 May 2017 13:44:48 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1495366327 -7200
> #      Sun May 21 13:32:07 2017 +0200
> # Node ID 94371c6bd54f4dd50ba3fe7c4e86759407312d85
> # Parent  eb7674b12d5a15fc53f10b075dcac7bee91379d2
> # EXP-Topic obscache
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 94371c6bd54f
> perf: allow to clear the obsstore in 'perfvolatilesets'

Looks good. Queued, thanks.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1120,7 +1120,15 @@  def perfrevset(ui, repo, expr, clear=Fal
     timer(d)
     fm.end()
 
-@command('perfvolatilesets', formatteropts)
+def _clearobsstore(repo):
+    unfi = repo.unfiltered()
+    if 'obsstore' in vars(unfi):
+        del unfi.obsstore
+        del unfi._filecache['obsstore']
+
+@command('perfvolatilesets',
+         [('', 'clear-obsstore', False, 'drop obsstore between each call.'),
+         ] + formatteropts)
 def perfvolatilesets(ui, repo, *names, **opts):
     """benchmark the computation of various volatile set
 
@@ -1131,6 +1139,8 @@  def perfvolatilesets(ui, repo, *names, *
     def getobs(name):
         def d():
             repo.invalidatevolatilesets()
+            if opts['clear_obsstore']:
+                _clearobsstore(repo)
             obsolete.getrevs(repo, name)
         return d
 
@@ -1144,6 +1154,8 @@  def perfvolatilesets(ui, repo, *names, *
     def getfiltered(name):
         def d():
             repo.invalidatevolatilesets()
+            if opts['clear_obsstore']:
+                _clearobsstore(repo)
             repoview.filterrevs(repo, name)
         return d