Patchwork [1,of,2,STABLE] profiling: revert the default mode back to 'cpu' on Windows

login
register
mail settings
Submitter Matt Harbison
Date Oct. 25, 2018, 2:48 a.m.
Message ID <89703e6151e72be5f658.1540435681@Envy>
Download mbox | patch
Permalink /patch/36273/
State Accepted
Headers show

Comments

Matt Harbison - Oct. 25, 2018, 2:48 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1540434250 14400
#      Wed Oct 24 22:24:10 2018 -0400
# Branch stable
# Node ID 89703e6151e72be5f65876dc9f81c90525e13c53
# Parent  49c7b701fdc2a8659b6f752aef507764d40ed5d0
profiling: revert the default mode back to 'cpu' on Windows

On Windows, os.times() only returns user and system times.  Real elapsed time is
0.  That results in no actual times reported, an end wall time of 0.000000, and
seemingly randomly sorted stack frames.  This at least provides test stability
in test-profile.t.

I kind of think that `default=pycompat.iswindows and 'cpu' or 'real'` would be a
better way to set the default in configitems, but I didn't see any other
examples of this, and thought maybe there's a reason for that.  That might allow
plugging the value into the help text automatically- the documented default
wasn't updated in db0dba2d157d.
Yuya Nishihara - Oct. 25, 2018, 10:48 a.m.
On Wed, 24 Oct 2018 22:48:01 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1540434250 14400
> #      Wed Oct 24 22:24:10 2018 -0400
> # Branch stable
> # Node ID 89703e6151e72be5f65876dc9f81c90525e13c53
> # Parent  49c7b701fdc2a8659b6f752aef507764d40ed5d0
> profiling: revert the default mode back to 'cpu' on Windows

Queued for stable, thanks.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -923,7 +923,7 @@  coreconfigitem('profiling', 'statformat'
     default='hotpath',
 )
 coreconfigitem('profiling', 'time-track',
-    default='real',
+    default=dynamicdefault,
 )
 coreconfigitem('profiling', 'type',
     default='stat',
diff --git a/mercurial/profiling.py b/mercurial/profiling.py
--- a/mercurial/profiling.py
+++ b/mercurial/profiling.py
@@ -101,7 +101,8 @@  def statprofile(ui, fp):
     else:
         ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)
 
-    track = ui.config('profiling', 'time-track')
+    track = ui.config('profiling', 'time-track',
+                      pycompat.iswindows and 'cpu' or 'real')
     statprof.start(mechanism='thread', track=track)
 
     try: