Patchwork [1,of,2] perffncachewrite: load fncache after lock is acquired

login
register
mail settings
Submitter Boris Feld
Date July 16, 2018, 7:27 a.m.
Message ID <fa319c92bed5fc495d62.1531726060@FB-lair>
Download mbox | patch
Permalink /patch/32853/
State Accepted
Headers show

Comments

Boris Feld - July 16, 2018, 7:27 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1531526987 -7200
#      Sat Jul 14 02:09:47 2018 +0200
# Node ID fa319c92bed5fc495d62122697ee32a8fe2be8c4
# Parent  cc76692f401d0063cd5dfaf46f0fca1563a85fae
# EXP-Topic perffncachewrite
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fa319c92bed5
perffncachewrite: load fncache after lock is acquired

Without this patch, running perffncachewrite on a repository destroy its
fncache.

Lock Acquisition drops various caches, including the fncache one. Then writing
of an non-loaded fncache result into an empty one.
Yuya Nishihara - July 16, 2018, 9:40 a.m.
On Mon, 16 Jul 2018 09:27:40 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1531526987 -7200
> #      Sat Jul 14 02:09:47 2018 +0200
> # Node ID fa319c92bed5fc495d62122697ee32a8fe2be8c4
> # Parent  cc76692f401d0063cd5dfaf46f0fca1563a85fae
> # EXP-Topic perffncachewrite
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fa319c92bed5
> perffncachewrite: load fncache after lock is acquired

Looks good. Queued, thanks.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -957,9 +957,10 @@  def perffncacheload(ui, repo, **opts):
 def perffncachewrite(ui, repo, **opts):
     timer, fm = gettimer(ui, opts)
     s = repo.store
+    lock = repo.lock()
     s.fncache._load()
-    lock = repo.lock()
     tr = repo.transaction('perffncachewrite')
+    tr.addbackup('fncache')
     def d():
         s.fncache._dirty = True
         s.fncache.write(tr)
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -145,7 +145,11 @@  perfstatus
 #if repofncache
   $ hg perffncacheencode
   $ hg perffncacheload
+  $ hg debugrebuildfncache
+  fncache already up to date
   $ hg perffncachewrite
+  $ hg debugrebuildfncache
+  fncache already up to date
 #endif
   $ hg perfheads
   $ hg perfindex