Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/47592
to review the following change.
Change subject: profiling: disambiguate profile identifiers
..
profiling: disambiguate profile identifiers
Upcoming patches want to add memory profiling,
so the CPU profiling will not be the only one.
This patch changes all the profile related identifers
by prepending the 'cpu_' string to reflect that.
Change-Id: Ia43159009318295313855a16688b249982e40b34
Signed-off-by: Francesco Romani
Reviewed-on: https://gerrit.ovirt.org/36011
Reviewed-by: Dan Kenigsberg
---
M lib/vdsm/config.py.in
M lib/vdsm/profiling/cpu.py
M tests/cpuProfileTests.py
3 files changed, 16 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/47592/2
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index ef05a4a..f327231 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -29,17 +29,17 @@
('core_dump_enable', 'true',
'Enable core dump.'),
-('profile_enable', 'false',
+('cpu_profile_enable', 'false',
'Enable whole process profiling (requires yappi profiler).'),
-('profile_format', 'pstat',
+('cpu_profile_format', 'pstat',
'Profile file format (pstat, callgrind, ystat)'),
-('profile_builtins', 'false',
+('cpu_profile_builtins', 'false',
'Profile builtin functions used by standard Python modules. '
'false by default.'),
-('profile_clock', 'cpu',
+('cpu_profile_clock', 'cpu',
'Sets the underlying clock type (cpu, wall)'),
('host_mem_reserve', '256',
@@ -363,6 +363,7 @@
('guests_gateway_ip', '', None),
]),
+
]
diff --git a/lib/vdsm/profiling/cpu.py b/lib/vdsm/profiling/cpu.py
index ce5b546..e14ca95 100644
--- a/lib/vdsm/profiling/cpu.py
+++ b/lib/vdsm/profiling/cpu.py
@@ -36,9 +36,9 @@
# Defaults
_FILENAME = os.path.join(constants.P_VDSM_RUN, 'vdsmd.prof')
-_FORMAT = config.get('vars', 'profile_format')
-_BUILTINS = config.getboolean('vars', 'profile_builtins')
-_CLOCK = config.get('vars', 'profile_clock')
+_FORMAT = config.get('vars', 'cpu_profile_format')
+_BUILTINS = config.getboolean('vars', 'cpu_profile_builtins')
+_CLOCK = config.get('vars', 'cpu_profile_clock')
_THREADS = True
_lock = threading.Lock()
@@ -49,19 +49,19 @@
def start():
-""" Starts application wide profiling """
+""" Starts application wide CPU profiling """
if is_enabled():
_start_profiling(_CLOCK, _BUILTINS, _THREADS)
def stop():
-""" Stops application wide profiling """
+""" Stops application wide CPU profiling """
if is_enabled():
_stop_profiling(_FILENAME, _FORMAT)
def is_enabled():
-return config.getboolean('vars', 'profile_enable')
+return config.getboolean('vars', 'cpu_profile_enable')
def is_running():
@@ -91,7 +91,7 @@
def _start_profiling(clock, builtins, threads):
global yappi
-logging.debug("Starting profiling")
+logging.debug("Starting CPU profiling")
import yappi
@@ -100,13 +100,13 @@
# yappi is already started, happily having too different code paths
# that thinks they own the single process profiler.
if yappi.is_running():
-raise Error('Profiler is already running')
+raise Error('CPU profiler is already running')
yappi.set_clock_type(clock)
yappi.start(builtins=builtins, profile_threads=threads)
def _stop_profiling(filename, format):
-logging.debug("Stopping profiling")
+logging.debug("Stopping CPU profiling")
with _lock:
if yappi.is_running():
yappi.stop()
diff --git a/tests/cpuProfileTests.py b/tests/cpuProfileTests.py
index bc9d478..373e67f 100644
--- a/tests/cpuProfileTests.py
+++ b/tests/cpuProfileTests.py
@@ -44,7 +44,7 @@
def make_config(enable='false'):
cfg = ConfigParser.ConfigParser()
config.set_defaults(cfg)
-cfg.set('vars', 'profile_enable', enable)
+cfg.set('vars', 'cpu_profile_enable', enable)
return cfg
@@ -171,7 +171,7 @@
# Function profile must succeed if profile is disabled in config.
@MonkeyPatch(cpu, 'config', make_config(enable='true'))
-def test_profile_disabled(self):
+def test_cpu_profile_disabled(self):
requires_yappi()
self.profiled_function()
self.assertNotRaises(pstats.Stats, FILENAME)
--
To view, visit https://gerrit.ovirt.org/47592
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia43159009318295313855a16688b249982e40b34
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani
Gerrit-Reviewer: Dan Kenigsberg