Patchwork [3,of,3] perf: support measuring bdiff for all changeset related data

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 6, 2016, 7:03 p.m.
Message ID <1c7269484883804b6f96.1478458997@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17377/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 6, 2016, 7:03 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478458015 28800
#      Sun Nov 06 10:46:55 2016 -0800
# Node ID 1c7269484883804b6f960e87309169ef4ae85043
# Parent  91a510590fa6f4003f596bf661cb17da8800ecde
perf: support measuring bdiff for all changeset related data

The --all argument changes the behavior of `perfbdiff` to pull
in fulltext revision pairs for all changes related to a changeset.
The p1 and p2 manifests will be bdiffed against current. Every file
that changed between p1 and current will have its file revisions
loaded and bdiffed.

This mode of operation effectively measured the bdiff time required
for `hg commit`.
Augie Fackler - Nov. 9, 2016, 4:44 p.m.
On Sun, Nov 06, 2016 at 11:03:17AM -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1478458015 28800
> #      Sun Nov 06 10:46:55 2016 -0800
> # Node ID 1c7269484883804b6f960e87309169ef4ae85043
> # Parent  91a510590fa6f4003f596bf661cb17da8800ecde
> perf: support measuring bdiff for all changeset related data

Queued these, thanks.

>
> The --all argument changes the behavior of `perfbdiff` to pull
> in fulltext revision pairs for all changes related to a changeset.
> The p1 and p2 manifests will be bdiffed against current. Every file
> that changed between p1 and current will have its file revisions
> loaded and bdiffed.
>
> This mode of operation effectively measured the bdiff time required
> for `hg commit`.
>
> diff --git a/contrib/perf.py b/contrib/perf.py
> --- a/contrib/perf.py
> +++ b/contrib/perf.py
> @@ -748,7 +748,8 @@ def perffncacheencode(ui, repo, **opts):
>      fm.end()
>
>  @command('perfbdiff', revlogopts + formatteropts + [
> -    ('', 'count', 1, 'number of revisions to test (when using --startrev)')],
> +    ('', 'count', 1, 'number of revisions to test (when using --startrev)'),
> +    ('', 'alldata', False, 'test bdiffs for all associated revisions')],
>      '-c|-m|FILE REV')
>  def perfbdiff(ui, repo, file_, rev=None, count=None, **opts):
>      """benchmark a bdiff between revisions
> @@ -757,7 +758,14 @@ def perfbdiff(ui, repo, file_, rev=None,
>
>      With ``--count``, benchmark bdiffs between delta parents and self for N
>      revisions starting at the specified revision.
> +
> +    With ``--alldata``, assume the requested revision is a changeset and
> +    measure bdiffs for all changes related to that changeset (manifest
> +    and filelogs).
>      """
> +    if opts['alldata']:
> +        opts['changelog'] = True
> +
>      if opts.get('changelog') or opts.get('manifest'):
>          file_, rev = None, file_
>      elif rev is None:
> @@ -769,8 +777,25 @@ def perfbdiff(ui, repo, file_, rev=None,
>
>      startrev = r.rev(r.lookup(rev))
>      for rev in range(startrev, min(startrev + count, len(r) - 1)):
> -        dp = r.deltaparent(rev)
> -        textpairs.append((r.revision(dp), r.revision(rev)))
> +        if opts['alldata']:
> +            # Load revisions associated with changeset.
> +            ctx = repo[rev]
> +            mtext = repo.manifest.revision(ctx.manifestnode())
> +            for pctx in ctx.parents():
> +                pman = repo.manifest.revision(pctx.manifestnode())
> +                textpairs.append((pman, mtext))
> +
> +            # Load filelog revisions by iterating manifest delta.
> +            man = ctx.manifest()
> +            pman = ctx.p1().manifest()
> +            for filename, change in pman.diff(man).items():
> +                fctx = repo.file(filename)
> +                f1 = fctx.revision(change[0][0] or -1)
> +                f2 = fctx.revision(change[1][0] or -1)
> +                textpairs.append((f1, f2))
> +        else:
> +            dp = r.deltaparent(rev)
> +            textpairs.append((r.revision(dp), r.revision(rev)))
>
>      def d():
>          for pair in textpairs:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -748,7 +748,8 @@  def perffncacheencode(ui, repo, **opts):
     fm.end()
 
 @command('perfbdiff', revlogopts + formatteropts + [
-    ('', 'count', 1, 'number of revisions to test (when using --startrev)')],
+    ('', 'count', 1, 'number of revisions to test (when using --startrev)'),
+    ('', 'alldata', False, 'test bdiffs for all associated revisions')],
     '-c|-m|FILE REV')
 def perfbdiff(ui, repo, file_, rev=None, count=None, **opts):
     """benchmark a bdiff between revisions
@@ -757,7 +758,14 @@  def perfbdiff(ui, repo, file_, rev=None,
 
     With ``--count``, benchmark bdiffs between delta parents and self for N
     revisions starting at the specified revision.
+
+    With ``--alldata``, assume the requested revision is a changeset and
+    measure bdiffs for all changes related to that changeset (manifest
+    and filelogs).
     """
+    if opts['alldata']:
+        opts['changelog'] = True
+
     if opts.get('changelog') or opts.get('manifest'):
         file_, rev = None, file_
     elif rev is None:
@@ -769,8 +777,25 @@  def perfbdiff(ui, repo, file_, rev=None,
 
     startrev = r.rev(r.lookup(rev))
     for rev in range(startrev, min(startrev + count, len(r) - 1)):
-        dp = r.deltaparent(rev)
-        textpairs.append((r.revision(dp), r.revision(rev)))
+        if opts['alldata']:
+            # Load revisions associated with changeset.
+            ctx = repo[rev]
+            mtext = repo.manifest.revision(ctx.manifestnode())
+            for pctx in ctx.parents():
+                pman = repo.manifest.revision(pctx.manifestnode())
+                textpairs.append((pman, mtext))
+
+            # Load filelog revisions by iterating manifest delta.
+            man = ctx.manifest()
+            pman = ctx.p1().manifest()
+            for filename, change in pman.diff(man).items():
+                fctx = repo.file(filename)
+                f1 = fctx.revision(change[0][0] or -1)
+                f2 = fctx.revision(change[1][0] or -1)
+                textpairs.append((f1, f2))
+        else:
+            dp = r.deltaparent(rev)
+            textpairs.append((r.revision(dp), r.revision(rev)))
 
     def d():
         for pair in textpairs: