bart.sched.SchedAssert module

bart.sched.SchedAssert provides ability to assert scheduler behaviour. The analysis is based on TRAPpy’s statistics framework and is potent enough to aggregate statistics over processor hierarchies.

class bart.sched.SchedAssert.SchedAssert(ftrace, topology, execname=None, pid=None)[source]

Bases: object

The primary focus of this class is to assert and verify predefined scheduler scenarios. This does not compare parameters across runs

Parameters:
  • ftrace (trappy.ftrace.FTrace) – A single trappy.FTrace object or a path that can be passed to trappy.FTrace
  • topology (trappy.stats.Topology.Topology) – A topology that describes the arrangement of CPU’s on a system. This is useful for multi-cluster systems where data needs to be aggregated at different topological levels
  • execname (str) –

    The execname of the task to be analysed

    Note

    There should be only one PID that maps to the specified execname. If there are multiple PIDs bart.sched.SchedMultiAssert should be used

  • pid (int) – The process ID of the task to be analysed
assertDutyCycle(expected_value, operator, window)[source]
Parameters:
  • operator

    A binary operator function that returns a boolean. For example:

    import operator
    op = operator.ge
    assertPeriod(expected_value, op)
    

    Will do the following check:

    getPeriod() >= expected_value
    

    A custom function can also be passed:

    THRESHOLD=5
    def between_threshold(a, expected):
        return abs(a - expected) <= THRESHOLD
    
  • window (tuple) – A (start, end) tuple to limit the scope of the calculation.
assertFirstCpu(cpus, window=None)[source]

Check if the Task started (first ran on in the duration of the trace) on a particular CPU(s)

Parameters:cpus (int, list) – A list of acceptable CPUs

See also

bart.sched.SchedAssert.SchedAssert.getFirstCPU

assertPeriod(expected_value, operator, window=None, align='start')[source]

Assert on the period of the task

Parameters:
  • expected_value (double) – The expected value of the runtime
  • operator

    A binary operator function that returns a boolean. For example:

    import operator
    op = operator.ge
    assertPeriod(expected_value, op)
    

    Will do the following check:

    getPeriod() >= expected_value
    

    A custom function can also be passed:

    THRESHOLD=5
    def between_threshold(a, expected):
        return abs(a - expected) <= THRESHOLD
    
  • window (tuple) – A (start, end) tuple to limit the scope of the calculation.
  • align"start" aligns period calculation to switch-in events "end" aligns the calculation to switch-out events
assertResidency(level, node, expected_value, operator, window=None, percent=False)[source]
Parameters:
  • level (str) – The topological level to which the group belongs
  • node (list) – The group of CPUs for which residency needs to calculated
  • expected_value (double) – The expected value of the residency
  • operator (function) –

    A binary operator function that returns a boolean. For example:

    import operator
    op = operator.ge
    assertResidency(level, node, expected_value, op)
    

    Will do the following check:

    getResidency(level, node) >= expected_value
    

    A custom function can also be passed:

    THRESHOLD=5
    def between_threshold(a, expected):
        return abs(a - expected) <= THRESHOLD
    
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • percent (bool) – If true the result is normalized to the total runtime of the task and returned as a percentage
assertRuntime(expected_value, operator, window=None, percent=False)[source]

Assert on the total runtime of the task

Parameters:
  • expected_value (double) – The expected value of the runtime
  • operator (function) –

    A binary operator function that returns a boolean. For example:

    import operator
    op = operator.ge
    assertRuntime(expected_value, op)
    

    Will do the following check:

    getRuntime() >= expected_value
    

    A custom function can also be passed:

    THRESHOLD=5
    def between_threshold(a, expected):
        return abs(a - expected) <= THRESHOLD
    
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • percent (bool) – If True, the result is returned as a percentage of the total execution time of the run.
assertSwitch(level, from_node, to_node, window, ignore_multiple=True)[source]
This function asserts that there is context switch from the
from_node to the to_node:
Parameters:
  • level (str) – The topological level to which the group belongs
  • from_node (list) – The node from which the task switches out
  • to_node (list) – The node to which the task switches
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • ignore_multiple (bool) – If true, the function will ignore multiple switches in the window, If false the assert will be true if and only if there is a single switch within the specified window
generate_events(level, start_id=0, window=None)[source]

Generate events for the trace plot

Note

This is an internal function accessed by the bart.sched.SchedMultiAssert class for plotting data

getDutyCycle(window)[source]

Return the duty cycle of the task

Parameters:window (tuple) – A (start, end) tuple to limit the scope of the calculation.
Duty Cycle:

The percentage of time the task spends executing in the given window of time

\[\delta_{cycle} = \frac{T_{exec} \times 100}{T_{window}}\]
getEndTime()[source]
Returns:The first last time the task ran across all the CPUs
getFirstCpu(window=None)[source]
Returns:The first CPU the task ran on

See also

bart.sched.SchedAssert.SchedAssert.assertFirstCPU

getLastCpu(window=None)[source]

Return the last CPU the task ran on

getPeriod(window=None, align='start')[source]

Return the period of the task in (ms)

Let’s say a task started execution at the following times:

\[T_1, T_2, ...T_n\]

The period is defined as:

\[Median((T_2 - T_1), (T_4 - T_3), ....(T_n - T_{n-1}))\]
Parameters:
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • align"start" aligns period calculation to switch-in events "end" aligns the calculation to switch-out events
getResidency(level, node, window=None, percent=False)[source]

Residency of the task is the amount of time it spends executing a particular group of a topological level. For example:

from trappy.stats.Topology import Topology

big = [1, 2]
little = [0, 3, 4, 5]

topology = Topology(clusters=[little, big])

s = SchedAssert(trace, topology, pid=123)
s.getResidency("cluster", big)

This will return the residency of the task on the big cluster. If percent is specified it will be normalized to the total runtime of the task

Parameters:
  • level (str) – The topological level to which the group belongs
  • node (list) – The group of CPUs for which residency needs to calculated
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • percent (bool) – If true the result is normalized to the total runtime of the task and returned as a percentage
\[R = \frac{T_{group} \times 100}{T_{total}}\]
getRuntime(window=None, percent=False)[source]

Return the Total Runtime of a task

Parameters:
  • window (tuple) – A (start, end) tuple to limit the scope of the residency calculation.
  • percent (bool) – If True, the result is returned as a percentage of the total execution time of the run.
getStartTime()[source]
Returns:The first time the task ran across all the CPUs
plot(level='cpu', window=None, xlim=None)[source]
Returns:trappy.plotter.AbstractDataPlotter instance Call view() to draw the graph