aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin DuBois <kevindubois@google.com>2017-10-30 13:51:28 -0700
committerKevin DuBois <kevindubois@google.com>2017-10-31 13:00:36 -0700
commit04b7016e8a090ac8147874bab99041345f312b98 (patch)
tree26227aab10928822b22ab43e71eefe40beb67769
parent9fdfb32d507915e46c874d0ec144a4eebdb283ca (diff)
downloadlisa-04b7016e8a090ac8147874bab99041345f312b98.tar.gz
libs/utils: fix the plotting of CPU residency.
Upstream changed 'comm' to 'TaskName', which broke parsing. CPU residency analysis was not in the integration testing loop, so this includes some changes so that running experiments/run_uibench_cgroup.py is sufficient smoke testing for this analysis feature. If running experiments/run_uibench_cgroup.py, the charts no longer pop up onscreen. This helps with testing, as well as is more consistent with other analysis scripts work. (e.g. FrequencyAnalysis). pylab grabs the output image in the notebook, so the behavior in the .ipynb files is the same. Fixes: 68655983 Test: Run experiments/run_uibench_cgroup.py, and verify the charts produced in the results directory. Test: Run notebooks/residency/task_residencies_uibench.ipynb and make sure that the charts appear correctly. Change-Id: I5c8cc54e9d8fde352c779a9a47c9762bd0dd9905
-rwxr-xr-xexperiments/run_uibench_cgroup.py19
-rw-r--r--libs/utils/analysis/residency_analysis.py19
-rw-r--r--libs/utils/trace.py5
3 files changed, 34 insertions, 9 deletions
diff --git a/experiments/run_uibench_cgroup.py b/experiments/run_uibench_cgroup.py
index 76e91b5..f1d3408 100755
--- a/experiments/run_uibench_cgroup.py
+++ b/experiments/run_uibench_cgroup.py
@@ -58,11 +58,10 @@ parser.add_argument('--serial', dest='serial', action='store',
args = parser.parse_args()
-def experiment():
+def experiment(outdir):
# Get workload
wload = Workload.getInstance(te, 'UiBench')
- outdir=te.res_dir + '_' + args.out_prefix
try:
shutil.rmtree(outdir)
except:
@@ -127,4 +126,18 @@ if args.serial:
te = TestEnv(my_conf, wipe=False)
target = te.target
-results = experiment()
+outdir=te.res_dir + '_' + args.out_prefix
+results = experiment(outdir)
+
+trace_file = os.path.join(outdir, "trace.html")
+tr = Trace(None, trace_file,
+ cgroup_info = {
+ 'cgroups': ['foreground', 'background', 'system-background', 'top-app', 'rt'],
+ 'controller_ids': { 4: 'cpuset', 2: 'schedtune' }
+ },
+ events=[ 'sched_switch', 'cgroup_attach_task_devlib', 'cgroup_attach_task', 'sched_process_fork' ],
+ normalize_time=False)
+
+tr.data_frame.cpu_residencies_cgroup('schedtune')
+tr.analysis.residency.plot_cgroup('schedtune', idle=False)
+tr.analysis.residency.plot_cgroup('schedtune', idle=True)
diff --git a/libs/utils/analysis/residency_analysis.py b/libs/utils/analysis/residency_analysis.py
index 797e2f4..7cfed3d 100644
--- a/libs/utils/analysis/residency_analysis.py
+++ b/libs/utils/analysis/residency_analysis.py
@@ -20,6 +20,8 @@
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
+from matplotlib import __version__ as matplotlib_version
+from packaging import version
import pandas as pd
import pylab as pl
import operator
@@ -214,6 +216,17 @@ class ResidencyAnalysis(AnalysisModule):
controller: name of the controller
idle: Consider idle time?
"""
+ required_version = '1.4'
+ if version.parse(matplotlib_version) >= version.parse(required_version):
+ plt.style.use('ggplot')
+ else:
+ logging.info("matplotlib version ({}) is too old to support ggplot. Upgrade to version {}"\
+ .format(matplotlib_version, required_version))
+
+ suffix = 'with_idle' if idle else 'without_idle'
+ figname = '{}/residency_for_{}_{}_{}.png'\
+ .format(self._trace.plots_dir, cgroup, controller, suffix)
+
df = self._dfg_cpu_residencies_cgroup(controller)
# Plot per-CPU break down for a single CGroup (Single pie plot)
if cgroup != 'all':
@@ -221,7 +234,6 @@ class ResidencyAnalysis(AnalysisModule):
df = df.drop('total', 1)
df = df.apply(lambda x: x*10)
- plt.style.use('ggplot')
colors = plt.rcParams['axes.color_cycle']
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(8,8))
patches, texts, autotexts = axes.pie(df.loc[cgroup], labels=df.columns, autopct='%.2f', colors=colors)
@@ -233,7 +245,7 @@ class ResidencyAnalysis(AnalysisModule):
plt.setp(autotexts, fontproperties=proptease)
plt.setp(texts, fontproperties=proptease)
- plt.show()
+ pl.savefig(figname, bbox_inches='tight')
return
# Otherwise, Plot per-CGroup of a Controller down for each CPU
@@ -241,7 +253,6 @@ class ResidencyAnalysis(AnalysisModule):
df = df[pd.isnull(df.index) != True]
# Bug in matplot lib causes plotting issues when residency is < 1
df = df.apply(lambda x: x*10)
- plt.style.use('ggplot')
colors = plt.rcParams['axes.color_cycle']
fig, axes = plt.subplots(nrows=5, ncols=2, figsize=(12,30))
@@ -250,7 +261,7 @@ class ResidencyAnalysis(AnalysisModule):
ax.set(ylabel='', title=col, aspect='equal')
axes[0, 0].legend(bbox_to_anchor=(0, 0.5))
- plt.show()
+ pl.savefig(figname, bbox_inches='tight')
diff --git a/libs/utils/trace.py b/libs/utils/trace.py
index 089a3c3..6b4c8b0 100644
--- a/libs/utils/trace.py
+++ b/libs/utils/trace.py
@@ -604,8 +604,9 @@ class Trace(object):
sdf = sdf.join(self._pid_tgid, on='prev_pid').rename(columns = {'tgid': 'prev_tgid'})
df = self._tasks_by_pid.rename(columns = { 'next_comm': 'comm' })
- sdf = sdf.join(df, on='next_tgid').rename(columns = {'comm': 'next_tgid_comm'})
- sdf = sdf.join(df, on='prev_tgid').rename(columns = {'comm': 'prev_tgid_comm'})
+
+ sdf = sdf.join(df, on='next_tgid').rename(columns = {'TaskName': 'next_tgid_comm'})
+ sdf = sdf.join(df, on='prev_tgid').rename(columns = {'TaskName': 'prev_tgid_comm'})
return sdf
###############################################################################