diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -84,8 +84,8 @@ def perfindex(ui, repo):
     mercurial.revlog._prereadsize = 2**24 # disable old lazy parser
     n = repo["tip"].node()
     def d():
+        repo.invalidate()
         repo[n]
-        repo.invalidate()
     timer(d)
 
 def perfstartup(ui, repo):