D4134: perf: call _generatechangelog() instead of group()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Aug 6 19:51:32 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Now that we have a separate function for generating just the changelog
  bits, the perf command should call it so it gets more accurate
  behavior.
  
  This changes the results of this command on my hg repo significantly:
  
  ! wall 1.390502 comb 1.390000 user 1.370000 sys 0.020000 (best of 8)
  ! wall 1.768750 comb 1.760000 user 1.760000 sys 0.000000 (best of 6)
  
  Profiling seems to reveal that ~20% of execution time is spent in
  progress bar accounting and printing! If we run with
  progress.disable=true:
  
  ! wall 1.639134 comb 1.650000 user 1.630000 sys 0.020000 (best of 7)
  
  A nice speedup. But profiling still shows a good chunk of time being
  spent in progress bar accounting code. The reason is that the
  progress bar is conditionally enabled via an argument to
  cgpacker.group(). The previous code in perf.py calling into group()
  did not enable the progress bar but _generatechangelog() always does.
  
  I think it is important for the perf* commands to capture real-world
  use cases. And this code always runs with an active progress bar. So
  the regression is acceptable.
  
  That being said, terminal printing performance can vary substantially.
  I don't think perf* commands should test terminal printing unless
  explicitly desired. So I've disabled progress bar printing in this
  command.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4134

AFFECTED FILES
  contrib/perf.py

CHANGE DETAILS

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -663,21 +663,20 @@
     By default, all revisions are added to the changegroup.
     """
     cl = repo.changelog
-    revs = [cl.lookup(r) for r in repo.revs(rev or 'all()')]
+    nodes = [cl.lookup(r) for r in repo.revs(rev or 'all()')]
     bundler = changegroup.getbundler(version, repo)
 
-    def lookup(node):
-        # The real bundler reads the revision in order to access the
-        # manifest node and files list. Do that here.
-        cl.read(node)
-        return node
-
     def d():
-        for chunk in bundler.group(revs, cl, lookup):
+        state, chunks = bundler._generatechangelog(cl, nodes)
+        for chunk in chunks:
             pass
 
     timer, fm = gettimer(ui, opts)
-    timer(d)
+
+    # Terminal printing can interfere with timing. So disable it.
+    with ui.configoverride({('progress', 'disable'): True}):
+        timer(d)
+
     fm.end()
 
 @command('perfdirs', formatteropts)



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list