Patchwork [6,of,6] profiling: allow configuring minimum display threshold for hotpath

login
register
mail settings
Submitter Gregory Szorc
Date June 15, 2017, 6:18 p.m.
Message ID <cb05c6acff5665e118e7.1497550696@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21399/
State Accepted
Headers show

Comments

Gregory Szorc - June 15, 2017, 6:18 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1497550251 25200
#      Thu Jun 15 11:10:51 2017 -0700
# Node ID cb05c6acff5665e118e71a1ba6e0f49bd0fc358e
# Parent  4c12e71de97e5e390e8ee78f9942724a5f024d64
profiling: allow configuring minimum display threshold for hotpath

statprof.display_hotpath() accepts a "limit" function to choose the
minimum threshold for samples to display. The default is 0.05, which
means you don't need individual items contributing less than 5%.

I had a need to adjust this threshold. We already have a config
option for it. So let's reuse it.

check-config.py doesn't like having multiple defaults for the
ui.configwith() calls. The behavior is obviously correct. I'm
not sure if it is worth teaching check-config.py how to ignore
this. So I've just accepted the new output.
Yuya Nishihara - June 16, 2017, 1:13 p.m.
On Thu, 15 Jun 2017 11:18:16 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1497550251 25200
> #      Thu Jun 15 11:10:51 2017 -0700
> # Node ID cb05c6acff5665e118e71a1ba6e0f49bd0fc358e
> # Parent  4c12e71de97e5e390e8ee78f9942724a5f024d64
> profiling: allow configuring minimum display threshold for hotpath

Queued, thanks.

> check-config.py doesn't like having multiple defaults for the
> ui.configwith() calls. The behavior is obviously correct. I'm
> not sure if it is worth teaching check-config.py how to ignore
> this. So I've just accepted the new output.

I prefer not leaving a known-good error since it isn't easy to say whether
it is a real error.

Patch

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1580,6 +1580,7 @@  profiling is done using lsprof.
 
     Only used by the ``stat`` profiler.
 
+    For the ``hotpath`` format, default is ``0.05``.
     For the ``chrome`` format, default is ``0.005``.
 
     The option is unused on other formats.
diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -138,6 +138,9 @@  def statprofile(ui, fp):
             showmin = ui.configwith(fraction, 'profiling', 'showmin', 0.005)
             showmax = ui.configwith(fraction, 'profiling', 'showmax', 0.999)
             kwargs.update(minthreshold=showmin, maxthreshold=showmax)
+        elif profformat == 'hotpath':
+            limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
+            kwargs['limit'] = limit
 
         statprof.display(fp, data=data, format=displayformat, **kwargs)
 
diff --git a/tests/test-check-config.t b/tests/test-check-config.t
--- a/tests/test-check-config.t
+++ b/tests/test-check-config.t
@@ -33,3 +33,6 @@  New errors are not allowed. Warnings are
 
   $ hg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |
   >   python contrib/check-config.py
+              limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
+  
+  conflict on profiling.showmin: ('with', '0.05') != ('with', '0.005')