aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Nikitin <denik@google.com>2019-09-20 13:04:31 -0700
committerDenis Nikitin <denik@chromium.org>2019-09-24 00:38:48 +0000
commit73a0d2ad68df4db8ba08bf15faece66d5a98aa44 (patch)
tree82a120dc374db8de0be3222f46943c5c13c9a72c
parent05ee05dc9b9f8d87cb94be112f0b1dde939ed181 (diff)
downloadtoolchain-utils-73a0d2ad68df4db8ba08bf15faece66d5a98aa44.tar.gz
crosperf: Add top_interval argument to experiment
Added the following optional argument in the global settings: "top_interval" - Run top command in the background of a benchmark with interval of sampling specified in seconds (float type). With zero value don't run top (default value). Top output is stored in <resultsdir>/top.log. BUG=chromium:966514 TEST=unittests and HW tests on eve, kevin64, scarlet passed. Change-Id: I87b187c85912140fc0c16e224580b60061c8bd94 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1817121 Tested-by: Denis Nikitin <denik@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xcrosperf/crosperf_unittest.py2
-rw-r--r--crosperf/experiment_factory.py1
-rwxr-xr-xcrosperf/experiment_file_unittest.py2
-rw-r--r--crosperf/experiment_files/dut_config.exp7
-rw-r--r--crosperf/settings_factory.py13
-rwxr-xr-xcrosperf/settings_factory_unittest.py5
-rw-r--r--crosperf/suite_runner.py5
-rwxr-xr-xcrosperf/suite_runner_unittest.py3
8 files changed, 32 insertions, 6 deletions
diff --git a/crosperf/crosperf_unittest.py b/crosperf/crosperf_unittest.py
index 84f646a6..57e23b81 100755
--- a/crosperf/crosperf_unittest.py
+++ b/crosperf/crosperf_unittest.py
@@ -67,7 +67,7 @@ class CrosperfTest(unittest.TestCase):
settings = crosperf.ConvertOptionsToSettings(options)
self.assertIsNotNone(settings)
self.assertIsInstance(settings, settings_factory.GlobalSettings)
- self.assertEqual(len(settings.fields), 36)
+ self.assertEqual(len(settings.fields), 37)
self.assertTrue(settings.GetField('rerun'))
argv = ['crosperf/crosperf.py', 'temp.exp']
options, _ = parser.parse_known_args(argv)
diff --git a/crosperf/experiment_factory.py b/crosperf/experiment_factory.py
index 9bf42d4f..5d004256 100644
--- a/crosperf/experiment_factory.py
+++ b/crosperf/experiment_factory.py
@@ -166,6 +166,7 @@ class ExperimentFactory(object):
'governor': global_settings.GetField('governor'),
'cpu_usage': global_settings.GetField('cpu_usage'),
'cpu_freq_pct': global_settings.GetField('cpu_freq_pct'),
+ 'top_interval': global_settings.GetField('top_interval'),
}
# Default cache hit conditions. The image checksum in the cache and the
diff --git a/crosperf/experiment_file_unittest.py b/crosperf/experiment_file_unittest.py
index f0d5178b..79ee48c0 100755
--- a/crosperf/experiment_file_unittest.py
+++ b/crosperf/experiment_file_unittest.py
@@ -94,6 +94,7 @@ DUT_CONFIG_EXPERIMENT_FILE_GOOD = """
governor: powersave
cpu_usage: exclusive_cores
cpu_freq_pct: 50
+ top_interval: 5
benchmark: speedometer {
iterations: 3
@@ -221,6 +222,7 @@ class ExperimentFileTest(unittest.TestCase):
self.assertEqual(global_settings.GetField('cpu_freq_pct'), 50)
self.assertEqual(global_settings.GetField('cooldown_time'), 5)
self.assertEqual(global_settings.GetField('cooldown_temp'), 38)
+ self.assertEqual(global_settings.GetField('top_interval'), 5)
def testLoadDutConfigExperimentFile_WrongGovernor(self):
input_file = StringIO.StringIO(DUT_CONFIG_EXPERIMENT_FILE_BAD_GOV)
diff --git a/crosperf/experiment_files/dut_config.exp b/crosperf/experiment_files/dut_config.exp
index fe8f8f77..fb81ba89 100644
--- a/crosperf/experiment_files/dut_config.exp
+++ b/crosperf/experiment_files/dut_config.exp
@@ -16,6 +16,13 @@ remote: <your-remote-goes-here>
#
# Run turbostat process in background. Default: True.
turbostat: <True|False>
+# Run top process in background with specified interval of sampling in
+# seconds, type float. 0 - don't run top.
+# Default: 0
+# Recommended values 1-5 (Lower number provides more accurate data).
+# NOTE: Running top with interval 1-5 sec has insignificant
+# performance impact (performance degradation does not exceed 0.3%).
+top_interval: <interval_in_seconds_float>
# One of Intel Pstate modes defined in kernel command line:
# active, passive, no_hwp.
intel_pstate: <active|passive|no_hwp>
diff --git a/crosperf/settings_factory.py b/crosperf/settings_factory.py
index 1fbc8e14..1f2693c6 100644
--- a/crosperf/settings_factory.py
+++ b/crosperf/settings_factory.py
@@ -347,6 +347,19 @@ class GlobalSettings(Settings):
required=False,
default=True))
self.AddField(
+ FloatField(
+ 'top_interval',
+ description='Run top command in the background of a benchmark with'
+ ' interval of sampling specified in seconds.\n'
+ 'Recommended values 1-5. Lower number provides more accurate'
+ ' data.\n'
+ 'With 0 - do not run top.\n'
+ 'NOTE: Running top with interval 1-5 sec has insignificant'
+ ' performance impact (performance degradation does not exceed 0.3%,'
+ ' measured on x86_64, ARM32, and ARM64).',
+ required=False,
+ default=0))
+ self.AddField(
IntegerField(
'cooldown_temp',
required=False,
diff --git a/crosperf/settings_factory_unittest.py b/crosperf/settings_factory_unittest.py
index 633f2e5f..d80dbb12 100755
--- a/crosperf/settings_factory_unittest.py
+++ b/crosperf/settings_factory_unittest.py
@@ -50,7 +50,7 @@ class GlobalSettingsTest(unittest.TestCase):
def test_init(self):
res = settings_factory.GlobalSettings('g_settings')
self.assertIsNotNone(res)
- self.assertEqual(len(res.fields), 36)
+ self.assertEqual(len(res.fields), 37)
self.assertEqual(res.GetField('name'), '')
self.assertEqual(res.GetField('board'), '')
self.assertEqual(res.GetField('skylab'), False)
@@ -78,6 +78,7 @@ class GlobalSettingsTest(unittest.TestCase):
self.assertEqual(res.GetField('ignore_min_max'), False)
self.assertEqual(res.GetField('intel_pstate'), '')
self.assertEqual(res.GetField('turbostat'), True)
+ self.assertEqual(res.GetField('top_interval'), 0)
self.assertEqual(res.GetField('cooldown_time'), 0)
self.assertEqual(res.GetField('cooldown_temp'), 40)
self.assertEqual(res.GetField('governor'), 'performance')
@@ -105,7 +106,7 @@ class SettingsFactoryTest(unittest.TestCase):
g_settings = settings_factory.SettingsFactory().GetSettings(
'global', 'global')
self.assertIsInstance(g_settings, settings_factory.GlobalSettings)
- self.assertEqual(len(g_settings.fields), 36)
+ self.assertEqual(len(g_settings.fields), 37)
if __name__ == '__main__':
diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py
index 7203b63b..43d5bca3 100644
--- a/crosperf/suite_runner.py
+++ b/crosperf/suite_runner.py
@@ -630,11 +630,12 @@ class SuiteRunner(object):
test_args = test_args[1:-1]
args_string = "test_args='%s'" % test_args
+ top_interval = self.dut_config['top_interval']
cmd = ('{} {} {} --board={} --args="{} run_local={} test={} '
- 'turbostat={} {}" {} telemetry_Crosperf'.format(
+ 'turbostat={} top_interval={} {}" {} telemetry_Crosperf'.format(
TEST_THAT_PATH, autotest_dir_arg, fast_arg, label.board,
args_string, benchmark.run_local, benchmark.test_name,
- benchmark.turbostat, profiler_args, machine))
+ benchmark.turbostat, top_interval, profiler_args, machine))
# Use --no-ns-pid so that cros_sdk does not create a different
# process namespace and we can kill process created easily by their
diff --git a/crosperf/suite_runner_unittest.py b/crosperf/suite_runner_unittest.py
index bac93a85..10cd3a7a 100755
--- a/crosperf/suite_runner_unittest.py
+++ b/crosperf/suite_runner_unittest.py
@@ -848,6 +848,7 @@ class SuiteRunnerTest(unittest.TestCase):
self.mock_cmd_exec.ChrootRunCommandWOutput = mock_chroot_runcmd
profiler_args = ("--profiler=custom_perf --profiler_args='perf_options"
'="record -a -e cycles,instructions"\'')
+ self.runner.dut_config['top_interval'] = 3
res = self.runner.Telemetry_Crosperf_Run('lumpy1.cros', self.mock_label,
self.telemetry_crosperf_bench, '',
profiler_args)
@@ -860,7 +861,7 @@ class SuiteRunnerTest(unittest.TestCase):
('/usr/bin/test_that --autotest_dir '
'~/trunk/src/third_party/autotest/files --fast '
'--board=lumpy --args=" run_local=False test=octane '
- 'turbostat=True profiler=custom_perf '
+ 'turbostat=True top_interval=3 profiler=custom_perf '
'profiler_args=\'record -a -e cycles,instructions\'" '
'lumpy1.cros telemetry_Crosperf'))
self.assertEqual(args_dict['cros_sdk_options'],