trappy.ftrace module

class trappy.ftrace.FTrace(path='.', name='', normalize_time=True, scope='all', events=[], window=(0, None), abs_window=(0, None))[source]

Bases: trappy.ftrace.GenericFTrace

A wrapper class that initializes all the classes of a given run

  • The FTrace class can receive the following optional parameters.
Parameters:
  • path (str) – Path contains the path to the trace file. If no path is given, it uses the current directory by default. If path is a file, and ends in .dat, it’s run through “trace-cmd report”. If it doesn’t end in ”.dat”, then it must be the output of a trace-cmd report run. If path is a directory that contains a trace.txt, that is assumed to be the output of “trace-cmd report”. If path is a directory that doesn’t have a trace.txt but has a trace.dat, it runs trace-cmd report on the trace.dat, saves it in trace.txt and then uses that.
  • name (str) – is a string describing the trace.
  • normalize_time (bool) – is used to make all traces start from time 0 (the default). If normalize_time is False, the trace times are the same as in the trace file.
  • scope (str) – can be used to limit the parsing done on the trace. The default scope parses all the traces known to trappy. If scope is thermal, only the thermal classes are parsed. If scope is sched, only the sched classes are parsed.
  • events (list) – A list of strings containing the name of the trace events that you want to include in this FTrace object. The string must correspond to the event name (what you would pass to “trace-cmd -e”, i.e. 4th field in trace.txt)
  • window (tuple) – a tuple indicating a time window. The first element in the tuple is the start timestamp and the second one the end timestamp. Timestamps are relative to the first trace event that’s parsed. If you want to trace until the end of the trace, set the second element to None. If you want to use timestamps extracted from the trace file use “abs_window”.
  • abs_window (tuple) – a tuple indicating an absolute time window. This parameter is similar to the “window” one but its values represent timestamps that are not normalized, (i.e. the ones you find in the trace file)

This is a simple example:

import trappy
trappy.FTrace("trace_dir")
class trappy.ftrace.GenericFTrace(name='', normalize_time=True, scope='all', events=[], window=(0, None), abs_window=(0, None))[source]

Bases: trappy.bare_trace.BareTrace

Generic class to parse output of FTrace. This class is meant to be subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.

dynamic_classes = {}
get_all_freqs_data(map_label)[source]

get an array of tuple of names and DataFrames suitable for the allfreqs plot

plot_allfreqs(map_label, width=None, height=None, ax=None)[source]

Do allfreqs plots similar to those of CompareRuns

if ax is not none, it must be an array of the same size as map_label. Each plot will be done in each of the axis in ax

plot_freq_hists(map_label, ax)[source]

Plot histograms for each actor input and output frequency

ax is an array of axis, one for the input power and one for the output power

plot_load(mapping_label, title='', width=None, height=None, ax=None)[source]

plot the load of all the clusters, similar to how compare runs did it

the mapping_label has to be a dict whose keys are the cluster numbers as found in the trace and values are the names that will appear in the legend.

plot_normalized_load(mapping_label, title='', width=None, height=None, ax=None)[source]

plot the normalized load of all the clusters, similar to how compare runs did it

the mapping_label has to be a dict whose keys are the cluster numbers as found in the trace and values are the names that will appear in the legend.

classmethod register_parser(cobject, scope)[source]

Register the class as an Event. This function can be used to register a class which is associated with an FTrace unique word.

sched_classes = {'sched_load_avg_task': <class 'trappy.sched.SchedLoadAvgTask'>, 'sched_contrib_scale_factor': <class 'trappy.dynamic.SchedContribScaleFactor'>, 'cpu_capacity': <class 'trappy.sched.SchedCpuCapacity'>, 'sched_load_avg_sg': <class 'trappy.sched.SchedLoadAvgSchedGroup'>, 'sched_load_avg_cpu': <class 'trappy.dynamic.SchedLoadAvgCpu'>, 'sched_migrate_task': <class 'trappy.dynamic.SchedMigrateTask'>, 'sched_wakeup_new': <class 'trappy.dynamic.SchedWakeupNew'>, 'cpu_frequency': <class 'trappy.sched.SchedCpuFrequency'>, 'sched_switch': <class 'trappy.sched.SchedSwitch'>, 'sched_wakeup': <class 'trappy.dynamic.SchedWakeup'>}
thermal_classes = {'cpu_out_power': <class 'trappy.cpu_power.CpuOutPower'>, 'pid_controller': <class 'trappy.pid_controller.PIDController'>, 'thermal': <class 'trappy.thermal.Thermal'>, 'devfreq_out_power': <class 'trappy.devfreq_power.DevfreqOutPower'>, 'thermal_governor': <class 'trappy.thermal.ThermalGovernor'>, 'cpu_in_power': <class 'trappy.cpu_power.CpuInPower'>, 'devfreq_in_power': <class 'trappy.devfreq_power.DevfreqInPower'>}
trace_hasnt_finished()[source]

Return a function that accepts a line and returns true if this line is part of the trace.

This function is called with each line of the file after trace_hasnt_started() returns True so the first line it sees is part of the trace. The returned function should return True as long as the line it receives is part of the trace. As soon as this function returns False, the rest of the file will be dropped. Subclasses of GenericFTrace may override this to stop processing after the end of the trace is found to skip parsing the end of the file if it contains anything other than trace.
trace_hasnt_started()[source]

Return a function that accepts a line and returns true if this line is not part of the trace.

Subclasses of GenericFTrace may override this to skip the beginning of a file that is not part of the trace. The first time the returned function returns False it will be considered the beginning of the trace and this function will never be called again (because once it returns False, the trace has started).
classmethod unregister_parser(cobject)[source]

Unregister a parser

This is the opposite of FTrace.register_parser(), it removes a class from the list of classes that will be parsed on the trace