FreqInvarianceTest is a LisaTest class for automated testing of frequency invariant load tracking. This notebook uses the methods it provides to perform the same analysis as the automated test and plot some results.
The test class runs the same workload at a selection of frequencies, each entry in t.experiments represents a run at a different frequency.
In [1]:
%matplotlib inline
In [2]:
import pandas as pd
import json
from trace import Trace
from trappy.plotter import plot_trace
from trappy.stats.grammar import Parser
from trappy import ILinePlot
In [3]:
import logging
from conf import LisaLogging
LisaLogging.setup()
logging.getLogger('Analysis').setLevel(logging.ERROR)
logging.getLogger('Trace').setLevel(logging.ERROR)
In [4]:
from tests.eas.load_tracking import FreqInvarianceTest
t = FreqInvarianceTest()
print t.__doc__
To run automated tests from within a notebook we instantiate the test class and call runExperiments on it.
In [5]:
t.runExperiments()
In [6]:
# Get the frequency an experiment was run at
def experiment_freq(exp):
[cpu] = exp.wload.cpus
freq = exp.conf['cpufreq']['freqs'][cpu]
return freq
freqs = [experiment_freq(e) for e in t.experiments]
In [7]:
def plot_signal_against_freq(signal):
means = [t.get_signal_mean(e, signal) for e in t.experiments]
limits = (0 , max(means) * 1.15)
pd.DataFrame(means, index=freqs, columns=['Mean ' + signal]).plot(kind='bar', ylim=limits)
In [8]:
t.get_trace(t.experiments[0]).available_events
Out[8]:
In [9]:
plot_signal_against_freq('util_avg')
In [10]:
plot_signal_against_freq('load_avg')
Plot task residency and sched_util and sched_load for the workload task, along with the expected mean value for util_avg. Note that assuming the system was under little load, so that the task was RUNNING whenever it was RUNNABLE, load_avg and util_avg should be the same.
Call examine_experiment with different experiment indexes to get plots for runs at different frequencies.
In [11]:
signals = ['util_avg', 'load_avg']
def examine_experiment(idx):
experiment = t.experiments[idx]
[freq] = experiment.conf['cpufreq']['freqs'].values()
print "Experiment ran at frequency {}".format(freq)
events = t.te.test_conf["ftrace"]["events"]
print 'Trace plot:'
plot_trace(t.get_trace(experiment).ftrace)
# Get observed signal
signal_df = t.get_sched_task_signals(experiment, signals)
# Get expected average value for util_avg signal
expected_util_avg_mean = t.get_expected_util_avg(experiment)
# Plot task util_avg signal with expected mean value
util_avg_mean = pd.Series([expected_util_avg_mean], name='expected_util_avg', index=[signal_df.index[0]])
df = pd.concat([signal_df, util_avg_mean], axis=1).ffill()
ILinePlot(df, column=signals + ['expected_util_avg'], drawstyle='steps-post',
title='Scheduler task signals').view()
In [12]:
for i , f in enumerate(freqs):
print "Experiment {}:{:10d}Hz".format(i, f)
In [13]:
examine_experiment(0)