Patchwork [3,of,3] perf: measure slicing time in perfrevlogrevision

login
register
mail settings
Submitter Boris Feld
Date Nov. 6, 2018, 10:34 a.m.
Message ID <71b1cbf7a7b59d06972b.1541500463@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/36411/
State Accepted
Headers show

Comments

Boris Feld - Nov. 6, 2018, 10:34 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1541498713 -3600
#      Tue Nov 06 11:05:13 2018 +0100
# Node ID 71b1cbf7a7b59d06972b18c9f3cab27019b2cb0e
# Parent  59d548edb4ce2dafb989ffc2d0a95fb4bb19d2ee
# EXP-Topic sparse-prefrevlogrevision
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 71b1cbf7a7b5
perf: measure slicing time in perfrevlogrevision

Slicing a sparse delta chain can be expensive. We now benchmark the associated
time.
Yuya Nishihara - Nov. 6, 2018, 11:28 a.m.
On Tue, 06 Nov 2018 11:34:23 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1541498713 -3600
> #      Tue Nov 06 11:05:13 2018 +0100
> # Node ID 71b1cbf7a7b59d06972b18c9f3cab27019b2cb0e
> # Parent  59d548edb4ce2dafb989ffc2d0a95fb4bb19d2ee
> # EXP-Topic sparse-prefrevlogrevision
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 71b1cbf7a7b5
> perf: measure slicing time in perfrevlogrevision

Queued the series, thanks. I've fixed a couple of typos in docstring.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1692,10 +1692,11 @@  def perfrevlogrevision(ui, repo, file_, 
     Obtaining a revlog revision consists of roughly the following steps:
 
     1. Compute the delta chain
-    2. Obtain the raw chunks for that delta chain
-    3. Decompress each raw chunk
-    4. Apply binary patches to obtain fulltext
-    5. Verify hash of fulltext
+    2. slice the delta chain if applicatble
+    3. Obtain the raw chunks for that delta chain
+    4. Decompress each raw chunk
+    5. Apply binary patches to obtain fulltext
+    6. Verify hash of fulltext
 
     This command measures the time spent in each of these phases.
     """
@@ -1749,6 +1750,10 @@  def perfrevlogrevision(ui, repo, file_, 
         for item in slicedchain:
             segmentforrevs(item[0], item[-1])
 
+    def doslice(r, chain, size):
+        for s in slicechunk(r, chain, targetsize=size):
+            pass
+
     def dorawchunks(data, chain):
         if not cache:
             r.clearcaches()
@@ -1797,11 +1802,18 @@  def perfrevlogrevision(ui, repo, file_, 
         (lambda: dorevision(), b'full'),
         (lambda: dodeltachain(rev), b'deltachain'),
         (lambda: doread(chain), b'read'),
+    ]
+
+    if getattr(r, '_withsparseread', False):
+        slicing = (lambda: doslice(r, chain, size), b'slice-sparse-chain')
+        benches.append(slicing)
+
+    benches.extend([
         (lambda: dorawchunks(data, slicedchain), b'rawchunks'),
         (lambda: dodecompress(rawchunks), b'decompress'),
         (lambda: dopatch(text, bins), b'patch'),
         (lambda: dohash(text), b'hash'),
-    ]
+    ])
 
     timer, fm = gettimer(ui, opts)
     for fn, title in benches: